Class: Fontisan::Tables::Os2
- Inherits:
-
Binary::BaseRecord
- Object
- BinData::Record
- Binary::BaseRecord
- Fontisan::Tables::Os2
- Defined in:
- lib/fontisan/tables/os2.rb
Overview
Parser for the ‘OS/2’ (OS/2 and Windows Metrics) table
The OS/2 table contains OS/2 and Windows-specific metrics that are required by Windows and OS/2. This includes font metrics, character ranges, vendor information, and embedding permissions.
The table has evolved through multiple versions (0-5), with newer versions adding additional fields while maintaining backward compatibility.
Reference: OpenType specification, OS/2 table
Instance Method Summary collapse
-
#has_optical_point_size? ⇒ Boolean
Check if optical point size information is available.
-
#lower_optical_point_size ⇒ Float?
Get the lower optical point size.
- #s_cap_height ⇒ Object
- #sx_height ⇒ Object
-
#type_flags ⇒ Integer
Get the embedding type flags.
-
#ul_code_page_range1 ⇒ Object
Override conditional field accessors to return nil when not present BinData’s onlyif fields return default values even when not read, so we need to check the version before accessing them.
- #ul_code_page_range2 ⇒ Object
-
#upper_optical_point_size ⇒ Float?
Get the upper optical point size.
- #us_break_char ⇒ Object
- #us_default_char ⇒ Object
- #us_lower_optical_point_size ⇒ Object
- #us_max_context ⇒ Object
- #us_upper_optical_point_size ⇒ Object
-
#vendor_id ⇒ String
Get the vendor ID as a trimmed string.
Methods inherited from Binary::BaseRecord
Instance Method Details
#has_optical_point_size? ⇒ Boolean
Check if optical point size information is available
150 151 152 |
# File 'lib/fontisan/tables/os2.rb', line 150 def has_optical_point_size? version >= 5 end |
#lower_optical_point_size ⇒ Float?
Get the lower optical point size
158 159 160 161 162 |
# File 'lib/fontisan/tables/os2.rb', line 158 def lower_optical_point_size return nil unless has_optical_point_size? us_lower_optical_point_size / 20.0 end |
#s_cap_height ⇒ Object
95 96 97 98 99 |
# File 'lib/fontisan/tables/os2.rb', line 95 def s_cap_height return nil unless version >= 2 super end |
#sx_height ⇒ Object
89 90 91 92 93 |
# File 'lib/fontisan/tables/os2.rb', line 89 def sx_height return nil unless version >= 2 super end |
#type_flags ⇒ Integer
Get the embedding type flags
143 144 145 |
# File 'lib/fontisan/tables/os2.rb', line 143 def type_flags fs_type end |
#ul_code_page_range1 ⇒ Object
Override conditional field accessors to return nil when not present BinData’s onlyif fields return default values even when not read, so we need to check the version before accessing them
77 78 79 80 81 |
# File 'lib/fontisan/tables/os2.rb', line 77 def ul_code_page_range1 return nil unless version >= 1 super end |
#ul_code_page_range2 ⇒ Object
83 84 85 86 87 |
# File 'lib/fontisan/tables/os2.rb', line 83 def ul_code_page_range2 return nil unless version >= 1 super end |
#upper_optical_point_size ⇒ Float?
Get the upper optical point size
168 169 170 171 172 |
# File 'lib/fontisan/tables/os2.rb', line 168 def upper_optical_point_size return nil unless has_optical_point_size? us_upper_optical_point_size / 20.0 end |
#us_break_char ⇒ Object
107 108 109 110 111 |
# File 'lib/fontisan/tables/os2.rb', line 107 def us_break_char return nil unless version >= 2 super end |
#us_default_char ⇒ Object
101 102 103 104 105 |
# File 'lib/fontisan/tables/os2.rb', line 101 def us_default_char return nil unless version >= 2 super end |
#us_lower_optical_point_size ⇒ Object
119 120 121 122 123 |
# File 'lib/fontisan/tables/os2.rb', line 119 def us_lower_optical_point_size return nil unless version >= 5 super end |
#us_max_context ⇒ Object
113 114 115 116 117 |
# File 'lib/fontisan/tables/os2.rb', line 113 def us_max_context return nil unless version >= 2 super end |
#us_upper_optical_point_size ⇒ Object
125 126 127 128 129 |
# File 'lib/fontisan/tables/os2.rb', line 125 def us_upper_optical_point_size return nil unless version >= 5 super end |
#vendor_id ⇒ String
Get the vendor ID as a trimmed string
134 135 136 137 138 |
# File 'lib/fontisan/tables/os2.rb', line 134 def vendor_id return "" unless ach_vend_id ach_vend_id.gsub(/[\x00\s]+$/, "") end |