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)
68 69 70 71 72 |
# File 'lib/fontisan/tables/post_table.rb', line 68 def fixed_pitch? return false unless parsed parsed.is_fixed_pitch == 1 end |
#glyph_name_for(glyph_id) ⇒ String?
Get glyph name by ID
117 118 119 120 121 122 |
# File 'lib/fontisan/tables/post_table.rb', line 117 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
107 108 109 110 111 |
# File 'lib/fontisan/tables/post_table.rb', line 107 def glyph_names return [] unless parsed parsed.glyph_names || [] end |
#has_glyph_names? ⇒ Boolean
Check if glyph names are available
127 128 129 130 131 |
# File 'lib/fontisan/tables/post_table.rb', line 127 def has_glyph_names? return false unless parsed parsed.has_glyph_names? end |
#italic? ⇒ Boolean
Check if font is italic
44 45 46 47 |
# File 'lib/fontisan/tables/post_table.rb', line 44 def italic? angle = italic_angle !angle.nil? && angle != 0 end |
#italic_angle ⇒ Float?
Get italic angle in degrees
Positive value means counter-clockwise tilt
35 36 37 38 39 |
# File 'lib/fontisan/tables/post_table.rb', line 35 def italic_angle return nil unless parsed parsed.italic_angle end |
#max_mem_type1 ⇒ Integer?
Get maximum memory for Type 1 fonts
98 99 100 |
# File 'lib/fontisan/tables/post_table.rb', line 98 def max_mem_type1 parsed&.max_mem_type1 end |
#max_mem_type42 ⇒ Integer?
Get maximum memory for Type 42 fonts
84 85 86 |
# File 'lib/fontisan/tables/post_table.rb', line 84 def max_mem_type42 parsed&.max_mem_type42 end |
#min_mem_type1 ⇒ Integer?
Get minimum memory for Type 1 fonts
91 92 93 |
# File 'lib/fontisan/tables/post_table.rb', line 91 def min_mem_type1 parsed&.min_mem_type1 end |
#min_mem_type42 ⇒ Integer?
Get minimum memory for Type 42 fonts
77 78 79 |
# File 'lib/fontisan/tables/post_table.rb', line 77 def min_mem_type42 parsed&.min_mem_type42 end |
#named_glyph_count ⇒ Integer
Get the number of glyphs with names
136 137 138 |
# File 'lib/fontisan/tables/post_table.rb', line 136 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)
54 55 56 |
# File 'lib/fontisan/tables/post_table.rb', line 54 def underline_position parsed&.underline_position end |
#underline_thickness ⇒ Integer?
Get underline thickness
61 62 63 |
# File 'lib/fontisan/tables/post_table.rb', line 61 def underline_thickness parsed&.underline_thickness end |
#version ⇒ Float?
Get post table version
24 25 26 27 28 |
# File 'lib/fontisan/tables/post_table.rb', line 24 def version return nil unless parsed parsed.version end |