1Font::TTF::Ttopen(3)  User Contributed Perl Documentation Font::TTF::Ttopen(3)
2
3
4

NAME

6       Font::TTF::Ttopen - Opentype superclass for standard Opentype lookup
7       based tables (GSUB and GPOS)
8

DESCRIPTION

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

INSTANCE VARIABLES

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 corre‐
30                   sponding script tag to this one such that the offsets in
31                   the file are the same. When writing, it is up to the caller
32                   to ensure that the REFTAGs are set correctly, since these
33                   will be used to assume that the scripts are identical. Note
34                   that REFTAG must refer to a script which has no REFTAG of
35                   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 indices which index
62                               into the FEATURES instance variable of the ta‐
63                               ble
64
65       FEATURES
66           The features section of instance variables corresponds to the fea‐
67           ture table in the opentype table.
68
69           FEAT_TAGS
70                   This array gives the ordered list of feature tags for this
71                   table. It is used during reading and writing for converting
72                   between feature index and feature tag.
73
74           The rest of the FEATURES variable is itself a hash based on the
75           feature tag for each feature. Each feature has the following struc‐
76           ture:
77
78           OFFSET  This attribute is preceeded by a space and gives the offset
79                   relative to the start of the whole table of this particular
80                   feature.
81
82           PARMS   This is an unused offset to the parameters for each feature
83
84           LOOKUPS This is an array containing indices to lookups in the
85                   LOOKUP instance variable of the table
86
87           INDEX   This gives the feature index for this feature and is used
88                   during reading and writing for converting between feature
89                   tag and feature index.
90
91       LOOKUP
92           This variable is an array of lookups in order and is indexed via
93           the features of a language of a script. Each lookup contains subta‐
94           bles and other information:
95
96           OFFSET  This name is preceeded by a space and contains the offset
97                   from the start of the table to this particular lookup
98
99           TYPE    This is a subclass specific type for a lookup. It stipu‐
100                   lates the type of lookup and hence subtables within the
101                   lookup
102
103           FLAG    Holds the lookup flag bits
104
105           SUB     This holds an array of subtables which are subclass spe‐
106                   cific. Each subtable must have an OFFSET. The other vari‐
107                   ables described here are an abstraction used in both the
108                   GSUB and GPOS tables which are the target subclasses of
109                   this class.
110
111                   OFFSET      This is preceeded by a space and gives the off‐
112                               set relative to the start of the table for this
113                               subtable
114
115                   FORMAT      Gives the sub-table sub format for this GSUB
116                               subtable. It is assumed that this value is cor‐
117                               rect when it comes time to write the subtable.
118
119                   COVERAGE    Most lookups consist of a coverage table corre‐
120                               sponding to the first glyph to match. The off‐
121                               set of this coverage table is stored here and
122                               the coverage table looked up against the GSUB
123                               table proper. There are two lookups without
124                               this initial coverage table which is used to
125                               index into the RULES array.  These lookups have
126                               one element in the RULES array which is used
127                               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 cov‐
131                               erage table (governed by the coverage index).
132                               If there is no coverage table, then there is
133                               considered to be only one element in the rules
134                               array. Each element of the array is itself an
135                               array corresponding to the possibly multiple
136                               string matches which may follow the initial
137                               glyph. Each element of this array is a hash
138                               with fixed keys corresponding to information
139                               needed to match a glyph string or act upon it.
140                               Thus the RULES element is an array of arrays of
141                               hashes which contain the following keys:
142
143                               MATCH           This contains a sequence of
144                                               elements held as an array. The
145                                               elements may be glyph ids
146                                               (gid), class ids (cids), or
147                                               offsets to coverage tables.
148                                               Each element corresponds to one
149                                               glyph in the glyph string. See
150                                               MATCH_TYPE for details of how
151                                               the different element types are
152                                               marked.
153
154                               PRE             This array holds the sequence
155                                               of elements preceeding the
156                                               first match element and has the
157                                               same form as the MATCH array.
158
159                               POST            This array holds the sequence
160                                               of elements to be tested for
161                                               following the match string and
162                                               is of the same form as the
163                                               MATCH array.
164
165                               ACTION          This array holds information
166                                               regarding what should be done
167                                               if a match is found.  The array
168                                               may either hold glyph ids
169                                               (which are used to replace or
170                                               insert or whatever glyphs in
171                                               the glyph string) or 2 element
172                                               arrays consisting of:
173
174                                               OFFSET              Offset from
175                                                                   the start
176                                                                   of the
177                                                                   matched
178                                                                   string that
179                                                                   the lookup
180                                                                   should
181                                                                   start at
182                                                                   when pro‐
183                                                                   cessing the
184                                                                   substring.
185
186                                               LOOKUP_INDEX        The index
187                                                                   to a lookup
188                                                                   to be acted
189                                                                   upon on the
190                                                                   match
191                                                                   string.
192
193       CLASS
194           For those lookups which use class categories rather than glyph ids
195           for matching this is the offset to the class definition used to
196           categories glyphs in the match string.
197
198       PRE_CLASS
199           This is the offset to the class definition for the before match
200           glyphs
201
202       POST_CLASS
203           This is the offset to the class definition for the after match
204           glyphs.
205
206       ACTION_TYPE
207           This string holds the type of information held in the ACTION vari‐
208           able of a RULE.  It is subclass specific.
209
210       MATCH_TYPE
211           This holds the type of information in the MATCH array of a RULE.
212           This is subclass specific.
213
214       ADJUST
215           This corresponds to a single action for all items in a coverage ta‐
216           ble. The meaning is subclass specific.
217
218       CACHE
219           This key starts with a space
220
221           A hash of other tables (such as coverage tables, classes, anchors,
222           device tables) based on the offset given in the subtable to that
223           other information.  Note that the documentation is particularly
224           unhelpful here in that such tables are given as offsets relative to
225           the beginning of the subtable not the whole GSUB table. This
226           includes those items which are stored relative to another base
227           within the subtable.
228

