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

Method _getFlatFont

Lib/pagebot/contexts/flatcontext/flatcontext.py:534–549  ·  view source on GitHub ↗

Answer the (cache) FlatFont that corresponds with font. >>> import flat >>> context = FlatContext() >>> font = findFont('PageBot-Regular') >>> context._getFlatFont(font)[0].__class__.__name__ 'font'

(self, font)

Source from the content-addressed store, hash-verified

532 # T E X T
533
534 def _getFlatFont(self, font):
535 """Answer the (cache) FlatFont that corresponds with font.
536
537 >>> import flat
538 >>> context = FlatContext()
539 >>> font = findFont('PageBot-Regular')
540 >>> context._getFlatFont(font)[0].__class__.__name__
541 'font'
542 """
543 if isinstance(font, str):
544 font = findFont(font)
545 if font is None:
546 font = findFont(DEFAULT_FONT)
547 if not font.path in self._flatFonts:
548 self._flatFonts[font.path] = self.b.font.open(font.path)
549 return self._flatFonts[font.path], font
550
551 def _place(self, bs, x, y, w=None, h=None):
552 """Places the styled Flat text on a page, transform vertical position

Callers

nothing calls this directly

Calls 2

findFontFunction · 0.90
openMethod · 0.45

Tested by

no test coverage detected