Sha256: a824612f88f252081d91a78e36cbb5cb96356d17bcad7ad1db98b0ca361f0878

Contents?: true

Size: 714 Bytes

Versions: 5

Compression:

Stored size: 714 Bytes

Contents

# coding: utf-8
# typed: true
# 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

5 entries across 5 versions & 1 rubygems

Version Path
pdf-reader-2.9.2 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.9.1 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.9.0 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.8.0 lib/pdf/reader/width_calculator/type_zero.rb
pdf-reader-2.7.0 lib/pdf/reader/width_calculator/type_zero.rb