Class: Fontisan::Tables::Post
- Inherits:
-
Binary::BaseRecord
- Object
- BinData::Record
- Binary::BaseRecord
- Fontisan::Tables::Post
- Defined in:
- lib/fontisan/tables/post.rb
Overview
Parser for the 'post' (PostScript) table
The post table contains PostScript information, primarily glyph names. Different versions exist (1.0, 2.0, 2.5, 3.0, 4.0) with varying glyph name storage strategies.
Reference: OpenType specification, post table
Constant Summary collapse
- STANDARD_NAMES =
Standard Mac glyph names for version 1.0 (258 glyphs) rubocop:disable Metrics/CollectionLiteralLength
%w[ .notdef .null nonmarkingreturn space exclam quotedbl numbersign dollar percent ampersand quotesingle parenleft parenright asterisk plus comma hyphen period slash zero one two three four five six seven eight nine colon semicolon less equal greater question at A B C D E F G H I J K L M N O P Q R S T U V W X Y Z bracketleft backslash bracketright asciicircum underscore grave a b c d e f g h i j k l m n o p q r s t u v w x y z braceleft bar braceright asciitilde Adieresis Aring Ccedilla Eacute Ntilde Odieresis Udieresis aacute agrave acircumflex adieresis atilde aring ccedilla eacute egrave ecircumflex edieresis iacute igrave icircumflex idieresis ntilde oacute ograve ocircumflex odieresis otilde uacute ugrave ucircumflex udieresis dagger degree cent sterling section bullet paragraph germandbls registered copyright trademark acute dieresis notequal AE Oslash infinity plusminus lessequal greaterequal yen mu partialdiff summation product pi integral ordfeminine ordmasculine Omega ae oslash questiondown exclamdown logicalnot radical florin approxequal Delta guillemotleft guillemotright ellipsis nonbreakingspace Agrave Atilde Otilde OE oe endash emdash quotedblleft quotedblright quoteleft quoteright divide lozenge ydieresis Ydieresis fraction currency guilsinglleft guilsinglright fi fl daggerdbl periodcentered quotesinglbase quotedblbase perthousand Acircumflex Ecircumflex Aacute Edieresis Egrave Iacute Icircumflex Idieresis Igrave Oacute Ocircumflex apple Ograve Uacute Ucircumflex Ugrave dotlessi circumflex tilde macron breve dotaccent ring cedilla hungarumlaut ogonek caron Lslash lslash Scaron scaron Zcaron zcaron brokenbar Eth eth Yacute yacute Thorn thorn minus multiply onesuperior twosuperior threesuperior onehalf onequarter threequarters franc Gbreve gbreve Idotaccent Scedilla scedilla Cacute cacute Ccaron ccaron dcroat ].freeze
- VERSION_2_0_RAW =
Version 2.0 as Fixed 16.16 constant
131_072
Instance Method Summary collapse
-
#complete_version_2_data? ⇒ Boolean
Validation helper: Check if version 2.0 data is complete.
-
#glyph_names ⇒ Array<String>
Get glyph names based on version.
-
#has_glyph_names? ⇒ Boolean
Validation helper: Check if glyph names are available.
-
#has_underline_metrics? ⇒ Boolean
Validation helper: Check if underline values are present.
-
#italic_angle ⇒ Object
Get italic angle as float (Fixed 16.16 format).
-
#valid_fixed_pitch_flag? ⇒ Boolean
Validation helper: Check if fixed pitch flag is consistent.
-
#valid_italic_angle? ⇒ Boolean
Validation helper: Check if italic angle is reasonable.
-
#valid_version? ⇒ Boolean
Validation helper: Check if version is valid.
-
#version ⇒ Object
Get version as float (Fixed 16.16 format).
Methods inherited from Binary::BaseRecord
Instance Method Details
#complete_version_2_data? ⇒ Boolean
Validation helper: Check if version 2.0 data is complete
For version 2.0, we should have glyph count and name data
198 199 200 201 202 |
# File 'lib/fontisan/tables/post.rb', line 198 def complete_version_2_data? return true unless version == 2.0 !num_glyphs_v2.nil? && num_glyphs_v2.positive? && !remaining_data.empty? end |
#glyph_names ⇒ Array<String>
Get glyph names based on version
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/fontisan/tables/post.rb', line 82 def glyph_names @glyph_names ||= case version when 1.0 STANDARD_NAMES.dup when 2.0 parse_version_2_names else [] end end |
#has_glyph_names? ⇒ Boolean
Validation helper: Check if glyph names are available
For versions 1.0 and 2.0, glyph names should be accessible
188 189 190 191 |
# File 'lib/fontisan/tables/post.rb', line 188 def has_glyph_names? names = glyph_names !names.nil? && !names.empty? end |
#has_underline_metrics? ⇒ Boolean
Validation helper: Check if underline values are present
Both position and thickness should be non-zero for valid underline
172 173 174 |
# File 'lib/fontisan/tables/post.rb', line 172 def has_underline_metrics? underline_position != 0 && underline_thickness != 0 end |
#italic_angle ⇒ Object
Get italic angle as float (Fixed 16.16 format)
75 76 77 |
# File 'lib/fontisan/tables/post.rb', line 75 def italic_angle fixed_to_float(italic_angle_raw) end |
#valid_fixed_pitch_flag? ⇒ Boolean
Validation helper: Check if fixed pitch flag is consistent
179 180 181 |
# File 'lib/fontisan/tables/post.rb', line 179 def valid_fixed_pitch_flag? [0, 1].include?(is_fixed_pitch) end |
#valid_italic_angle? ⇒ Boolean
Validation helper: Check if italic angle is reasonable
Italic angle should be between -60 and 60 degrees
163 164 165 |
# File 'lib/fontisan/tables/post.rb', line 163 def valid_italic_angle? italic_angle.abs <= 60.0 end |
#valid_version? ⇒ Boolean
Validation helper: Check if version is valid
Common versions: 1.0, 2.0, 2.5, 3.0, 4.0
154 155 156 |
# File 'lib/fontisan/tables/post.rb', line 154 def valid_version? [1.0, 2.0, 2.5, 3.0, 4.0].include?(version) end |
#version ⇒ Object
Get version as float (Fixed 16.16 format)
70 71 72 |
# File 'lib/fontisan/tables/post.rb', line 70 def version fixed_to_float(version_raw) end |