Class: TTFunk::Table::Name

Inherits:
TTFunk::Table show all
Defined in:
lib/ttfunk/table/name.rb

Overview

Naming (name) table

Defined Under Namespace

Classes: NameString

Constant Summary collapse

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

Attributes inherited from TTFunk::Table

#file, #length, #offset

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TTFunk::Table

#exists?, #initialize, #raw, #tag

Constructor Details

This class inherits a constructor from TTFunk::Table

Instance Attribute Details

#compatible_fullArray<NameString> (readonly)

Compatible Full Names.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 118
118
def compatible_full
119
  @compatible_full
120
end

Copyright notice.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 54
54
def copyright
55
  @copyright
56
end

#descriptionArray<NameString> (readonly)

Descriptions.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 90
90
def description
91
  @description
92
end

#designerArray<NameString> (readonly)

Designers.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 86
86
def designer
87
  @designer
88
end

#designer_urlArray<NameString> (readonly)

Designer URLs.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 98
98
def designer_url
99
  @designer_url
100
end

#entriesArray<Hash> (readonly)

Name records.

Returns:

  • (Array<Hash>)
Source Code
lib/ttfunk/table/name.rb, line 46
46
def entries
47
  @entries
48
end

#font_familyArray<NameString> (readonly)

Font Family names.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 58
58
def font_family
59
  @font_family
60
end

#font_nameArray<NameString> (readonly)

Full font names.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 70
70
def font_name
71
  @font_name
72
end

#font_subfamilyArray<NameString> (readonly)

Font Subfamily names.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 62
62
def font_subfamily
63
  @font_subfamily
64
end

#licenseArray<NameString> (readonly)

License Descriptions.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 102
102
def license
103
  @license
104
end

#license_urlArray<NameString> (readonly)

License Info URLs.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 106
106
def license_url
107
  @license_url
108
end

#manufacturerArray<NameString> (readonly)

Manufacturer Names.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 82
82
def manufacturer
83
  @manufacturer
84
end

#preferred_familyArray<NameString> (readonly)

Typographic Family names.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 110
110
def preferred_family
111
  @preferred_family
112
end

#preferred_subfamilyArray<NameString> (readonly)

Typographic Subfamily names.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 114
114
def preferred_subfamily
115
  @preferred_subfamily
116
end

#sample_textArray<NameString> (readonly)

Sample texts.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 122
122
def sample_text
123
  @sample_text
124
end

#stringsHash{Integer => NameString} (readonly)

Name strings.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 50
50
def strings
51
  @strings
52
end

#trademarkArray<NameString> (readonly)

Trademarks.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 78
78
def trademark
79
  @trademark
80
end

#unique_subfamilyArray<NameString> (readonly)

Unique font identifiers.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 66
66
def unique_subfamily
67
  @unique_subfamily
68
end

#vendor_urlArray<NameString> (readonly)

Vendor URLs.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 94
94
def vendor_url
95
  @vendor_url
96
end

#versionArray<NameString> (readonly)

Version strings.

Returns:

Source Code
lib/ttfunk/table/name.rb, line 74
74
def version
75
  @version
76
end

Class Method Details

.encode(names, key = '') ⇒ String

Encode table.

Parameters:

Returns:

  • (String)
Source Code
lib/ttfunk/table/name.rb, line 187
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_nameString

PostScript name for the font.

Returns:

  • (String)
Source Code
lib/ttfunk/table/name.rb, line 222
222
def postscript_name
223
  return @postscript_name if @postscript_name
224
225
  font_family.first || 'unnamed'
226
end