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)
Source Code
lib/ttfunk/table/maxp.rb, line 37
37
def max_component_contours
38
  @max_component_contours
39
end

#max_component_depthInteger (readonly)

Maximum levels of recursion.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 77
77
def max_component_depth
78
  @max_component_depth
79
end

#max_component_elementsInteger (readonly)

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

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 73
73
def max_component_elements
74
  @max_component_elements
75
end

#max_component_pointsInteger (readonly)

Maximum points in a composite glyph.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 33
33
def max_component_points
34
  @max_component_points
35
end

#max_contoursInteger (readonly)

Maximum contours in a non-composite glyph.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 29
29
def max_contours
30
  @max_contours
31
end

#max_function_defsInteger (readonly)

Number of FDEFs.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 55
55
def max_function_defs
56
  @max_function_defs
57
end

#max_instruction_defsInteger (readonly)

Number of IDEFs.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 59
59
def max_instruction_defs
60
  @max_instruction_defs
61
end

#max_pointsInteger (readonly)

Maximum points in a non-composite glyph.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 25
25
def max_points
26
  @max_points
27
end

#max_size_of_instructionsInteger (readonly)

Maximum byte count for glyph instructions.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 68
68
def max_size_of_instructions
69
  @max_size_of_instructions
70
end

#max_stack_elementsInteger (readonly)

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

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 64
64
def max_stack_elements
65
  @max_stack_elements
66
end

#max_storageInteger (readonly)

Number of Storage Area locations.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 51
51
def max_storage
52
  @max_storage
53
end

#max_twilight_pointsInteger (readonly)

Maximum points used in Z0.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 47
47
def max_twilight_points
48
  @max_twilight_points
49
end

#max_zonesInteger (readonly)

Maximum zones.

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

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 43
43
def max_zones
44
  @max_zones
45
end

#num_glyphsInteger (readonly)

The number of glyphs in the font.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 21
21
def num_glyphs
22
  @num_glyphs
23
end

#versionInteger (readonly)

Table version.

Returns:

  • (Integer)
Source Code
lib/ttfunk/table/maxp.rb, line 17
17
def version
18
  @version
19
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)
Source Code
lib/ttfunk/table/maxp.rb, line 86
86
def encode(maxp, new2old_glyph)
87
  ''.b.tap do |table|
88
    num_glyphs = new2old_glyph.length
89
    table << [maxp.version, num_glyphs].pack('Nn')
90
91
    if maxp.version == 0x10000
92
      stats = stats_for(maxp, glyphs_from_ids(maxp, new2old_glyph.values))
93
94
      table << [
95
        stats[:max_points],
96
        stats[:max_contours],
97
        stats[:max_component_points],
98
        stats[:max_component_contours],
99
        # these all come from the fpgm and cvt tables, which
100
        # we don't support at the moment
101
        maxp.max_zones,
102
        maxp.max_twilight_points,
103
        maxp.max_storage,
104
        maxp.max_function_defs,
105
        maxp.max_instruction_defs,
106
        maxp.max_stack_elements,
107
        stats[:max_size_of_instructions],
108
        stats[:max_component_elements],
109
        stats[:max_component_depth],
110
      ].pack('n*')
111
    end
112
  end
113
end