METHODS

230       $t->read
231
232       Reads the table passing control to the subclass to handle the subtable
233       specifics
234
235       $t->read_sub($fh, $lookup, $index)
236
237       This stub is to allow subclasses to read subtables of lookups in a ta‐
238       ble specific manner. A reference to the lookup is passed in along with
239       the subtable index. The file is located at the start of the subtable to
240       be read
241
242       $t->extension()
243
244       Returns the lookup number for the extension table that allows access to
245       32-bit offsets.
246
247       $t->out($fh)
248
249       Writes this Opentype table to the output calling $t->out_sub for each
250       sub table at the appropriate point in the output. The assumption is
251       that on entry the number of scripts, languages, features, lookups, etc.
252       are all resolved and the relationships fixed. This includes a script's
253       LANG_TAGS list and that all scripts and languages in their respective
254       dictionaries either have a REFTAG or contain real data.
255
256       $t->num_sub($lookup)
257
258       Asks the subclass to count the number of subtables for a particular
259       lookup and to return that value. Used in out().
260
261       $t->out_sub($fh, $lookup, $index)
262
263       This stub is to allow subclasses to output subtables of lookups in a
264       table specific manner. A reference to the lookup is passed in along
265       with the subtable index. The file is located at the start of the sub‐
266       table to be output
267

Internal Functions & Methods

269       Most of these methods are used by subclasses for handling such things
270       as coverage tables.
271
272       copy($ref)
273
274       Internal function to copy the top level of a dictionary to create a new
275       dictionary.  Only the top level is copied.
276
277       $t->read_cover($cover_offset, $lookup_loc, $lookup, $fh, $is_cover)
278
279       Reads a coverage table and stores the results in $lookup->{' CACHE'},
280       that is, if it hasn't been read already.
281
282       ref_cache($obj, $cache, $offset)
283
284       Internal function to keep track of the local positioning of subobjects
285       such as coverage and class definition tables, and their offsets.  What
286       happens is that the cache is a hash of sub objects indexed by the ref‐
287       erence (using a string mashing of the reference name which is valid for
288       the duration of the reference) and holds a list of locations in the
289       output string which should be filled in with the offset to the sub
290       object when the final string is output in out_final.
291
292       Uses tricks for Tie::Refhash
293
294       out_final($fh, $out, $cache_list, $state)
295
296       Internal function to actually output everything to the file handle
297       given that now we know the offset to the first sub object to be output
298       and which sub objects are to be output and what locations need to be
299       updated, we can now generate everything. $cache_list is an array of two
300       element arrays. The first element is a cache object, the second is an
301       offset to be subtracted from each reference to that object made in the
302       cache.
303
304       If $state is 1, then the output is not sent to the filehandle and the
305       return value is the string to be output. If $state is absent or 0 then
306       output is not limited by storing in a string first and the return value
307       is "";
308
309       $self->read_context($lookup, $fh, $type, $fmt, $cover, $count, $loc)
310
311       Internal method to read context (simple and chaining context) lookup
312       subtables for the GSUB and GPOS table types. The assumed values for
313       $type correspond to those for GSUB, so GPOS should adjust the values
314       upon calling.
315
316       $self->out_context($lookup, $fh, $type, $fmt, $ctables, $out, $num)
317
318       Provides shared behaviour between GSUB and GPOS tables during output
319       for context (chained and simple) rules. In addition, support is pro‐
320       vided here for type 4 GSUB tables, which are not used in GPOS. The
321       value for $type corresponds to the type in a GSUB table so calling from
322       GPOS should adjust the value accordingly.
323

BUGS

325       ·   No way to share cachable items (coverage tables, classes, anchors,
326           device tables) across different lookups. The items are always out‐
327           put after the lookup and repeated if necessary. Within lookup shar‐
328           ing is possible.
329

AUTHOR

331       Martin Hosken Martin_Hosken@sil.org. See Font::TTF::Font for copyright
332       and licensing.
333
334
335
336perl v5.8.8                       2005-06-14              Font::TTF::Ttopen(3)
Impressum