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

Method getInstance

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

Answers the instance of self at location. If the cache file already exists, then just answer a Font instance to that font file. >>> from pagebot.fonttoolbox.objects.font import findFont >>> f = findFont('RobotoDelta-VF') >>> sorted(f.axes.keys()) ['GRAD', 'PO

(self, location=None, dstPath=None, opticalSize=None,
            styleName=None, cached=True, lazy=True, kerning=None)

Source from the content-addressed store, hash-verified

1022 variables = property(_get_variables)
1023
1024 def getInstance(self, location=None, dstPath=None, opticalSize=None,
1025 styleName=None, cached=True, lazy=True, kerning=None):
1026 """Answers the instance of self at location. If the cache file already
1027 exists, then just answer a Font instance to that font file.
1028
1029 >>> from pagebot.fonttoolbox.objects.font import findFont
1030 >>> f = findFont('RobotoDelta-VF')
1031 >>> sorted(f.axes.keys())
1032 ['GRAD', 'POPS', 'PWDT', 'PWGT', 'UDLN', 'XOPQ', 'XTRA', 'YOPQ', 'YTAD', 'YTAS', 'YTDD', 'YTDE', 'YTLC', 'YTRA', 'YTUC', 'opsz', 'wdth', 'wght']
1033 >>> f.name
1034 'RobotoDelta VF'
1035 >>> len(f)
1036 188
1037 >>> f.axes['wght']
1038 (100.0, 400.0, 900.0)
1039 >>> g = f['H']
1040 >>> g
1041 <Glyph 'H' (Pts:12, Cnt:1, Cmp:0)>
1042 >>> g.points[6], g.width
1043 (APoint(1288,1456,On), 1458)
1044 >>> instance = f.getInstance(location=dict(wght=500))
1045 >>> instance
1046 <Font RobotoDelta-VF-wght500>
1047 >>> ig = instance['H']
1048 >>> ig
1049 <Glyph 'H' (Pts:12, Cnt:1, Cmp:0)>
1050 >>> ig.points[6], ig.width
1051 (APoint(1307,1456,On), 1477)
1052 """
1053 if location is None:
1054 location = self.getDefaultVarLocation()
1055 return getInstance(self.path, location=location, dstPath=dstPath, opticalSize=opticalSize,
1056 styleName=styleName, cached=cached, lazy=lazy, kerning=kerning)
1057
1058 def _get_cmap(self):
1059 """Answer the best cmap for this font

Callers

nothing calls this directly

Calls 2

getDefaultVarLocationMethod · 0.95
getInstanceFunction · 0.85

Tested by

no test coverage detected