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
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   If FeatureParams are defined for this feature, this
82                   contains a reference to the corresponding FeatureParams
83                   object.  Otherwise set to null.
84
85           LOOKUPS This is an array containing indices to lookups in the
86                   LOOKUP instance variable of the table
87
88           INDEX   This gives the feature index for this feature and is used
89                   during reading and writing for converting between feature
90                   tag and feature index.
91
92       LOOKUP
93           This variable is an array of lookups in order and is indexed via
94           the features of a language of a script. Each lookup contains
95           subtables and other information:
96
97           OFFSET  This name is preceeded by a space and contains the offset
98                   from the start of the table to this particular lookup
99
100           TYPE    This is a subclass specific type for a lookup. It
101                   stipulates the type of lookup and hence subtables within
102                   the lookup
103
104           FLAG    Holds the lookup flag bits
105
106           FILTER  Holds the MarkFilteringSet (that is, the index into
107                   GDEF->MARKSETS) for the lookup.
108
109           SUB     This holds an array of subtables which are subclass
110                   specific. Each subtable must have an OFFSET. The other
111                   variables described here are an abstraction used in both
112                   the GSUB and GPOS tables which are the target subclasses of
113                   this class.
114
115                   OFFSET      This is preceeded by a space and gives the
116                               offset relative to the start of the table for
117                               this subtable
118
119                   FORMAT      Gives the sub-table sub format for this GSUB
120                               subtable. It is assumed that this value is
121                               correct when it comes time to write the
122                               subtable.
123
124                   COVERAGE    Most lookups consist of a coverage table
125                               corresponding to the first glyph to match. The
126                               offset of this coverage table is stored here
127                               and the coverage table looked up against the
128                               GSUB table proper. There are two lookups
129                               without this initial coverage table which is
130                               used to index into the RULES array.  These
131                               lookups have one element in the RULES array
132                               which is used for the whole match.
133
134                   RULES       The rules are a complex array. Each element of
135                               the array corresponds to an element in the
136                               coverage table (governed by the coverage
137                               index). If there is no coverage table, then
138                               there is considered to be only one element in
139                               the rules array. Each element of the array is
140                               itself an array corresponding to the possibly
141                               multiple string matches which may follow the
142                               initial glyph. Each element of this array is a
143                               hash with fixed keys corresponding to
144                               information needed to match a glyph string or
145                               act upon it. Thus the RULES element is an array
146                               of arrays of hashes which contain the following
147                               keys:
148
149                               MATCH           This contains a sequence of
150                                               elements held as an array. The
151                                               elements may be glyph ids
152                                               (gid), class ids (cids), or
153                                               offsets to coverage tables.
154                                               Each element corresponds to one
155                                               glyph in the glyph string. See
156                                               MATCH_TYPE for details of how
157                                               the different element types are
158                                               marked.
159
160                               PRE             This array holds the sequence
161                                               of elements preceeding the
162                                               first match element and has the
163                                               same form as the MATCH array.
164
165                               POST            This array holds the sequence
166                                               of elements to be tested for
167                                               following the match string and
168                                               is of the same form as the
169                                               MATCH array.
170
171                               ACTION          This array holds information
172                                               regarding what should be done
173                                               if a match is found.  The array
174                                               may either hold glyph ids
175                                               (which are used to replace or
176                                               insert or whatever glyphs in
177                                               the glyph string) or 2 element
178                                               arrays consisting of:
179
180                                               OFFSET              Offset from
181                                                                   the start
182                                                                   of the
183                                                                   matched
184                                                                   string that
185                                                                   the lookup
186                                                                   should
187                                                                   start at
188                                                                   when
189                                                                   processing
190                                                                   the
191                                                                   substring.
192
193                                               LOOKUP_INDEX        The index
194                                                                   to a lookup
195                                                                   to be acted
196                                                                   upon on the
197                                                                   match
198                                                                   string.
199
200       CLASS
201           For those lookups which use class categories rather than glyph ids
202           for matching this is the offset to the class definition used to
203           categories glyphs in the match string.
204
205       PRE_CLASS
206           This is the offset to the class definition for the before match
207           glyphs
208
209       POST_CLASS
210           This is the offset to the class definition for the after match
211           glyphs.
212
213       ACTION_TYPE
214           This string holds the type of information held in the ACTION
215           variable of a RULE.  It is subclass specific.
216
217       MATCH_TYPE
218           This holds the type of information in the MATCH array of a RULE.
219           This is subclass specific.
220
221       ADJUST
222           This corresponds to a single action for all items in a coverage
223           table. The meaning is subclass specific.
224
225       CACHE
226           This key starts with a space
227
228           A hash of other tables (such as coverage tables, classes, anchors,
229           device tables) based on the offset given in the subtable to that
230           other information.  Note that the documentation is particularly
231           unhelpful here in that such tables are given as offsets relative to
232           the beginning of the subtable not the whole GSUB table. This
233           includes those items which are stored relative to another base
234           within the subtable.
235

METHODS

237   $t->read
238       Reads the table passing control to the subclass to handle the subtable
239       specifics
240
241   $t->read_sub($fh, $lookup, $index)
242       This stub is to allow subclasses to read subtables of lookups in a
243       table specific manner. A reference to the lookup is passed in along
244       with the subtable index. The file is located at the start of the
245       subtable to be read
246
247   $t->extension()
248       Returns the lookup number for the extension table that allows access to
249       32-bit offsets.
250
251   $t->out($fh)
252       Writes this Opentype table to the output calling $t->out_sub for each
253       sub table at the appropriate point in the output. The assumption is
254       that on entry the number of scripts, languages, features, lookups, etc.
255       are all resolved and the relationships fixed. This includes a LANG_TAGS
256       list for a script, and that all scripts and languages in their
257       respective dictionaries either have a REFTAG or contain real data.
258
259   $t->num_sub($lookup)
260       Asks the subclass to count the number of subtables for a particular
261       lookup and to return that value. Used in out().
262
263   $t->out_sub($fh, $lookup, $index)
264       This stub is to allow subclasses to output subtables of lookups in a
265       table specific manner. A reference to the lookup is passed in along
266       with the subtable index. The file is located at the start of the
267       subtable to be output
268
269   $t->dirty
270       Setting GPOS or GSUB dirty means that OS/2 may need updating, so set it
271       dirty.
272
273   $t->maxContext
274       Returns the length of the longest opentype rule in this table.
275
276   $t->update
277       Sort COVERAGE table and RULES for all lookups.
278
279       Unless $t->{' PARENT'}{' noharmony'} is true, update will make sure
280       that GPOS and GSUB include the same scripts and languages. Any added
281       scripts and languages will have empty feature sets.
282

Internal Functions & Methods

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

BUGS

334       ยท   No way to share cachable items (coverage tables, classes, anchors,
335           device tables) across different lookups. The items are always
336           output after the lookup and repeated if necessary. Within lookup
337           sharing is possible.
338

AUTHOR

340       Martin Hosken Martin_Hosken@sil.org. See Font::TTF::Font for copyright
341       and licensing.
342
343
344
345perl v5.16.3                      2012-08-08              Font::TTF::Ttopen(3)
Impressum