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)
54 55 56 57 58 |
# File 'lib/fontisan/tables/maxp_table.rb', line 54 def cff? return false unless parsed parsed.cff? end |
#has_composite_glyphs? ⇒ Boolean
Check if font uses composite glyphs
180 181 182 183 |
# File 'lib/fontisan/tables/maxp_table.rb', line 180 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
188 189 190 |
# File 'lib/fontisan/tables/maxp_table.rb', line 188 def has_twilight_zone? max_zones == 2 end |
#max_component_depth ⇒ Integer?
Get maximum levels of recursion in composite glyphs (version 1.0)
171 172 173 174 175 |
# File 'lib/fontisan/tables/maxp_table.rb', line 171 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)
162 163 164 165 166 |
# File 'lib/fontisan/tables/maxp_table.rb', line 162 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)
90 91 92 93 94 |
# File 'lib/fontisan/tables/maxp_table.rb', line 90 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)
81 82 83 84 85 |
# File 'lib/fontisan/tables/maxp_table.rb', line 81 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)
72 73 74 75 76 |
# File 'lib/fontisan/tables/maxp_table.rb', line 72 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)
126 127 128 129 130 |
# File 'lib/fontisan/tables/maxp_table.rb', line 126 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)
135 136 137 138 139 |
# File 'lib/fontisan/tables/maxp_table.rb', line 135 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)
63 64 65 66 67 |
# File 'lib/fontisan/tables/maxp_table.rb', line 63 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)
153 154 155 156 157 |
# File 'lib/fontisan/tables/maxp_table.rb', line 153 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)
144 145 146 147 148 |
# File 'lib/fontisan/tables/maxp_table.rb', line 144 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)
117 118 119 120 121 |
# File 'lib/fontisan/tables/maxp_table.rb', line 117 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)
108 109 110 111 112 |
# File 'lib/fontisan/tables/maxp_table.rb', line 108 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)
99 100 101 102 103 |
# File 'lib/fontisan/tables/maxp_table.rb', line 99 def max_zones return nil unless parsed&.version_1_0? parsed.max_zones end |
#num_glyphs ⇒ Integer?
Get number of glyphs
38 39 40 |
# File 'lib/fontisan/tables/maxp_table.rb', line 38 def num_glyphs parsed&.num_glyphs end |
#statistics ⇒ Hash
Get complexity statistics
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/fontisan/tables/maxp_table.rb', line 195 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)
45 46 47 48 49 |
# File 'lib/fontisan/tables/maxp_table.rb', line 45 def truetype? return false unless parsed parsed.truetype? end |
#version ⇒ Float?
Get maxp table version
29 30 31 32 33 |
# File 'lib/fontisan/tables/maxp_table.rb', line 29 def version return nil unless parsed parsed.version end |