1Font::TTF::Ttopen(3) User Contributed Perl Documentation Font::TTF::Ttopen(3)
2
3
4
6 Font::TTF::Ttopen - Opentype superclass for standard Opentype lookup
7 based tables (GSUB and GPOS)
8
10 Handles all the script, lang, feature, lookup stuff for a
11 Font::TTF::Gsub/Font::TTF::Gpos table leaving the class specifics to
12 the subclass
13
15 The instance variables of an opentype table form a complex sub-module
16 hierarchy.
17
18 Version
19 This contains the version of the table as a floating point number
20
21 SCRIPTS
22 The scripts list is a hash of script tags. Each script tag (of the
23 form $t->{'SCRIPTS'}{$tag}) has information below it.
24
25 OFFSET This variable is preceeded by a space and gives the offset
26 from the start of the table (not the table section) to the
27 script table for this script
28
29 REFTAG This variable is preceded by a space and gives a
30 corresponding script tag to this one such that the offsets
31 in the file are the same. When writing, it is up to the
32 caller to ensure that the REFTAGs are set correctly, since
33 these will be used to assume that the scripts are
34 identical. Note that REFTAG must refer to a script which
35 has no REFTAG of its own.
36
37 DEFAULT This corresponds to the default language for this script,
38 if there is one, and contains the same information as an
39 itemised language
40
41 LANG_TAGS
42 This contains an array of language tag strings (each 4
43 bytes) corresponding to the languages listed by this script
44
45 $lang Each language is a hash containing its information:
46
47 OFFSET This variable is preceeded by a a space and
48 gives the offset from the start of the whole
49 table to the language table for this language
50
51 REFTAG This variable is preceded by a space and has
52 the same function as for the script REFTAG,
53 only for the languages within a script.
54
55 RE-ORDER This indicates re-ordering information, and has
56 not been set. The value should always be 0.
57
58 DEFAULT This holds the index of the default feature, if
59 there is one, or -1 otherwise.
60
61 FEATURES This is an array of feature tags for all the
62 features enabled for this language
63
64 FEATURES
65 The features section of instance variables corresponds to the
66 feature table in the opentype table.
67
68 FEAT_TAGS
69 This array gives the ordered list of feature tags for this
70 table. It is used during reading and writing for converting
71 between feature index and feature tag.
72
73 The rest of the FEATURES variable is itself a hash based on the
74 feature tag for each feature. Each feature has the following
75 structure:
76
77 OFFSET This attribute is preceeded by a space and gives the offset
78 relative to the start of the whole table of this particular
79 feature.
80
81 PARMS This is an unused offset to the parameters for each feature
82
83 LOOKUPS This is an array containing indices to lookups in the
84 LOOKUP instance variable of the table
85
86 INDEX This gives the feature index for this feature and is used
87 during reading and writing for converting between feature
88 tag and feature index.
89
90 LOOKUP
91 This variable is an array of lookups in order and is indexed via
92 the features of a language of a script. Each lookup contains
93 subtables and other information:
94
95 OFFSET This name is preceeded by a space and contains the offset
96 from the start of the table to this particular lookup
97
98 TYPE This is a subclass specific type for a lookup. It
99 stipulates the type of lookup and hence subtables within
100 the lookup
101
102 FLAG Holds the lookup flag bits
103
104 SUB This holds an array of subtables which are subclass
105 specific. Each subtable must have an OFFSET. The other
106 variables described here are an abstraction used in both
107 the GSUB and GPOS tables which are the target subclasses of
108 this class.
109
110 OFFSET This is preceeded by a space and gives the
111 offset relative to the start of the table for
112 this subtable
113
114 FORMAT Gives the sub-table sub format for this GSUB
115 subtable. It is assumed that this value is
116 correct when it comes time to write the
117 subtable.
118
119 COVERAGE Most lookups consist of a coverage table
120 corresponding to the first glyph to match. The
121 offset of this coverage table is stored here
122 and the coverage table looked up against the
123 GSUB table proper. There are two lookups
124 without this initial coverage table which is
125 used to index into the RULES array. These
126 lookups have one element in the RULES array
127 which is used for the whole match.
128
129 RULES The rules are a complex array. Each element of
130 the array corresponds to an element in the
131 coverage table (governed by the coverage
132 index). If there is no coverage table, then
133 there is considered to be only one element in
134 the rules array. Each element of the array is
135 itself an array corresponding to the possibly
136 multiple string matches which may follow the
137 initial glyph. Each element of this array is a
138 hash with fixed keys corresponding to
139 information needed to match a glyph string or
140 act upon it. Thus the RULES element is an array
141 of arrays of hashes which contain the following
142 keys:
143
144 MATCH This contains a sequence of
145 elements held as an array. The
146 elements may be glyph ids
147 (gid), class ids (cids), or
148 offsets to coverage tables.
149 Each element corresponds to one
150 glyph in the glyph string. See
151 MATCH_TYPE for details of how
152 the different element types are
153 marked.
154
155 PRE This array holds the sequence
156 of elements preceeding the
157 first match element and has the
158 same form as the MATCH array.
159
160 POST This array holds the sequence
161 of elements to be tested for
162 following the match string and
163 is of the same form as the
164 MATCH array.
165
166 ACTION This array holds information
167 regarding what should be done
168 if a match is found. The array
169 may either hold glyph ids
170 (which are used to replace or
171 insert or whatever glyphs in
172 the glyph string) or 2 element
173 arrays consisting of:
174
175 OFFSET Offset from
176 the start
177 of the
178 matched
179 string that
180 the lookup
181 should
182 start at
183 when
184 processing
185 the
186 substring.
187
188 LOOKUP_INDEX The index
189 to a lookup
190 to be acted
191 upon on the
192 match
193 string.
194
195 CLASS
196 For those lookups which use class categories rather than glyph ids
197 for matching this is the offset to the class definition used to
198 categories glyphs in the match string.
199
200 PRE_CLASS
201 This is the offset to the class definition for the before match
202 glyphs
203
204 POST_CLASS
205 This is the offset to the class definition for the after match
206 glyphs.
207
208 ACTION_TYPE
209 This string holds the type of information held in the ACTION
210 variable of a RULE. It is subclass specific.
211
212 MATCH_TYPE
213 This holds the type of information in the MATCH array of a RULE.
214 This is subclass specific.
215
216 ADJUST
217 This corresponds to a single action for all items in a coverage
218 table. The meaning is subclass specific.
219
220 CACHE
221 This key starts with a space
222
223 A hash of other tables (such as coverage tables, classes, anchors,
224 device tables) based on the offset given in the subtable to that
225 other information. Note that the documentation is particularly
226 unhelpful here in that such tables are given as offsets relative to
227 the beginning of the subtable not the whole GSUB table. This
228 includes those items which are stored relative to another base
229 within the subtable.
230
232 $t->read
233 Reads the table passing control to the subclass to handle the subtable
234 specifics
235
236 $t->read_sub($fh, $lookup, $index)
237 This stub is to allow subclasses to read subtables of lookups in a
238 table specific manner. A reference to the lookup is passed in along
239 with the subtable index. The file is located at the start of the
240 subtable to be read
241
242 $t->extension()
243 Returns the lookup number for the extension table that allows access to
244 32-bit offsets.
245
246 $t->out($fh)
247 Writes this Opentype table to the output calling $t->out_sub for each
248 sub table at the appropriate point in the output. The assumption is
249 that on entry the number of scripts, languages, features, lookups, etc.
250 are all resolved and the relationships fixed. This includes a script's
251 LANG_TAGS list and that all scripts and languages in their respective
252 dictionaries either have a REFTAG or contain real data.
253
254 $t->num_sub($lookup)
255 Asks the subclass to count the number of subtables for a particular
256 lookup and to return that value. Used in out().
257
258 $t->out_sub($fh, $lookup, $index)
259 This stub is to allow subclasses to output subtables of lookups in a
260 table specific manner. A reference to the lookup is passed in along
261 with the subtable index. The file is located at the start of the
262 subtable to be output
263
264 $t->dirty
265 Setting GPOS or GSUB dirty means that OS/2 may need updating, so set it
266 dirty.
267
268 $t->maxContext
269 Returns the length of the longest opentype rule in this table.
270
271 $t->update
272 Unless $t->{' PARENT'}{' noharmony'} is true, update will make sure
273 that GPOS and GSUB include the same scripts and languages. Any added
274 scripts and languages will have empty feature sets.
275
277 Most of these methods are used by subclasses for handling such things
278 as coverage tables.
279
280 copy($ref)
281 Internal function to copy the top level of a dictionary to create a new
282 dictionary. Only the top level is copied.
283
284 $t->read_cover($cover_offset, $lookup_loc, $lookup, $fh, $is_cover)
285 Reads a coverage table and stores the results in $lookup->{' CACHE'},
286 that is, if it hasn't been read already.
287
288 ref_cache($obj, $cache, $offset)
289 Internal function to keep track of the local positioning of subobjects
290 such as coverage and class definition tables, and their offsets. What
291 happens is that the cache is a hash of sub objects indexed by the
292 reference (using a string mashing of the reference name which is valid
293 for the duration of the reference) and holds a list of locations in the
294 output string which should be filled in with the offset to the sub
295 object when the final string is output in out_final.
296
297 Uses tricks for Tie::Refhash
298
299 out_final($fh, $out, $cache_list, $state)
300 Internal function to actually output everything to the file handle
301 given that now we know the offset to the first sub object to be output
302 and which sub objects are to be output and what locations need to be
303 updated, we can now generate everything. $cache_list is an array of two
304 element arrays. The first element is a cache object, the second is an
305 offset to be subtracted from each reference to that object made in the
306 cache.
307
308 If $state is 1, then the output is not sent to the filehandle and the
309 return value is the string to be output. If $state is absent or 0 then
310 output is not limited by storing in a string first and the return value
311 is "";
312
313 $self->read_context($lookup, $fh, $type, $fmt, $cover, $count, $loc)
314 Internal method to read context (simple and chaining context) lookup
315 subtables for the GSUB and GPOS table types. The assumed values for
316 $type correspond to those for GSUB, so GPOS should adjust the values
317 upon calling.
318
319 $self->out_context($lookup, $fh, $type, $fmt, $ctables, $out, $num)
320 Provides shared behaviour between GSUB and GPOS tables during output
321 for context (chained and simple) rules. In addition, support is
322 provided here for type 4 GSUB tables, which are not used in GPOS. The
323 value for $type corresponds to the type in a GSUB table so calling from
324 GPOS should adjust the value accordingly.
325
327 ยท No way to share cachable items (coverage tables, classes, anchors,
328 device tables) across different lookups. The items are always
329 output after the lookup and repeated if necessary. Within lookup
330 sharing is possible.
331
333 Martin Hosken Martin_Hosken@sil.org. See Font::TTF::Font for copyright
334 and licensing.
335
336
337
338perl v5.12.0 2008-06-11 Font::TTF::Ttopen(3)