1Font::TTF::Name(3) User Contributed Perl Documentation Font::TTF::Name(3)
2
3
4
6 Font::TTF::Name - String table for a TTF font
7
9 Strings are held by number, platform, encoding and language. Strings
10 are accessed as:
11
12 $f->{'name'}{'strings'}[$number][$platform_id][$encoding_id]{$language_id}
13
14 Notice that the language is held in an associative array due to its
15 sparse nature on some platforms such as Microsoft ($pid = 3). Notice
16 also that the array order is different from the stored array order
17 (platform, encoding, language, number) to allow for easy manipulation
18 of strings by number (which is what I guess most people will want to
19 do).
20
21 By default, $Font::TTF::Name::utf8 is set to 1, and strings will be
22 stored as UTF8 wherever possible. The method "is_utf8" can be used to
23 find out if a string in a particular platform and encoding will be
24 returned as UTF8. Unicode strings are always converted if utf8 is
25 requested. Otherwise, strings are stored according to platform:
26
27 You now have to set <$Font::TTF::Name::utf8> to 0 to get the old
28 behaviour.
29
30 Apple Unicode (platform id = 0)
31 Data is stored as network ordered UCS2. There is no encoding id for
32 this platform but there are language ids as per Mac language ids.
33
34 Mac (platform id = 1)
35 Data is stored as 8-bit binary data, leaving the interpretation to
36 the user according to encoding id.
37
38 Unicode (platform id = 2)
39 Currently stored as 16-bit network ordered UCS2. Upon release of
40 Perl 5.005 this will change to utf8 assuming current UCS2 semantics
41 for all encoding ids.
42
43 Windows (platform id = 3)
44 As per Unicode, the data is currently stored as 16-bit network
45 ordered UCS2. Upon release of Perl 5.005 this will change to utf8
46 assuming current UCS2 semantics for all encoding ids.
47
49 strings
50 An array of arrays, etc.
51
53 $t->read
54 Reads all the names into memory
55
56 $t->out($fh)
57 Writes out all the strings
58
59 $t->XML_element($context, $depth, $key, $value)
60 Outputs the string element in nice XML (which is all the table really!)
61
62 $t->XML_end($context, $tag, %attrs)
63 Store strings in the right place
64
65 is_utf8($pid, $eid)
66 Returns whether a string of a given platform and encoding is going to
67 be in UTF8
68
69 find_name($nid)
70 Hunts down a name in all the standard places and returns the string and
71 for an array context the pid, eid & lid as well
72
73 remove_name($nid)
74 Removes all strings with the given name id from the table.
75
76 set_name($nid, $str[, $lang[, @cover]])
77 Sets the given name id string to $str for all platforms and encodings
78 that this module can handle. If $lang is set, it is interpretted as a
79 language tag and if the particular language of a string is found to
80 match, then that string is changed, otherwise no change occurs.
81
82 If supplied, @cover should be a list of references to two-element
83 arrays containing pid,eid pairs that should be added to the name table
84 if not already present.
85
86 This function does not add any names to the table unless @cover is
87 supplied.
88
89 Font::TTF::Name->match_lang($pid, $lid, $lang)
90 Compares the language associated to the string of given platform and
91 language with the given language tag. If the language matches the tag
92 (i.e. is equal or more defined than the given language tag) returns
93 true. This is calculated by finding whether the associated language tag
94 starts with the given language tag.
95
96 Font::TTF::Name->get_lang($pid, $lid)
97 Returns the language tag associated with a particular platform and
98 language id
99
100 Font::TTF::Name->find_lang($pid, $lang)
101 Looks up the language name and returns a lang id if one exists
102
103 Font::TTF::Name->pe_list()
104 Returns an array of references to two-element arrays containing pid,eid
105 pairs that already exist in this name table. Useful for creating
106 @cover parameter to set_name().
107
109 ยท Unicode type strings will be stored in utf8 for all known
110 platforms, once Perl 5.6 has been released and I can find all the
111 mapping tables, etc.
112
114 Martin Hosken Martin_Hosken@sil.org. See Font::TTF::Font for copyright
115 and licensing.
116
117
118
119perl v5.16.3 2012-07-24 Font::TTF::Name(3)