Sha256: a79472986413f02628a3c1c0665b3a88f30a474e921de380b0ab5f5c0e282c22

Contents?: true

Size: 878 Bytes

Versions: 10

Compression:

Stored size: 878 Bytes

Contents

# coding: utf-8
# frozen_string_literal: true

class PDF::Reader
  module WidthCalculator
    # CIDFontType0 or CIDFontType2 use DW (integer) and W (array) to determine
    # codepoint widths, note that CIDFontType2 will contain a true type font
    # program which could be used to calculate width, however, a conforming writer
    # is supposed to convert the widths for the codepoints used into the W array
    # so that it can be used.
    # see Section 9.7.4.1, PDF 32000-1:2008, pp 269-270
    class Composite

      def initialize(font)
        @font = font
        @widths = PDF::Reader::CidWidths.new(@font.cid_default_width, @font.cid_widths)
      end

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

        w = @widths[code_point]
        # 0 is a valid width
        return w.to_f unless w.nil?
      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/composite.rb
pdf-reader-2.5.0 lib/pdf/reader/width_calculator/composite.rb
pdf-reader-2.4.2 lib/pdf/reader/width_calculator/composite.rb
pdf-reader-2.4.1 lib/pdf/reader/width_calculator/composite.rb
pdf-reader-2.4.0 lib/pdf/reader/width_calculator/composite.rb
pdf-reader-2.3.0 lib/pdf/reader/width_calculator/composite.rb
pdf-reader-2.2.1 lib/pdf/reader/width_calculator/composite.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/composite.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/composite.rb
pdf-reader-2.2.0 lib/pdf/reader/width_calculator/composite.rb