Sha256: 3746ba17880c3461e84bcd84171afa8e71d4419720c457ed8631b29e50377175

Contents?: true

Size: 700 Bytes

Versions: 10

Compression:

Stored size: 700 Bytes

Contents

# coding: utf-8
# frozen_string_literal: true

class PDF::Reader
  module WidthCalculator
    # Type0 (or Composite) fonts are a "root font" that rely on a "descendant font"
    # to do the heavy lifting. The "descendant font" is a CID-Keyed font.
    # see Section 9.7.1, PDF 32000-1:2008, pp 267
    # so if we are calculating a Type0 font width, we just pass off to
    # the descendant font
    class TypeZero

      def initialize(font)
        @font = font
        @descendant_font = @font.descendantfonts.first
      end

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

        @descendant_font.glyph_width(code_point).to_f
      end
    end
  end
end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
pdf-reader-2.6.0 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.5.0 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.4.2 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.4.1 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.4.0 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.3.0 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.2.1 lib/pdf/reader/width_calculator/type_zero.rb
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.4.0/gems/pdf-reader-2.2.0/lib/pdf/reader/width_calculator/type_zero.rb
embulk-input-druginfo_interview_form-0.1.0 vendor/bundle/ruby/2.5.0/gems/pdf-reader-2.2.0/lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.2.0 lib/pdf/reader/width_calculator/type_zero.rb