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

Class Font

Lib/pagebot/fonttoolbox/objects/font.py:538–1162  ·  view source on GitHub ↗

Storage of font information while composing the pages. >>> from pagebot.fonttoolbox.objects.font import findFont >>> f = findFont('RobotoDelta-VF') >>> sorted(f.axes.keys()) ['GRAD', 'POPS', 'PWDT', 'PWGT', 'UDLN', 'XOPQ', 'XTRA', 'YOPQ', 'YTAD', 'YTAS', 'YTDD', 'YTDE', 'YTLC', 'YTR

Source from the content-addressed store, hash-verified

536 return Font(dstPath, lazy=lazy)
537
538class Font:
539 """Storage of font information while composing the pages.
540
541 >>> from pagebot.fonttoolbox.objects.font import findFont
542 >>> f = findFont('RobotoDelta-VF')
543 >>> sorted(f.axes.keys())
544 ['GRAD', 'POPS', 'PWDT', 'PWGT', 'UDLN', 'XOPQ', 'XTRA', 'YOPQ', 'YTAD', 'YTAS', 'YTDD', 'YTDE', 'YTLC', 'YTRA', 'YTUC', 'opsz', 'wdth', 'wght']
545 >>> f.info.familyName
546 'RobotoDelta'
547 >>> len(f)
548 188
549 >>> f.axes['opsz']
550 (8.0, 12.0, 144.0)
551 >>> variables = f.variables
552 >>> features = f.features
553 >>> f.groups
554 >>> f.designSpace
555 {}
556 """
557 GLYPH_CLASS = Glyph
558 FONTANALYZER_CLASS = FontAnalyzer
559
560 def __init__(self, path=None, ttFont=None, name=None, opticalSize=None,
561 location=None, styleName=None, lazy=True):
562 """Initialize the TTFont, for which Font is a wrapper. self.name is
563 supported, in case the calling function wants to use a different
564
565 >>> f = Font()
566 >>> f
567 <Font Untitled Untitled>
568 """
569
570 if path is None and ttFont is None:
571 self.ttFont = TTFont()
572 self.path = '%d' % id(ttFont) # In case no path, use unique id instead.
573 elif ttFont is None and path is not None:
574 self.ttFont = TTFont(path, lazy=lazy)
575 self.path = path # File path of the existing font file.
576 elif path is None:
577 self.ttFont = ttFont
578 self.path = '%d' % id(ttFont) # In case no path, use unique id instead.
579 else: # ttFont is not None: There is ttFont data
580 self.ttFont = ttFont
581 self.path = path
582
583 # Store location, in case this was a created VF instance
584 self.location = location
585 # TTFont is available as lazy style.info.font
586 self.info = FontInfo(self.ttFont)
587 self.info.opticalSize = opticalSize # Optional optical size, to indicate where this Variable Font is rendered for.
588 self.info.location = location # Store origina location of this instance of the font is derived from a Variable Font.
589 # Stores optional custom name, otherwise use original DrawBot name.
590 # Otherwise use from FontInfo.fullName
591 self.name = name or self.info.fullName
592 if styleName is not None:
593 self.info.styleName = styleName # Overwrite default style name in the ttFont or Variable Font location
594 self._kerning = None # Lazy reading.
595 self._groups = None # Lazy reading.

Callers 5

__init__Method · 0.90
getFontFunction · 0.85
getInstance2Function · 0.85
makeInstanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected