forked from robotools/compositor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.html
169 lines (77 loc) · 3.77 KB
/
usage.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<h1>Compositor Usage Reference</h1>
<p>This document covers the basic usage of the compositor package. For more detailed information read the documentation strings in the source.</p>
<h2>Asumptions</h2>
Some assumptions about the OpenType fonts being used are made by the package:
<ul>
<li>The font is valid.</li>
<li>The font’s <em>cmap</em> table contains Platform 3 Encoding 1.</li>
<li>The font does not contain <em><span class="caps">GSUB</span></em> or <em><span class="caps">GPOS</span></em> lookup types that are not supported by the <span class="caps">GSUB</span> or <span class="caps">GPOS</span> objects. If an unsupported lookup type is present, the lookup will simply be ignored. It will not raise an error.</li>
</ul>
<h2>The Font Object</h2>
<h3>Importing</h3>
<pre>
from compositor import Font
</pre>
<h3>Construction</h3>
<pre>
font = Font(path)
</pre>
<p><strong>path</strong> A path to an OpenType font.</p>
<h3>Special Behavior</h3>
<pre>
glyph = font["aGlyphName"]
</pre>
<p>Returns the glyph object named “aGlyphName”. This will raise a KeyError if “aGlyphName” is not in the font.</p>
<pre>
isThere = "aGlyphName" in font
</pre>
<p>Returns a boolean representing if “aGlyphName” is in the font.</p>
<h3>Methods</h3>
<pre>
font.keys()
</pre>
<p>A list of all glyph names in the font.</p>
<pre>
glyphRecords = font.process(aString)
</pre>
<p>This is the most important method. It takes a string (Unicode or plain <span class="caps">ASCII</span>) and processes it with the features defined in the font’s <em><span class="caps">GSUB</span></em> and <em><span class="caps">GPOS</span></em> tables. A list of <em>GlyphRecord</em> objects will be returned.</p>
<pre>
featureTags = font.getFeatureList()
</pre>
<p>A list of all available features in <span class="caps">GSUB</span> and <span class="caps">GPOS</span>.</p>
<pre>
state = font.getFeatureState(featureTag)
</pre>
<p>Get a boolean representing if a feature is on or not. This assumes that the feature state is consistent in both the <span class="caps">GSUB</span> and <span class="caps">GPOS</span> tables. A <em>CompositorError</em> will be raised if the feature is inconsistently applied. A <em>CompositorError</em> will be raised if featureTag is not defined in <span class="caps">GSUB</span> or <span class="caps">GPOS</span>.</p>
<pre>
font.setFeatureState(self, featureTag, state)
</pre>
<p>Set the application state of a feature.</p>
<h3>Attributes</h3>
<p><strong>info</strong> The Info object for the font.</p>
<h2>The GlyphRecord Object</h2>
<h3>Attributes</h3>
<p><strong>glyphName</strong> The name of the referenced glyph.</p>
<p><strong>xPlacement</strong> Horizontal placement.</p>
<p><strong>yPlacement</strong> Vertical placement.</p>
<p><strong>xAdvance</strong> Horizontal adjustment for advance.</p>
<p><strong>yAdvance</strong> Vertical adjustment for advance.</p>
<p><strong>alternates</strong> A list of <em>GlyphRecords</em> indicating alternates for the glyph.</p>
<h2>The Glyph Object</h2>
<h3>Methods</h3>
<pre>
glyph.draw(pen)
</pre>
<p>Draws the glyph with a FontTools pen.</p>
<h3>Attributes</h3>
<p><strong>name</strong> The name of the glyph.</p>
<p><strong>index</strong> The glyph’s index within the source font.</p>
<p><strong>width</strong> The width of the glyph.</p>
<p><strong>bounds</strong> The bounding box for the glyph. Formatted as (xMin, yMin, xMax, yMax). If the glyph contains no outlines, this will return <em>None</em>.</p>
<h2>The Info Object</h2>
<h3>Attributes</h3>
<p><strong>familyName</strong></p>
<p><strong>styleName</strong></p>
<p><strong>unitsPerEm</strong></p>
<p><strong>ascender</strong></p>
<p><strong>descender</strong></p>