Class: TTFunk::Table::Maxp

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

Overview

Maximum Profile (‘maxp`) table

Constant Summary collapse

DEFAULT_MAX_COMPONENT_DEPTH =

Default maximum levels of recursion.

1
MAX_V1_TABLE_LENGTH =

Size of full table version 1.

32

Instance Attribute Summary collapse

Attributes inherited from TTFunk::Table

#file, #length, #offset

Class 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

#max_component_contoursInteger (readonly)

Maximum contours in a composite glyph.

Returns:

  • (Integer)


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

def max_component_contours
  @max_component_contours
end

#max_component_depthInteger (readonly)

Maximum levels of recursion.

Returns:

  • (Integer)


77
78
79
# File 'lib/ttfunk/table/maxp.rb', line 77

def max_component_depth
  @max_component_depth
end

#max_component_elementsInteger (readonly)

Maximum number of components referenced at “top level” for any composite glyph.

Returns:

  • (Integer)


73
74
75
# File 'lib/ttfunk/table/maxp.rb', line 73

def max_component_elements
  @max_component_elements
end

#max_component_pointsInteger (readonly)

Maximum points in a composite glyph.

Returns:

  • (Integer)


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

def max_component_points
  @max_component_points
end

#max_contoursInteger (readonly)

Maximum contours in a non-composite glyph.

Returns:

  • (Integer)


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

def max_contours
  @max_contours
end

#max_function_defsInteger (readonly)

Number of FDEFs.

Returns:

  • (Integer)


55
56
57
# File 'lib/ttfunk/table/maxp.rb', line 55

def max_function_defs
  @max_function_defs
end

#max_instruction_defsInteger (readonly)

Number of IDEFs.

Returns:

  • (Integer)


59
60
61
# File 'lib/ttfunk/table/maxp.rb', line 59

def max_instruction_defs
  @max_instruction_defs
end

#max_pointsInteger (readonly)

Maximum points in a non-composite glyph.

Returns:

  • (Integer)


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

def max_points
  @max_points
end

#max_size_of_instructionsInteger (readonly)

Maximum byte count for glyph instructions.

Returns:

  • (Integer)


68
69
70
# File 'lib/ttfunk/table/maxp.rb', line 68

def max_size_of_instructions
  @max_size_of_instructions
end

#max_stack_elementsInteger (readonly)

Maximum stack depth across Font Program, CVT Program and all glyph instructions.

Returns:

  • (Integer)


64
65
66
# File 'lib/ttfunk/table/maxp.rb', line 64

def max_stack_elements
  @max_stack_elements
end

#max_storageInteger (readonly)

Number of Storage Area locations.

Returns:

  • (Integer)


51
52
53
# File 'lib/ttfunk/table/maxp.rb', line 51

def max_storage
  @max_storage
end

#max_twilight_pointsInteger (readonly)

Maximum points used in Z0.

Returns:

  • (Integer)


47
48
49
# File 'lib/ttfunk/table/maxp.rb', line 47

def max_twilight_points
  @max_twilight_points
end

#max_zonesInteger (readonly)

Maximum zones.

  • 1 if instructions do not use the twilight zone (Z0)

  • 2 if instructions do use Z0

Returns:

  • (Integer)


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

def max_zones
  @max_zones
end

#num_glyphsInteger (readonly)

The number of glyphs in the font.

Returns:

  • (Integer)


21
22
23
# File 'lib/ttfunk/table/maxp.rb', line 21

def num_glyphs
  @num_glyphs
end

#versionInteger (readonly)

Table version.

Returns:

  • (Integer)


17
18
19
# File 'lib/ttfunk/table/maxp.rb', line 17

def version
  @version
end

Class Method Details

.encode(maxp, new2old_glyph) ⇒ String

Encode table.

Parameters:

  • maxp (TTFunk::Table::Maxp)
  • new2old_glyph (Hash{Integer => Integer})

    keys are new glyph IDs, values are old glyph IDs.

Returns:

  • (String)


86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/ttfunk/table/maxp.rb', line 86

def encode(maxp, new2old_glyph)
  ''.b.tap do |table|
    num_glyphs = new2old_glyph.length
    table << [maxp.version, num_glyphs].pack('Nn')

    if maxp.version == 0x10000
      stats = stats_for(maxp, glyphs_from_ids(maxp, new2old_glyph.values))

      table << [
        stats[:max_points],
        stats[:max_contours],
        stats[:max_component_points],
        stats[:max_component_contours],
        # these all come from the fpgm and cvt tables, which
        # we don't support at the moment
        maxp.max_zones,
        maxp.max_twilight_points,
        maxp.max_storage,
        maxp.max_function_defs,
        maxp.max_instruction_defs,
        maxp.max_stack_elements,
        stats[:max_size_of_instructions],
        stats[:max_component_elements],
        stats[:max_component_depth],
      ].pack('n*')
    end
  end
end