xref: /aosp_15_r20/external/fonttools/Lib/fontTools/otlLib/builder.py.sketch (revision e1fe3e4ad2793916b15cccdc4a7da52a7e1dd0e9)
1*e1fe3e4aSElliott Hughes
2*e1fe3e4aSElliott Hughesfrom fontTools.otlLib import builder as builder
3*e1fe3e4aSElliott Hughes
4*e1fe3e4aSElliott HughesGDEF::mark filtering sets
5*e1fe3e4aSElliott Hughesname::
6*e1fe3e4aSElliott Hughes
7*e1fe3e4aSElliott Hugheslookup_flags = builder.LOOKUP_FLAG_IGNORE_MARKS | builder.LOOKUP_FLAG_RTL
8*e1fe3e4aSElliott Hughessmcp_subtable = builder.buildSingleSubstitute({'a':'a.scmp'})
9*e1fe3e4aSElliott Hughessmcp_lookup = builder.buildLookup([smcp_subtable], lookup_flags=lookup_flags, mark_filter_set=int)
10*e1fe3e4aSElliott Hughes
11*e1fe3e4aSElliott Hugheslookups = [smcp_lookup, ...]
12*e1fe3e4aSElliott Hughes
13*e1fe3e4aSElliott Hughesscmp_feature = builder.buildFeature('smcp', [scmp_lookup], lookup_list=lookups)
14*e1fe3e4aSElliott Hughesscmp_feature = builder.buildFeature('smcp', [0])
15*e1fe3e4aSElliott Hughes
16*e1fe3e4aSElliott Hughesfeatures = [smcp_feature]
17*e1fe3e4aSElliott Hughes
18*e1fe3e4aSElliott Hughesdefault_langsys = builder.buildLangSys(set([scmp_feature]), requiredFeature=None, featureOrder=features)
19*e1fe3e4aSElliott Hughesdefault_langsys = builder.buildLangSys(set([0]), requiredFeature=None)
20*e1fe3e4aSElliott Hughes
21*e1fe3e4aSElliott Hughesscript =
22*e1fe3e4aSElliott Hughes
23*e1fe3e4aSElliott Hughes
24*e1fe3e4aSElliott Hughes#GSUB:
25*e1fe3e4aSElliott Hughes
26*e1fe3e4aSElliott Hughesbuilder.buildSingleSubst({'a':'a.scmp'})
27*e1fe3e4aSElliott Hughesbuilder.buildLigatureSubst({('f','i'):'fi'})
28*e1fe3e4aSElliott Hughesbuilder.buildMultipleSubst({'a':('a0','a1')})
29*e1fe3e4aSElliott Hughesbuilder.buildAlternateSubst({'a':('a.0','a.1')})
30*e1fe3e4aSElliott Hughes
31*e1fe3e4aSElliott Hughes
32*e1fe3e4aSElliott Hughesclass ChainSequence : namedtuple(['backtrack', 'input', 'lookahead')])
33*e1fe3e4aSElliott Hughes	pass
34*e1fe3e4aSElliott Hughes
35*e1fe3e4aSElliott HughesChainSequence(backtrack=..., input=..., lookahead=...)
36*e1fe3e4aSElliott Hughes
37*e1fe3e4aSElliott Hughesklass0 = frozenset()
38*e1fe3e4aSElliott Hughes
39*e1fe3e4aSElliott Hughesbuilder.buildChainContextGlyphs(
40*e1fe3e4aSElliott Hughes	[
41*e1fe3e4aSElliott Hughes		( (None, ('f','f','i'), (,)), ( (1,lookup_fi), (1,lookup_2) ) ),
42*e1fe3e4aSElliott Hughes	],
43*e1fe3e4aSElliott Hughes	glyphMap
44*e1fe3e4aSElliott Hughes)
45*e1fe3e4aSElliott Hughesbuilder.buildChainContextClass(
46*e1fe3e4aSElliott Hughes	[
47*e1fe3e4aSElliott Hughes		( (None, (2,0,1), (,)), ( (1,lookup_fi), (1,lookup_2) ) ),
48*e1fe3e4aSElliott Hughes	],
49*e1fe3e4aSElliott Hughes	klasses = ( backtrackClass, ... ),
50*e1fe3e4aSElliott Hughes	glyphMap
51*e1fe3e4aSElliott Hughes)
52*e1fe3e4aSElliott Hughesbuilder.buildChainContextCoverage(
53*e1fe3e4aSElliott Hughes	( (None, (frozenset('f'),frozenset('f'),frozenset('i')), (,)), ( (1,lookup_fi), (1,lookup_2) ) ),
54*e1fe3e4aSElliott Hughes	glyphMap
55*e1fe3e4aSElliott Hughes)
56*e1fe3e4aSElliott Hughesbuilder.buildExtension(...)
57*e1fe3e4aSElliott Hughes
58*e1fe3e4aSElliott Hughes#GPOS:
59*e1fe3e4aSElliott Hughesdevice = builder.buildDevice()
60*e1fe3e4aSElliott Hughesbuilder.buildAnchor(100, -200) or (100,-200)
61*e1fe3e4aSElliott Hughesbuilder.buildAnchor(100, -200, device=device)
62*e1fe3e4aSElliott Hughesbuilder.buildAnchor(100, -200, point=2)
63*e1fe3e4aSElliott Hughes
64*e1fe3e4aSElliott HughesvalueRecord = builder.buildValue({'XAdvance':-200, ...})
65*e1fe3e4aSElliott Hughes
66*e1fe3e4aSElliott Hughesbuilder.buildSinglePos({'a':valueRecord})
67*e1fe3e4aSElliott Hughesbuilder.buildPairPosGlyphs(
68*e1fe3e4aSElliott Hughes	{
69*e1fe3e4aSElliott Hughes		('a','b'): (valueRecord1,valueRecord2),
70*e1fe3e4aSElliott Hughes	},
71*e1fe3e4aSElliott Hughes	glyphMap,
72*e1fe3e4aSElliott Hughes	, valueFormat1=None, valueFormat2=None
73*e1fe3e4aSElliott Hughes)
74*e1fe3e4aSElliott Hughesbuilder.buildPairPosClasses(
75*e1fe3e4aSElliott Hughes	{
76*e1fe3e4aSElliott Hughes		(frozenset(['a']),frozenset(['b'])): (valueRecord1,valueRecord2),
77*e1fe3e4aSElliott Hughes	},
78*e1fe3e4aSElliott Hughes	glyphMap,
79*e1fe3e4aSElliott Hughes	, valueFormat1=None, valueFormat2=None
80*e1fe3e4aSElliott Hughes)
81*e1fe3e4aSElliott Hughes
82*e1fe3e4aSElliott Hughesbuilder.buildCursivePos(
83*e1fe3e4aSElliott Hughes	{
84*e1fe3e4aSElliott Hughes		'alef': (entry,exit),
85*e1fe3e4aSElliott Hughes	}
86*e1fe3e4aSElliott Hughes	glyphMap
87*e1fe3e4aSElliott Hughes)
88*e1fe3e4aSElliott Hughesbuilder.buildMarkBasePos(
89*e1fe3e4aSElliott Hughes	marks = {
90*e1fe3e4aSElliott Hughes		'mark1': (klass, anchor),
91*e1fe3e4aSElliott Hughes	},
92*e1fe3e4aSElliott Hughes	bases = {
93*e1fe3e4aSElliott Hughes		'base0': [anchor0, anchor1, anchor2],
94*e1fe3e4aSElliott Hughes	},
95*e1fe3e4aSElliott Hughes	glyphMap
96*e1fe3e4aSElliott Hughes)
97*e1fe3e4aSElliott Hughesbuilder.buildMarkBasePos(
98*e1fe3e4aSElliott Hughes	marks = {
99*e1fe3e4aSElliott Hughes		'mark1': (name, anchor),
100*e1fe3e4aSElliott Hughes	},
101*e1fe3e4aSElliott Hughes	bases = {
102*e1fe3e4aSElliott Hughes		'base0': {'top':anchor0, 'left':anchor1},
103*e1fe3e4aSElliott Hughes	},
104*e1fe3e4aSElliott Hughes	glyphMap
105*e1fe3e4aSElliott Hughes)
106