Class: PDF::Reader::WidthCalculator::TypeOneOrThree
- Inherits:
-
Object
- Object
- PDF::Reader::WidthCalculator::TypeOneOrThree
- Defined in:
- lib/pdf/reader/width_calculator/type_one_or_three.rb
Overview
Calculates the width of a glyph in a Type One or Type Three
Instance Method Summary collapse
-
#glyph_height(code_point) ⇒ Object
TODO: figure out the proper response when the pdf tries to write in vertical mode with this font (which doesn’t support vertical mode).
- #glyph_width(code_point) ⇒ Object
-
#initialize(font) ⇒ TypeOneOrThree
constructor
A new instance of TypeOneOrThree.
Constructor Details
#initialize(font) ⇒ TypeOneOrThree
Returns a new instance of TypeOneOrThree.
8 9 10 11 12 13 14 15 16 |
# File 'lib/pdf/reader/width_calculator/type_one_or_three.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_height(code_point) ⇒ Object
TODO: figure out the proper response when the pdf tries to write in vertical mode with this font (which doesn’t support vertical mode)
34 35 36 |
# File 'lib/pdf/reader/width_calculator/type_one_or_three.rb', line 34 def glyph_height(code_point) return 0 end |
#glyph_width(code_point) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pdf/reader/width_calculator/type_one_or_three.rb', line 18 def glyph_width(code_point) return 0 if code_point.nil? || code_point < 0 return 0 if @font.widths.nil? || @font.widths.count == 0 # in ruby a negative index is valid, and will go from the end of the array # which is undesireable in this case. if @font.first_char <= code_point @font.widths.fetch(code_point - @font.first_char, @missing_width).to_f else @missing_width.to_f end end |