Class: PDF::Reader::WidthCalculator::TrueType

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf/reader/width_calculator/true_type.rb

Overview

Calculates the width of a glyph in a TrueType font

Instance Method Summary collapse

Constructor Details

#initialize(font) ⇒ TrueType

Returns a new instance of TrueType.



10
11
12
13
14
15
16
17
18
# File 'lib/pdf/reader/width_calculator/true_type.rb', line 10

def initialize(font)
  @font = font

  if fd = @font.font_descriptor
    @missing_width = fd.missing_width
  else
    @missing_width = 0
  end
end

Instance Method Details

#glyph_width(code_point) ⇒ Object



20
21
22
23
# File 'lib/pdf/reader/width_calculator/true_type.rb', line 20

def glyph_width(code_point)
  return 0 if code_point.nil? || code_point < 0
  glyph_width_from_font(code_point) || glyph_width_from_descriptor(code_point) || 0
end