Class: PDF::Reader::WidthCalculator::TrueType
- Inherits:
-
Object
- Object
- PDF::Reader::WidthCalculator::TrueType
- 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
- #glyph_width(code_point) ⇒ Object
-
#initialize(font) ⇒ TrueType
constructor
A new instance of TrueType.
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 |