MCPcopy Create free account
hub / github.com/PageBot/PageBot / drawGlyph

Method drawGlyph

Lib/pagebot/contexts/basecontext/basecontext.py:1247–1270  ·  view source on GitHub ↗

Draw the font[glyphName] at the defined position with the defined fontSize.

(self, glyph, x, y, fill=noColor, stroke=noColor,
            strokeWidth=0, fontSize=None, xTextAlign=LEFT)

Source from the content-addressed store, hash-verified

1245 # Glyphs.
1246
1247 def drawGlyph(self, glyph, x, y, fill=noColor, stroke=noColor,
1248 strokeWidth=0, fontSize=None, xTextAlign=LEFT):
1249 """Draw the font[glyphName] at the defined position with the defined
1250 fontSize."""
1251 font = glyph.font
1252
1253 if fontSize is None:
1254 fontSize = font.info.unitsPerEm
1255 s = fontSize / font.info.unitsPerEm
1256
1257 if xTextAlign == CENTER:
1258 x -= (glyph.width or 0) / 2*s
1259 elif xTextAlign == RIGHT:
1260 x -= glyph.width*s
1261
1262 #self.save()
1263 self.fill(fill)
1264 self.stroke(stroke, w=strokeWidth)
1265 self.translate(x, y)
1266 self.scale(s)
1267 self.drawGlyphPath(glyph)
1268 self.scale(1/s)
1269 self.translate(-x, -y)
1270 #self.restore()
1271
1272
1273 def drawGlyphPath(self, glyph):

Callers

nothing calls this directly

Calls 5

fillMethod · 0.95
strokeMethod · 0.95
translateMethod · 0.95
scaleMethod · 0.95
drawGlyphPathMethod · 0.95

Tested by

no test coverage detected