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.
118 119 120 |
# File 'lib/ttfunk/table/name.rb', line 118 def compatible_full @compatible_full end |
#copyright ⇒ Array<NameString> (readonly)
Copyright notice.
54 55 56 |
# File 'lib/ttfunk/table/name.rb', line 54 def copyright @copyright end |
#description ⇒ Array<NameString> (readonly)
Descriptions.
90 91 92 |
# File 'lib/ttfunk/table/name.rb', line 90 def description @description end |
#designer ⇒ Array<NameString> (readonly)
Designers.
86 87 88 |
# File 'lib/ttfunk/table/name.rb', line 86 def designer @designer end |
#designer_url ⇒ Array<NameString> (readonly)
Designer URLs.
98 99 100 |
# File 'lib/ttfunk/table/name.rb', line 98 def designer_url @designer_url end |
#entries ⇒ Array<Hash> (readonly)
Name records.
46 47 48 |
# File 'lib/ttfunk/table/name.rb', line 46 def entries @entries end |
#font_family ⇒ Array<NameString> (readonly)
Font Family names.
58 59 60 |
# File 'lib/ttfunk/table/name.rb', line 58 def font_family @font_family end |
#font_name ⇒ Array<NameString> (readonly)
Full font names.
70 71 72 |
# File 'lib/ttfunk/table/name.rb', line 70 def font_name @font_name end |
#font_subfamily ⇒ Array<NameString> (readonly)
Font Subfamily names.
62 63 64 |
# File 'lib/ttfunk/table/name.rb', line 62 def font_subfamily @font_subfamily end |
#license ⇒ Array<NameString> (readonly)
License Descriptions.
102 103 104 |
# File 'lib/ttfunk/table/name.rb', line 102 def license @license end |
#license_url ⇒ Array<NameString> (readonly)
License Info URLs.
106 107 108 |
# File 'lib/ttfunk/table/name.rb', line 106 def license_url @license_url end |
#manufacturer ⇒ Array<NameString> (readonly)
Manufacturer Names.
82 83 84 |
# File 'lib/ttfunk/table/name.rb', line 82 def manufacturer @manufacturer end |
#preferred_family ⇒ Array<NameString> (readonly)
Typographic Family names.
110 111 112 |
# File 'lib/ttfunk/table/name.rb', line 110 def preferred_family @preferred_family end |
#preferred_subfamily ⇒ Array<NameString> (readonly)
Typographic Subfamily names.
114 115 116 |
# File 'lib/ttfunk/table/name.rb', line 114 def preferred_subfamily @preferred_subfamily end |
#sample_text ⇒ Array<NameString> (readonly)
Sample texts.
122 123 124 |
# File 'lib/ttfunk/table/name.rb', line 122 def sample_text @sample_text end |
#strings ⇒ Hash{Integer => NameString} (readonly)
Name strings.
50 51 52 |
# File 'lib/ttfunk/table/name.rb', line 50 def strings @strings end |
#trademark ⇒ Array<NameString> (readonly)
Trademarks.
78 79 80 |
# File 'lib/ttfunk/table/name.rb', line 78 def trademark @trademark end |
#unique_subfamily ⇒ Array<NameString> (readonly)
Unique font identifiers.
66 67 68 |
# File 'lib/ttfunk/table/name.rb', line 66 def unique_subfamily @unique_subfamily end |
#vendor_url ⇒ Array<NameString> (readonly)
Vendor URLs.
94 95 96 |
# File 'lib/ttfunk/table/name.rb', line 94 def vendor_url @vendor_url end |
#version ⇒ Array<NameString> (readonly)
Version strings.
74 75 76 |
# File 'lib/ttfunk/table/name.rb', line 74 def version @version end |
Class Method Details
.encode(names, key = '') ⇒ String
Encode table.
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/ttfunk/table/name.rb', line 187 def self.encode(names, key = '') tag = Digest::SHA1.hexdigest(key)[0, 6] postscript_name = NameString.new("#{tag}+#{names.postscript_name}", 1, 0, 0) strings = names.strings.dup strings[6] = [postscript_name] str_count = strings.reduce(0) { |sum, (_, list)| sum + list.length } table = [0, str_count, 6 + (12 * str_count)].pack('n*') strtable = +'' items = [] strings.each do |id, list| list.each do |string| items << [id, string] end end items = items.sort_by { |id, string| [string.platform_id, string.encoding_id, string.language_id, id] } items.each do |id, string| table << [ string.platform_id, string.encoding_id, string.language_id, id, string.length, strtable.length, ].pack('n*') strtable << string end table << strtable end |
Instance Method Details
#postscript_name ⇒ String
PostScript name for the font.
222 223 224 225 226 |
# File 'lib/ttfunk/table/name.rb', line 222 def postscript_name return @postscript_name if @postscript_name font_family.first || 'unnamed' end |