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.



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

def initialize(font)
  @font = font

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

Instance Method Details

#glyph_width(code_point) ⇒ Object



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

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)
end