Thanks so much!! So in the end I managed to do everything I wanted, customising all the handles and nodes size, strokes size, colours, canvas size and size of the glyph within the canvas, how and where to save as png, but I admit this pesky background colour is proving more complicated than I thought. I can save the image as a transparent png so it doesn’t matter too much but I’d rather avoid the extra step of going to Photoshop if it can be done on DrawBot I have tried your method @ddaanniiieeelll, in the sense that I’ve added a fill line above all the code, but it adds another canvas on top of the one with my glyph on it? I’m sorry for being such a beginner, but I don’t understand where and how I should input the fill and rectangle code, if that’s what you were referring to when you said it had to be drawn.
Here is some example of my code for now, which gives a transparent background:
from GlyphsApp import *
import os
font = Glyphs.font
filedir = os.path.dirname("/Library/Application Support/Adobe/Fonts/MyFont.otf")
#filedir = os.path.join(filedir, "Subfolder")
def drawOnNode(node, handleSize):
if handleSize == 0:
return
pt = node.position
nodeType = node.type
size = 1
fill(255/255, 0/255, 0/255)
if nodeType == GSCURVE or nodeType == GSLINE:
rect(pt.x - (size / 2), pt.y - (size / 2), size, size)
def drawOffNode(node, handleSize):
if handleSize == 0:
return
pt = node.position
nodeType = node.type
size = 1
fill(255/255, 0/255, 0/255)
if nodeType != GSCURVE and nodeType != GSLINE:
index = node.parent.indexOfNode_(node)
prevNode = node.parent.nodes[index - 1]
nextNode = node.parent.nodes[index + 1]
if prevNode.type == GSOFFCURVE:
newPath()
moveTo(node.position)
lineTo(nextNode.position)
drawPath()
else:
newPath()
moveTo(node.position)
lineTo(prevNode.position)
drawPath()
oval(pt.x - (size / 2), pt.y - (size / 2), size, size)
def drawSize(layer, Width, Scale, handleSize = 10):
newPage(Width, Width)
offset = (Width - (layer.width * Scale)) / 2
translate(offset,offset)
scale(Scale)
fill(0, 0, 0)
drawPath(layer.bezierPath)
save()
strokeWidth(0.5)
stroke(255/255, 0/255, 0/255)
for p in layer.paths:
for n in p.nodes:
drawOffNode(n, handleSize)
for n in p.nodes:
drawOnNode(n, handleSize)
saveImage("/Users/Me/Desktop/test.png")
layer = Glyphs.font.selectedLayers[0]
layer = layer.copy()
layer.removeOverlap()
drawSize(layer, 4000, 5, 22)
(I apologise if the code is not formatted well, I’ve looked up how to do it but didn’t found anything)