Class: HexaPDF::Font::TrueType::Table::Glyf::Glyph
- Inherits:
-
Object
- Object
- HexaPDF::Font::TrueType::Table::Glyf::Glyph
- Defined in:
- lib/hexapdf/font/true_type/table/glyf.rb
Overview
Represents the definition of a glyph. Since the purpose of this implementation is not editing or rendering glyphs, the raw glyph data is only decoded so far as to get general information about the glyph.
Instance Attribute Summary collapse
-
#component_offsets ⇒ Object
readonly
The array with the component glyph offsets, or
nil
if this is not a compound glyph. -
#components ⇒ Object
readonly
The array with the component glyph IDs, or
nil
if this is not a compound glyph. -
#number_of_contours ⇒ Object
readonly
The number of contours in the glyph.
-
#raw_data ⇒ Object
readonly
Contains the raw byte data of the glyph.
-
#x_max ⇒ Object
readonly
The maximum x value for coordinate data.
-
#x_min ⇒ Object
readonly
The minimum x value for coordinate data.
-
#y_max ⇒ Object
readonly
The maximum y value for coordinate data.
-
#y_min ⇒ Object
readonly
The minimum y value for coordinate data.
Instance Method Summary collapse
-
#compound? ⇒ Boolean
Returns
true
if this a compound glyph. -
#initialize(raw_data) ⇒ Glyph
constructor
Creates a new glyph from the given raw data.
Constructor Details
#initialize(raw_data) ⇒ Glyph
Creates a new glyph from the given raw data.
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 84 def initialize(raw_data) @raw_data = raw_data @number_of_contours, @x_min, @y_min, @x_max, @y_max = @raw_data.unpack('s>5') @number_of_contours ||= 0 @x_min ||= 0 @y_min ||= 0 @x_max ||= 0 @y_max ||= 0 @components = nil @component_offsets = nil parse_compound_glyph if compound? end |
Instance Attribute Details
#component_offsets ⇒ Object (readonly)
The array with the component glyph offsets, or nil
if this is not a compound glyph.
81 82 83 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 81 def component_offsets @component_offsets end |
#components ⇒ Object (readonly)
The array with the component glyph IDs, or nil
if this is not a compound glyph.
78 79 80 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 78 def components @components end |
#number_of_contours ⇒ Object (readonly)
The number of contours in the glyph. A zero or positive number implies a simple glyph, a negative number a glyph made up from multiple components
63 64 65 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 63 def number_of_contours @number_of_contours end |
#raw_data ⇒ Object (readonly)
Contains the raw byte data of the glyph.
59 60 61 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 59 def raw_data @raw_data end |
#x_max ⇒ Object (readonly)
The maximum x value for coordinate data.
72 73 74 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 72 def x_max @x_max end |
#x_min ⇒ Object (readonly)
The minimum x value for coordinate data.
66 67 68 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 66 def x_min @x_min end |
#y_max ⇒ Object (readonly)
The maximum y value for coordinate data.
75 76 77 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 75 def y_max @y_max end |
#y_min ⇒ Object (readonly)
The minimum y value for coordinate data.
69 70 71 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 69 def y_min @y_min end |
Instance Method Details
#compound? ⇒ Boolean
Returns true
if this a compound glyph.
98 99 100 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 98 def compound? number_of_contours < 0 end |