Class: TTFunk::Table::Name

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

Defined Under Namespace

Classes: String

Constant Summary collapse

@@subset_tag =
"AAAAAA"

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_fullObject (readonly)

Returns the value of attribute compatible_full.



43
44
45
# File 'lib/ttfunk/table/name.rb', line 43

def compatible_full
  @compatible_full
end

Returns the value of attribute copyright.



27
28
29
# File 'lib/ttfunk/table/name.rb', line 27

def copyright
  @copyright
end

#descriptionObject (readonly)

Returns the value of attribute description.



36
37
38
# File 'lib/ttfunk/table/name.rb', line 36

def description
  @description
end

#designerObject (readonly)

Returns the value of attribute designer.



35
36
37
# File 'lib/ttfunk/table/name.rb', line 35

def designer
  @designer
end

#designer_urlObject (readonly)

Returns the value of attribute designer_url.



38
39
40
# File 'lib/ttfunk/table/name.rb', line 38

def designer_url
  @designer_url
end

#font_familyObject (readonly)

Returns the value of attribute font_family.



28
29
30
# File 'lib/ttfunk/table/name.rb', line 28

def font_family
  @font_family
end

#font_nameObject (readonly)

Returns the value of attribute font_name.



31
32
33
# File 'lib/ttfunk/table/name.rb', line 31

def font_name
  @font_name
end

#font_subfamilyObject (readonly)

Returns the value of attribute font_subfamily.



29
30
31
# File 'lib/ttfunk/table/name.rb', line 29

def font_subfamily
  @font_subfamily
end

#licenseObject (readonly)

Returns the value of attribute license.



39
40
41
# File 'lib/ttfunk/table/name.rb', line 39

def license
  @license
end

#license_urlObject (readonly)

Returns the value of attribute license_url.



40
41
42
# File 'lib/ttfunk/table/name.rb', line 40

def license_url
  @license_url
end

#manufacturerObject (readonly)

Returns the value of attribute manufacturer.



34
35
36
# File 'lib/ttfunk/table/name.rb', line 34

def manufacturer
  @manufacturer
end

#preferred_familyObject (readonly)

Returns the value of attribute preferred_family.



41
42
43
# File 'lib/ttfunk/table/name.rb', line 41

def preferred_family
  @preferred_family
end

#preferred_subfamilyObject (readonly)

Returns the value of attribute preferred_subfamily.



42
43
44
# File 'lib/ttfunk/table/name.rb', line 42

def preferred_subfamily
  @preferred_subfamily
end

#sample_textObject (readonly)

Returns the value of attribute sample_text.



44
45
46
# File 'lib/ttfunk/table/name.rb', line 44

def sample_text
  @sample_text
end

#stringsObject (readonly)

Returns the value of attribute strings.



25
26
27
# File 'lib/ttfunk/table/name.rb', line 25

def strings
  @strings
end

#trademarkObject (readonly)

Returns the value of attribute trademark.



33
34
35
# File 'lib/ttfunk/table/name.rb', line 33

def trademark
  @trademark
end

#unique_subfamilyObject (readonly)

Returns the value of attribute unique_subfamily.



30
31
32
# File 'lib/ttfunk/table/name.rb', line 30

def unique_subfamily
  @unique_subfamily
end

#vendor_urlObject (readonly)

Returns the value of attribute vendor_url.



37
38
39
# File 'lib/ttfunk/table/name.rb', line 37

def vendor_url
  @vendor_url
end

#versionObject (readonly)

Returns the value of attribute version.



32
33
34
# File 'lib/ttfunk/table/name.rb', line 32

def version
  @version
end

Class Method Details

.encode(names) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ttfunk/table/name.rb', line 48

def self.encode(names)
  tag = @@subset_tag.dup
  @@subset_tag.succ!

  postscript_name = Name::String.new("#{tag}+#{names.postscript_name}", 1, 0, 0)

  strings = names.strings.dup
  strings[6] = [postscript_name]
  str_count = strings.inject(0) { |sum, (_, list)| sum + list.length }

  table = [0, str_count, 6 + 12 * str_count].pack("n*")
  strtable = ""

  strings.each do |id, list|
    list.each do |string|
      table << [string.platform_id, string.encoding_id, string.language_id, id, string.length, strtable.length].pack("n*")
      strtable << string
    end
  end

  table << strtable
end

Instance Method Details

#postscript_nameObject



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

def postscript_name
  return @postscript_name if @postscript_name
  font_family.first || "unnamed"
end