Class: Fontisan::Tables::HheaTable
- Defined in:
- lib/fontisan/tables/hhea_table.rb
Overview
OOP representation of the ‘hhea’ (Horizontal Header) table
The hhea table contains horizontal layout metrics for the entire font, defining font-wide horizontal metrics such as ascent, descent, line gap, and the number of horizontal metrics in the hmtx table.
This class extends SfntTable to provide hhea-specific validation and convenience methods for accessing common hhea table fields.
Constant Summary collapse
- VERSION_1_0 =
Fixed value 0x00010000 for version 1.0
0x00010000
Instance Attribute Summary
Attributes inherited from SfntTable
Instance Method Summary collapse
-
#advance_width_max ⇒ Integer?
Get maximum advance width.
-
#ascent ⇒ Integer?
Get typographic ascent.
-
#caret_angle ⇒ Float?
Get caret angle in degrees.
-
#caret_offset ⇒ Integer?
Get caret offset.
-
#caret_slope_rise ⇒ Integer?
Get caret slope rise.
-
#caret_slope_run ⇒ Integer?
Get caret slope run.
-
#descent ⇒ Integer?
Get typographic descent.
-
#horizontal_caret? ⇒ Boolean
Check if caret is horizontal.
-
#italic_caret? ⇒ Boolean
Check if caret is italic.
-
#line_gap ⇒ Integer?
Get typographic line gap.
-
#line_height ⇒ Integer?
Get total line height.
-
#metric_data_format ⇒ Integer?
Get metric data format.
-
#min_left_side_bearing ⇒ Integer?
Get minimum left sidebearing.
-
#min_right_side_bearing ⇒ Integer?
Get minimum right sidebearing.
-
#number_of_h_metrics ⇒ Integer?
Get number of hmetrics.
-
#version ⇒ Float?
Get hhea table version.
-
#vertical_caret? ⇒ Boolean
Check if caret is vertical.
-
#x_max_extent ⇒ Integer?
Get maximum x extent.
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
#advance_width_max ⇒ Integer?
Get maximum advance width
Maximum advance width value in hmtx table
79 80 81 |
# File 'lib/fontisan/tables/hhea_table.rb', line 79 def advance_width_max parsed&.advance_width_max end |
#ascent ⇒ Integer?
Get typographic ascent
Distance from baseline to highest ascender (positive value)
41 42 43 |
# File 'lib/fontisan/tables/hhea_table.rb', line 41 def ascent parsed&.ascent end |
#caret_angle ⇒ Float?
Get caret angle in degrees
183 184 185 186 187 188 189 |
# File 'lib/fontisan/tables/hhea_table.rb', line 183 def caret_angle return nil unless parsed return 0.0 if caret_slope_run.zero? Math.atan2(caret_slope_rise, caret_slope_run) * (180.0 / Math::PI) end |
#caret_offset ⇒ Integer?
Get caret offset
Amount by which slanted highlight should be shifted
131 132 133 |
# File 'lib/fontisan/tables/hhea_table.rb', line 131 def caret_offset parsed&.caret_offset end |
#caret_slope_rise ⇒ Integer?
Get caret slope rise
Used to calculate slope of cursor (rise/run) For vertical text: rise = 1, run = 0
112 113 114 |
# File 'lib/fontisan/tables/hhea_table.rb', line 112 def caret_slope_rise parsed&.caret_slope_rise end |
#caret_slope_run ⇒ Integer?
Get caret slope run
Used to calculate slope of cursor (rise/run) For vertical text: run = 0
122 123 124 |
# File 'lib/fontisan/tables/hhea_table.rb', line 122 def caret_slope_run parsed&.caret_slope_run end |
#descent ⇒ Integer?
Get typographic descent
Distance from baseline to lowest descender (negative value)
50 51 52 |
# File 'lib/fontisan/tables/hhea_table.rb', line 50 def descent parsed&.descent end |
#horizontal_caret? ⇒ Boolean
Check if caret is horizontal
174 175 176 177 178 |
# File 'lib/fontisan/tables/hhea_table.rb', line 174 def horizontal_caret? return false unless parsed caret_slope_rise.zero? && caret_slope_run != 0 end |
#italic_caret? ⇒ Boolean
Check if caret is italic
165 166 167 168 169 |
# File 'lib/fontisan/tables/hhea_table.rb', line 165 def italic_caret? return false unless parsed caret_slope_rise != 0 && caret_slope_run != 0 end |
#line_gap ⇒ Integer?
Get typographic line gap
Additional space between lines (non-negative value)
59 60 61 |
# File 'lib/fontisan/tables/hhea_table.rb', line 59 def line_gap parsed&.line_gap end |
#line_height ⇒ Integer?
Get total line height
Calculated as ascent - descent + line_gap
68 69 70 71 72 |
# File 'lib/fontisan/tables/hhea_table.rb', line 68 def line_height return nil unless parsed ascent - descent + line_gap end |
#metric_data_format ⇒ Integer?
Get metric data format
Format of metric data (0 for current format)
140 141 142 |
# File 'lib/fontisan/tables/hhea_table.rb', line 140 def metric_data_format parsed&.metric_data_format end |
#min_left_side_bearing ⇒ Integer?
Get minimum left sidebearing
86 87 88 |
# File 'lib/fontisan/tables/hhea_table.rb', line 86 def min_left_side_bearing parsed&.min_left_side_bearing end |
#min_right_side_bearing ⇒ Integer?
Get minimum right sidebearing
93 94 95 |
# File 'lib/fontisan/tables/hhea_table.rb', line 93 def min_right_side_bearing parsed&.min_right_side_bearing end |
#number_of_h_metrics ⇒ Integer?
Get number of hmetrics
Number of hMetric entries in hmtx table
149 150 151 |
# File 'lib/fontisan/tables/hhea_table.rb', line 149 def number_of_h_metrics parsed&.number_of_h_metrics end |
#version ⇒ Float?
Get hhea table version
30 31 32 33 34 |
# File 'lib/fontisan/tables/hhea_table.rb', line 30 def version return nil unless parsed parsed.version end |
#vertical_caret? ⇒ Boolean
Check if caret is vertical
156 157 158 159 160 |
# File 'lib/fontisan/tables/hhea_table.rb', line 156 def vertical_caret? return false unless parsed caret_slope_rise != 0 && caret_slope_run.zero? end |
#x_max_extent ⇒ Integer?
Get maximum x extent
Maximum of lsb + (xMax - xMin) for all glyphs
102 103 104 |
# File 'lib/fontisan/tables/hhea_table.rb', line 102 def x_max_extent parsed&.x_max_extent end |