class HexaPDF::Font::TrueType::Table::Glyf
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
Attributes
glyphs[RW]
The mapping from glyph ID to Glyph
object or nil
(if the glyph has no outline).
Public Instance Methods
[](glyph_id)
click to toggle source
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.
# File lib/hexapdf/font/true_type/table/glyf.rb, line 142 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
Private Instance Methods
parse_table()
click to toggle source
Nothing to parse here since we lazily parse glyphs.
# File lib/hexapdf/font/true_type/table/glyf.rb, line 159 def parse_table @glyphs = {} end