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:



118
119
120
# File 'lib/ttfunk/table/name.rb', line 118

def compatible_full
  @compatible_full
end

Copyright notice.

Returns:



54
55
56
# File 'lib/ttfunk/table/name.rb', line 54

def copyright
  @copyright
end

#descriptionArray<NameString> (readonly)

Descriptions.

Returns:



90
91
92
# File 'lib/ttfunk/table/name.rb', line 90

def description
  @description
end

#designerArray<NameString> (readonly)

Designers.

Returns:



86
87
88
# File 'lib/ttfunk/table/name.rb', line 86

def designer
  @designer
end

#designer_urlArray<NameString> (readonly)

Designer URLs.

Returns:



98
99
100
# File 'lib/ttfunk/table/name.rb', line 98

def designer_url
  @designer_url
end

#entriesArray<Hash> (readonly)

Name records.

Returns:

  • (Array<Hash>)


46
47
48
# File 'lib/ttfunk/table/name.rb', line 46

def entries
  @entries
end

#font_familyArray<NameString> (readonly)

Font Family names.

Returns:



58
59
60
# File 'lib/ttfunk/table/name.rb', line 58

def font_family
  @font_family
end

#font_nameArray<NameString> (readonly)

Full font names.

Returns:



70
71
72
# File 'lib/ttfunk/table/name.rb', line 70

def font_name
  @font_name
end

#font_subfamilyArray<NameString> (readonly)

Font Subfamily names.

Returns:



62
63
64
# File 'lib/ttfunk/table/name.rb', line 62

def font_subfamily
  @font_subfamily
end

#licenseArray<NameString> (readonly)

License Descriptions.

Returns:



102
103
104
# File 'lib/ttfunk/table/name.rb', line 102

def license
  @license
end

#license_urlArray<NameString> (readonly)

License Info URLs.

Returns:



106
107
108
# File 'lib/ttfunk/table/name.rb', line 106

def license_url
  @license_url
end

#manufacturerArray<NameString> (readonly)

Manufacturer Names.

Returns:



82
83
84
# File 'lib/ttfunk/table/name.rb', line 82

def manufacturer
  @manufacturer
end

#preferred_familyArray<NameString> (readonly)

Typographic Family names.

Returns:



110
111
112
# File 'lib/ttfunk/table/name.rb', line 110

def preferred_family
  @preferred_family
end

#preferred_subfamilyArray<NameString> (readonly)

Typographic Subfamily names.

Returns:



114
115
116
# File 'lib/ttfunk/table/name.rb', line 114

def preferred_subfamily
  @preferred_subfamily
end

#sample_textArray<NameString> (readonly)

Sample texts.

Returns:



122
123
124
# File 'lib/ttfunk/table/name.rb', line 122

def sample_text
  @sample_text
end

#stringsHash{Integer => NameString} (readonly)

Name strings.

Returns:



50
51
52
# File 'lib/ttfunk/table/name.rb', line 50

def strings
  @strings
end

#trademarkArray<NameString> (readonly)

Trademarks.

Returns:



78
79
80
# File 'lib/ttfunk/table/name.rb', line 78

def trademark
  @trademark
end

#unique_subfamilyArray<NameString> (readonly)

Unique font identifiers.

Returns:



66
67
68
# File 'lib/ttfunk/table/name.rb', line 66

def unique_subfamily
  @unique_subfamily
end

#vendor_urlArray<NameString> (readonly)

Vendor URLs.

Returns:



94
95
96
# File 'lib/ttfunk/table/name.rb', line 94

def vendor_url
  @vendor_url
end

#versionArray<NameString> (readonly)

Version strings.

Returns:



74
75
76
# File 'lib/ttfunk/table/name.rb', line 74

def version
  @version
end

Class Method Details

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

Encode table.

Parameters:

Returns:

  • (String)


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_nameString

PostScript name for the font.

Returns:

  • (String)


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