Class: Fontisan::Tables::PostTable
- Defined in:
- lib/fontisan/tables/post_table.rb
Overview
OOP representation of 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.
This class extends SfntTable to provide post-specific validation and convenience methods for accessing PostScript metrics and glyph names.
Instance Attribute Summary
Attributes inherited from SfntTable
Instance Method Summary collapse
-
#fixed_pitch? ⇒ Boolean
Check if font is fixed pitch (monospaced).
-
#glyph_name_for(glyph_id) ⇒ String?
Get glyph name by ID.
-
#glyph_names ⇒ Array<String>
Get all glyph names.
-
#has_glyph_names? ⇒ Boolean
Check if glyph names are available.
-
#italic? ⇒ Boolean
Check if font is italic.
-
#italic_angle ⇒ Float?
Get italic angle in degrees.
-
#max_mem_type1 ⇒ Integer?
Get maximum memory for Type 1 fonts.
-
#max_mem_type42 ⇒ Integer?
Get maximum memory for Type 42 fonts.
-
#min_mem_type1 ⇒ Integer?
Get minimum memory for Type 1 fonts.
-
#min_mem_type42 ⇒ Integer?
Get minimum memory for Type 42 fonts.
-
#named_glyph_count ⇒ Integer
Get the number of glyphs with names.
-
#underline_position ⇒ Integer?
Get underline position.
-
#underline_thickness ⇒ Integer?
Get underline thickness.
-
#version ⇒ Float?
Get post 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
#fixed_pitch? ⇒ Boolean
Check if font is fixed pitch (monospaced)
71 72 73 74 75 |
# File 'lib/fontisan/tables/post_table.rb', line 71 def fixed_pitch? return false unless parsed parsed.is_fixed_pitch == 1 end |
#glyph_name_for(glyph_id) ⇒ String?
Get glyph name by ID
120 121 122 123 124 125 |
# File 'lib/fontisan/tables/post_table.rb', line 120 def glyph_name_for(glyph_id) names = glyph_names return nil if glyph_id.negative? || glyph_id >= names.length names[glyph_id] end |
#glyph_names ⇒ Array<String>
Get all glyph names
Only available for version 1.0 and 2.0
110 111 112 113 114 |
# File 'lib/fontisan/tables/post_table.rb', line 110 def glyph_names return [] unless parsed parsed.glyph_names || [] end |
#has_glyph_names? ⇒ Boolean
Check if glyph names are available
130 131 132 133 134 |
# File 'lib/fontisan/tables/post_table.rb', line 130 def has_glyph_names? return false unless parsed parsed.has_glyph_names? end |
#italic? ⇒ Boolean
Check if font is italic
47 48 49 50 |
# File 'lib/fontisan/tables/post_table.rb', line 47 def italic? angle = italic_angle !angle.nil? && angle != 0 end |
#italic_angle ⇒ Float?
Get italic angle in degrees
Positive value means counter-clockwise tilt
38 39 40 41 42 |
# File 'lib/fontisan/tables/post_table.rb', line 38 def italic_angle return nil unless parsed parsed.italic_angle end |
#max_mem_type1 ⇒ Integer?
Get maximum memory for Type 1 fonts
101 102 103 |
# File 'lib/fontisan/tables/post_table.rb', line 101 def max_mem_type1 parsed&.max_mem_type1 end |
#max_mem_type42 ⇒ Integer?
Get maximum memory for Type 42 fonts
87 88 89 |
# File 'lib/fontisan/tables/post_table.rb', line 87 def max_mem_type42 parsed&.max_mem_type42 end |
#min_mem_type1 ⇒ Integer?
Get minimum memory for Type 1 fonts
94 95 96 |
# File 'lib/fontisan/tables/post_table.rb', line 94 def min_mem_type1 parsed&.min_mem_type1 end |
#min_mem_type42 ⇒ Integer?
Get minimum memory for Type 42 fonts
80 81 82 |
# File 'lib/fontisan/tables/post_table.rb', line 80 def min_mem_type42 parsed&.min_mem_type42 end |
#named_glyph_count ⇒ Integer
Get the number of glyphs with names
139 140 141 |
# File 'lib/fontisan/tables/post_table.rb', line 139 def named_glyph_count glyph_names.length end |
#underline_position ⇒ Integer?
Get underline position
Distance from baseline to top of underline (negative for under baseline)
57 58 59 |
# File 'lib/fontisan/tables/post_table.rb', line 57 def underline_position parsed&.underline_position end |
#underline_thickness ⇒ Integer?
Get underline thickness
64 65 66 |
# File 'lib/fontisan/tables/post_table.rb', line 64 def underline_thickness parsed&.underline_thickness end |
#version ⇒ Float?
Get post table version
27 28 29 30 31 |
# File 'lib/fontisan/tables/post_table.rb', line 27 def version return nil unless parsed parsed.version end |