This file is indexed.

/usr/lib/ruby/vendor_ruby/pdf/reader/width_calculator/true_type.rb is in ruby-pdf-reader 1.3.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# coding: utf-8

class PDF::Reader
  module WidthCalculator
    # Calculates the width of a glyph in a TrueType font
    class TrueType

      def initialize(font)
        @font = font

        if @font.font_descriptor
          @missing_width = @font.font_descriptor.missing_width
        else
          @missing_width = 0
        end
      end

      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

      private

      #TODO convert Type3 units 1000 units => 1 text space unit
      def glyph_width_from_font(code_point)
        return 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

      def glyph_width_from_descriptor(code_point)
        return unless @font.font_descriptor

        # true type fonts will have most of their information contained
        # with-in a program inside the font descriptor, however the widths
        # may not be in standard PDF glyph widths (1000 units => 1 text space unit)
        # so this width will need to be scaled
        w = @font.font_descriptor.find_glyph_width(code_point)
        if w
          w.to_f * @font.font_descriptor.glyph_to_pdf_scale_factor
        else
          nil
        end
      end
    end
  end
end