Class: HexaPDF::Font::TrueType::Table::Glyf
- Inherits:
-
HexaPDF::Font::TrueType::Table
- Object
- HexaPDF::Font::TrueType::Table
- HexaPDF::Font::TrueType::Table::Glyf
- Defined in:
- lib/hexapdf/font/true_type/table/glyf.rb
Overview
The ‘glyf’ table contains the instructions for rendering glyphs and some additional glyph information.
This is probably always the largest table in a TrueType font, so care is taken to perform operations lazily.
See: developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html
Defined Under Namespace
Classes: Glyph
Constant Summary
Constants inherited from HexaPDF::Font::TrueType::Table
Instance Attribute Summary collapse
-
#glyphs ⇒ Object
The mapping from glyph ID to Glyph object or
nil
(if the glyph has no outline).
Attributes inherited from HexaPDF::Font::TrueType::Table
Instance Method Summary collapse
-
#[](glyph_id) ⇒ Object
Returns the Glyph object for the given glyph ID.
Methods inherited from HexaPDF::Font::TrueType::Table
calculate_checksum, #checksum_valid?, #directory_entry, #initialize, #raw_data
Constructor Details
This class inherits a constructor from HexaPDF::Font::TrueType::Table
Instance Attribute Details
#glyphs ⇒ Object
The mapping from glyph ID to Glyph object or nil
(if the glyph has no outline).
139 140 141 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 139 def glyphs @glyphs end |
Instance Method Details
#[](glyph_id) ⇒ Object
Returns the Glyph object for the given glyph ID. If the glyph has no outline (e.g. the space character), an empty Glyph object is returned.
143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/hexapdf/font/true_type/table/glyf.rb', line 143 def [](glyph_id) return @glyphs[glyph_id] if @glyphs.key?(glyph_id) offset = font[:loca].offset(glyph_id) length = font[:loca].length(glyph_id) if length == 0 @glyphs[glyph_id] = Glyph.new('') else raw_data = with_io_pos(directory_entry.offset + offset) { io.read(length) } @glyphs[glyph_id] = Glyph.new(raw_data) end end |