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
76 77 78 |
# File 'lib/fontisan/tables/hhea_table.rb', line 76 def advance_width_max parsed&.advance_width_max end |
#ascent ⇒ Integer?
Get typographic ascent
Distance from baseline to highest ascender (positive value)
38 39 40 |
# File 'lib/fontisan/tables/hhea_table.rb', line 38 def ascent parsed&.ascent end |
#caret_angle ⇒ Float?
Get caret angle in degrees
180 181 182 183 184 185 186 |
# File 'lib/fontisan/tables/hhea_table.rb', line 180 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
128 129 130 |
# File 'lib/fontisan/tables/hhea_table.rb', line 128 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
109 110 111 |
# File 'lib/fontisan/tables/hhea_table.rb', line 109 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
119 120 121 |
# File 'lib/fontisan/tables/hhea_table.rb', line 119 def caret_slope_run parsed&.caret_slope_run end |
#descent ⇒ Integer?
Get typographic descent
Distance from baseline to lowest descender (negative value)
47 48 49 |
# File 'lib/fontisan/tables/hhea_table.rb', line 47 def descent parsed&.descent end |
#horizontal_caret? ⇒ Boolean
Check if caret is horizontal
171 172 173 174 175 |
# File 'lib/fontisan/tables/hhea_table.rb', line 171 def horizontal_caret? return false unless parsed caret_slope_rise.zero? && caret_slope_run != 0 end |
#italic_caret? ⇒ Boolean
Check if caret is italic
162 163 164 165 166 |
# File 'lib/fontisan/tables/hhea_table.rb', line 162 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)
56 57 58 |
# File 'lib/fontisan/tables/hhea_table.rb', line 56 def line_gap parsed&.line_gap end |
#line_height ⇒ Integer?
Get total line height
Calculated as ascent - descent + line_gap
65 66 67 68 69 |
# File 'lib/fontisan/tables/hhea_table.rb', line 65 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)
137 138 139 |
# File 'lib/fontisan/tables/hhea_table.rb', line 137 def metric_data_format parsed&.metric_data_format end |
#min_left_side_bearing ⇒ Integer?
Get minimum left sidebearing
83 84 85 |
# File 'lib/fontisan/tables/hhea_table.rb', line 83 def min_left_side_bearing parsed&.min_left_side_bearing end |
#min_right_side_bearing ⇒ Integer?
Get minimum right sidebearing
90 91 92 |
# File 'lib/fontisan/tables/hhea_table.rb', line 90 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
146 147 148 |
# File 'lib/fontisan/tables/hhea_table.rb', line 146 def number_of_h_metrics parsed&.number_of_h_metrics end |
#version ⇒ Float?
Get hhea table version
27 28 29 30 31 |
# File 'lib/fontisan/tables/hhea_table.rb', line 27 def version return nil unless parsed parsed.version end |
#vertical_caret? ⇒ Boolean
Check if caret is vertical
153 154 155 156 157 |
# File 'lib/fontisan/tables/hhea_table.rb', line 153 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
99 100 101 |
# File 'lib/fontisan/tables/hhea_table.rb', line 99 def x_max_extent parsed&.x_max_extent end |