Class: TTFunk::Table::Name
- Inherits:
-
TTFunk::Table
- Object
- TTFunk::Table
- TTFunk::Table::Name
- Defined in:
- lib/ttfunk/table/name.rb
Overview
Naming (name
) table
Defined Under Namespace
Classes: NameString
Constant Summary collapse
- COPYRIGHT_NAME_ID =
Copyright notice ID.
0
- FONT_FAMILY_NAME_ID =
Font Family name ID.
1
- FONT_SUBFAMILY_NAME_ID =
Font Subfamily name ID.
2
- UNIQUE_SUBFAMILY_NAME_ID =
Unique font identifier ID.
3
- FONT_NAME_NAME_ID =
Full font name that reflects all family and relevant subfamily descriptors ID.
4
- VERSION_NAME_ID =
Version string ID.
5
- POSTSCRIPT_NAME_NAME_ID =
PostScript name for the font ID.
6
- TRADEMARK_NAME_ID =
Trademark ID.
7
- MANUFACTURER_NAME_ID =
Manufacturer Name ID.
8
- DESIGNER_NAME_ID =
Designer ID.
9
- DESCRIPTION_NAME_ID =
Description ID.
10
- VENDOR_URL_NAME_ID =
Vendor URL ID.
11
- DESIGNER_URL_NAME_ID =
Designer URL ID.
12
- LICENSE_NAME_ID =
License Description ID.
13
- LICENSE_URL_NAME_ID =
License Info URL ID.
14
- PREFERRED_FAMILY_NAME_ID =
Typographic Family name ID.
16
- PREFERRED_SUBFAMILY_NAME_ID =
Typographic Subfamily name ID.
17
- COMPATIBLE_FULL_NAME_ID =
Compatible Full ID.
18
- SAMPLE_TEXT_NAME_ID =
Sample text ID.
19
Instance Attribute Summary collapse
-
#compatible_full ⇒ Array<NameString>
readonly
Compatible Full Names.
-
#copyright ⇒ Array<NameString>
readonly
Copyright notice.
-
#description ⇒ Array<NameString>
readonly
Descriptions.
-
#designer ⇒ Array<NameString>
readonly
Designers.
-
#designer_url ⇒ Array<NameString>
readonly
Designer URLs.
-
#entries ⇒ Array<Hash>
readonly
Name records.
-
#font_family ⇒ Array<NameString>
readonly
Font Family names.
-
#font_name ⇒ Array<NameString>
readonly
Full font names.
-
#font_subfamily ⇒ Array<NameString>
readonly
Font Subfamily names.
-
#license ⇒ Array<NameString>
readonly
License Descriptions.
-
#license_url ⇒ Array<NameString>
readonly
License Info URLs.
-
#manufacturer ⇒ Array<NameString>
readonly
Manufacturer Names.
-
#preferred_family ⇒ Array<NameString>
readonly
Typographic Family names.
-
#preferred_subfamily ⇒ Array<NameString>
readonly
Typographic Subfamily names.
-
#sample_text ⇒ Array<NameString>
readonly
Sample texts.
-
#strings ⇒ Hash{Integer => NameString}
readonly
Name strings.
-
#trademark ⇒ Array<NameString>
readonly
Trademarks.
-
#unique_subfamily ⇒ Array<NameString>
readonly
Unique font identifiers.
-
#vendor_url ⇒ Array<NameString>
readonly
Vendor URLs.
-
#version ⇒ Array<NameString>
readonly
Version strings.
Attributes inherited from TTFunk::Table
Class Method Summary collapse
-
.encode(names, key = '') ⇒ String
Encode table.
Instance Method Summary collapse
-
#postscript_name ⇒ String
PostScript name for the font.
Methods inherited from TTFunk::Table
#exists?, #initialize, #raw, #tag
Constructor Details
This class inherits a constructor from TTFunk::Table
Instance Attribute Details
#compatible_full ⇒ Array<NameString> (readonly)
Compatible Full Names.
Source Code
118 | def compatible_full |
119 | @compatible_full
|
120 | end
|
#copyright ⇒ Array<NameString> (readonly)
Copyright notice.
Source Code
54 | def copyright |
55 | @copyright
|
56 | end
|
#description ⇒ Array<NameString> (readonly)
Descriptions.
Source Code
90 | def description |
91 | @description
|
92 | end
|
#designer ⇒ Array<NameString> (readonly)
Designers.
Source Code
86 | def designer |
87 | @designer
|
88 | end
|
#designer_url ⇒ Array<NameString> (readonly)
Designer URLs.
Source Code
98 | def designer_url |
99 | @designer_url
|
100 | end
|
#entries ⇒ Array<Hash> (readonly)
Name records.
Source Code
46 | def entries |
47 | @entries
|
48 | end
|
#font_family ⇒ Array<NameString> (readonly)
Font Family names.
Source Code
58 | def font_family |
59 | @font_family
|
60 | end
|
#font_name ⇒ Array<NameString> (readonly)
Full font names.
Source Code
70 | def font_name |
71 | @font_name
|
72 | end
|
#font_subfamily ⇒ Array<NameString> (readonly)
Font Subfamily names.
Source Code
62 | def font_subfamily |
63 | @font_subfamily
|
64 | end
|
#license ⇒ Array<NameString> (readonly)
License Descriptions.
Source Code
102 | def license |
103 | @license
|
104 | end
|
#license_url ⇒ Array<NameString> (readonly)
License Info URLs.
Source Code
106 | def license_url |
107 | @license_url
|
108 | end
|
#manufacturer ⇒ Array<NameString> (readonly)
Manufacturer Names.
Source Code
82 | def manufacturer |
83 | @manufacturer
|
84 | end
|
#preferred_family ⇒ Array<NameString> (readonly)
Typographic Family names.
Source Code
110 | def preferred_family |
111 | @preferred_family
|
112 | end
|
#preferred_subfamily ⇒ Array<NameString> (readonly)
Typographic Subfamily names.
Source Code
114 | def preferred_subfamily |
115 | @preferred_subfamily
|
116 | end
|
#sample_text ⇒ Array<NameString> (readonly)
Sample texts.
Source Code
122 | def sample_text |
123 | @sample_text
|
124 | end
|
#strings ⇒ Hash{Integer => NameString} (readonly)
Name strings.
Source Code
50 | def strings |
51 | @strings
|
52 | end
|
#trademark ⇒ Array<NameString> (readonly)
Trademarks.
Source Code
78 | def trademark |
79 | @trademark
|
80 | end
|
#unique_subfamily ⇒ Array<NameString> (readonly)
Unique font identifiers.
Source Code
66 | def unique_subfamily |
67 | @unique_subfamily
|
68 | end
|
#vendor_url ⇒ Array<NameString> (readonly)
Vendor URLs.
Source Code
94 | def vendor_url |
95 | @vendor_url
|
96 | end
|
#version ⇒ Array<NameString> (readonly)
Version strings.
Source Code
74 | def version |
75 | @version
|
76 | end
|
Class Method Details
.encode(names, key = '') ⇒ String
Encode table.
Source Code
187 | def self.encode(names, key = '') |
188 | tag = Digest::SHA1.hexdigest(key)[0, 6] |
189 | |
190 | postscript_name = NameString.new("#{tag}+#{names.postscript_name}", 1, 0, 0) |
191 | |
192 | strings = names.strings.dup |
193 | strings[6] = [postscript_name] |
194 | str_count = strings.reduce(0) { |sum, (_, list)| sum + list.length } |
195 | |
196 | table = [0, str_count, 6 + (12 * str_count)].pack('n*') |
197 | strtable = +'' |
198 | |
199 | items = [] |
200 | strings.each do |id, list| |
201 | list.each do |string| |
202 | items << [id, string] |
203 | end
|
204 | end
|
205 | items = |
206 | items.sort_by { |id, string| |
207 | [string.platform_id, string.encoding_id, string.language_id, id] |
208 | }
|
209 | items.each do |id, string| |
210 | table << [ |
211 | string.platform_id, string.encoding_id, string.language_id, id, |
212 | string.length, strtable.length, |
213 | ].pack('n*') |
214 | strtable << string |
215 | end
|
216 | |
217 | table << strtable |
218 | end
|
Instance Method Details
#postscript_name ⇒ String
PostScript name for the font.
Source Code
222 | def postscript_name |
223 | return @postscript_name if @postscript_name |
224 | |
225 | font_family.first || 'unnamed' |
226 | end
|