Class: HexaPDF::Font::TrueType::Table::Glyf::Glyph

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_offsetsObject (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

#componentsObject (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_contoursObject (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_dataObject (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_maxObject (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_minObject (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_maxObject (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_minObject (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.

Returns:

  • (Boolean)


98
99
100
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 98

def compound?
  number_of_contours < 0
end