Class: Fontisan::Tables::MaxpTable
- Defined in:
- lib/fontisan/tables/maxp_table.rb
Overview
OOP representation of the ‘maxp’ (Maximum Profile) table
The maxp table contains memory and complexity limits for the font, providing the number of glyphs and various maximum values needed for font rendering and processing.
This class extends SfntTable to provide maxp-specific validation and convenience methods for accessing font complexity metrics.
Constant Summary collapse
- VERSION_0_5 =
Version 0.5 constant (CFF fonts)
0x00005000- VERSION_1_0 =
Version 1.0 constant (TrueType fonts)
0x00010000
Instance Attribute Summary
Attributes inherited from SfntTable
Instance Method Summary collapse
-
#cff? ⇒ Boolean
Check if this is a CFF font (version 0.5).
-
#has_composite_glyphs? ⇒ Boolean
Check if font uses composite glyphs.
-
#has_twilight_zone? ⇒ Boolean
Check if font uses twilight zone.
-
#max_component_depth ⇒ Integer?
Get maximum levels of recursion in composite glyphs (version 1.0).
-
#max_component_elements ⇒ Integer?
Get maximum component elements in composite glyph (version 1.0).
-
#max_composite_contours ⇒ Integer?
Get maximum contours in a composite glyph (version 1.0).
-
#max_composite_points ⇒ Integer?
Get maximum points in a composite glyph (version 1.0).
-
#max_contours ⇒ Integer?
Get maximum contours in a non-composite glyph (version 1.0).
-
#max_function_defs ⇒ Integer?
Get maximum function definitions (version 1.0).
-
#max_instruction_defs ⇒ Integer?
Get maximum instruction definitions (version 1.0).
-
#max_points ⇒ Integer?
Get maximum points in a non-composite glyph (version 1.0).
-
#max_size_of_instructions ⇒ Integer?
Get maximum byte count for glyph instructions (version 1.0).
-
#max_stack_elements ⇒ Integer?
Get maximum stack depth (version 1.0).
-
#max_storage ⇒ Integer?
Get maximum storage area locations (version 1.0).
-
#max_twilight_points ⇒ Integer?
Get maximum twilight zone points (version 1.0).
-
#max_zones ⇒ Integer?
Get maximum zones (version 1.0).
-
#num_glyphs ⇒ Integer?
Get number of glyphs.
-
#statistics ⇒ Hash
Get complexity statistics.
-
#truetype? ⇒ Boolean
Check if this is a TrueType font (version 1.0).
-
#version ⇒ Float?
Get maxp table version.
Methods inherited from SfntTable
#available?, #calculate_checksum, #checksum, #data_loaded?, #human_name, #initialize, #inspect, #length, #load_data!, #offset, #parse, #parsed?, #required?, #tag, #to_s, #validate!
Constructor Details
This class inherits a constructor from Fontisan::SfntTable
Instance Method Details
#cff? ⇒ Boolean
Check if this is a CFF font (version 0.5)
57 58 59 60 61 |
# File 'lib/fontisan/tables/maxp_table.rb', line 57 def cff? return false unless parsed parsed.cff? end |
#has_composite_glyphs? ⇒ Boolean
Check if font uses composite glyphs
183 184 185 186 |
# File 'lib/fontisan/tables/maxp_table.rb', line 183 def has_composite_glyphs? max_comp = max_component_elements !max_comp.nil? && max_comp.positive? end |
#has_twilight_zone? ⇒ Boolean
Check if font uses twilight zone
191 192 193 |
# File 'lib/fontisan/tables/maxp_table.rb', line 191 def has_twilight_zone? max_zones == 2 end |
#max_component_depth ⇒ Integer?
Get maximum levels of recursion in composite glyphs (version 1.0)
174 175 176 177 178 |
# File 'lib/fontisan/tables/maxp_table.rb', line 174 def max_component_depth return nil unless parsed&.version_1_0? parsed.max_component_depth end |
#max_component_elements ⇒ Integer?
Get maximum component elements in composite glyph (version 1.0)
165 166 167 168 169 |
# File 'lib/fontisan/tables/maxp_table.rb', line 165 def max_component_elements return nil unless parsed&.version_1_0? parsed.max_component_elements end |
#max_composite_contours ⇒ Integer?
Get maximum contours in a composite glyph (version 1.0)
93 94 95 96 97 |
# File 'lib/fontisan/tables/maxp_table.rb', line 93 def max_composite_contours return nil unless parsed&.version_1_0? parsed.max_composite_contours end |
#max_composite_points ⇒ Integer?
Get maximum points in a composite glyph (version 1.0)
84 85 86 87 88 |
# File 'lib/fontisan/tables/maxp_table.rb', line 84 def max_composite_points return nil unless parsed&.version_1_0? parsed.max_composite_points end |
#max_contours ⇒ Integer?
Get maximum contours in a non-composite glyph (version 1.0)
75 76 77 78 79 |
# File 'lib/fontisan/tables/maxp_table.rb', line 75 def max_contours return nil unless parsed&.version_1_0? parsed.max_contours end |
#max_function_defs ⇒ Integer?
Get maximum function definitions (version 1.0)
129 130 131 132 133 |
# File 'lib/fontisan/tables/maxp_table.rb', line 129 def max_function_defs return nil unless parsed&.version_1_0? parsed.max_function_defs end |
#max_instruction_defs ⇒ Integer?
Get maximum instruction definitions (version 1.0)
138 139 140 141 142 |
# File 'lib/fontisan/tables/maxp_table.rb', line 138 def max_instruction_defs return nil unless parsed&.version_1_0? parsed.max_instruction_defs end |
#max_points ⇒ Integer?
Get maximum points in a non-composite glyph (version 1.0)
66 67 68 69 70 |
# File 'lib/fontisan/tables/maxp_table.rb', line 66 def max_points return nil unless parsed&.version_1_0? parsed.max_points end |
#max_size_of_instructions ⇒ Integer?
Get maximum byte count for glyph instructions (version 1.0)
156 157 158 159 160 |
# File 'lib/fontisan/tables/maxp_table.rb', line 156 def max_size_of_instructions return nil unless parsed&.version_1_0? parsed.max_size_of_instructions end |
#max_stack_elements ⇒ Integer?
Get maximum stack depth (version 1.0)
147 148 149 150 151 |
# File 'lib/fontisan/tables/maxp_table.rb', line 147 def max_stack_elements return nil unless parsed&.version_1_0? parsed.max_stack_elements end |
#max_storage ⇒ Integer?
Get maximum storage area locations (version 1.0)
120 121 122 123 124 |
# File 'lib/fontisan/tables/maxp_table.rb', line 120 def max_storage return nil unless parsed&.version_1_0? parsed.max_storage end |
#max_twilight_points ⇒ Integer?
Get maximum twilight zone points (version 1.0)
111 112 113 114 115 |
# File 'lib/fontisan/tables/maxp_table.rb', line 111 def max_twilight_points return nil unless parsed&.version_1_0? parsed.max_twilight_points end |
#max_zones ⇒ Integer?
Get maximum zones (version 1.0)
102 103 104 105 106 |
# File 'lib/fontisan/tables/maxp_table.rb', line 102 def max_zones return nil unless parsed&.version_1_0? parsed.max_zones end |
#num_glyphs ⇒ Integer?
Get number of glyphs
41 42 43 |
# File 'lib/fontisan/tables/maxp_table.rb', line 41 def num_glyphs parsed&.num_glyphs end |
#statistics ⇒ Hash
Get complexity statistics
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/fontisan/tables/maxp_table.rb', line 198 def statistics stats = { num_glyphs: num_glyphs, version: version, truetype: truetype?, cff: cff?, } if truetype? stats[:max_points] = max_points stats[:max_contours] = max_contours stats[:max_composite_points] = max_composite_points stats[:max_composite_contours] = max_composite_contours stats[:max_component_elements] = max_component_elements stats[:max_component_depth] = max_component_depth stats[:has_composite_glyphs] = has_composite_glyphs? stats[:has_twilight_zone] = has_twilight_zone? end stats end |
#truetype? ⇒ Boolean
Check if this is a TrueType font (version 1.0)
48 49 50 51 52 |
# File 'lib/fontisan/tables/maxp_table.rb', line 48 def truetype? return false unless parsed parsed.truetype? end |
#version ⇒ Float?
Get maxp table version
32 33 34 35 36 |
# File 'lib/fontisan/tables/maxp_table.rb', line 32 def version return nil unless parsed parsed.version end |