File: font_descriptor_spec.rb

package info (click to toggle)
ruby-pdf-reader 2.15.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,544 kB
  • sloc: ruby: 11,993; sh: 46; makefile: 11
file content (57 lines) | stat: -rw-r--r-- 1,773 bytes parent folder | download | duplicates (2)
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
56
57
# typed: false
# coding: utf-8

describe PDF::Reader::FontDescriptor do
  describe "initialisation" do
    let!(:dict) do
      {
        :Ascent       => 10,
        :Descent      => 10,
        :MissingWidth => 500,
        :FontBBox     => [0, 0, 10, 10],
        :AvgWidth     => 40,
        :CapHeight    => 30,
        :Flags        => 1,
        :ItalicAngle  => 0,
        :FontName     => :Helvetica,
        :Leading      => 0,
        :MaxWidth     => 500,
        :StemV        => 0,
        :XHeight      => 0,
        :FontStretch  => :Condensed,
        :FontWeight   => 500,
        :FontFamily   => "BoldItalic"
      }
    end
    let!(:objects) { PDF::Reader::ObjectHash.allocate }
    subject        { PDF::Reader::FontDescriptor.new(objects, dict)}

    it "sets the correct instance vars" do
      expect(subject.ascent).to            eq(10)
      expect(subject.descent).to           eq(10)
      expect(subject.missing_width).to     eq(500)
      expect(subject.font_bounding_box).to eq([0,0, 10, 10])
      expect(subject.avg_width).to         eq(40)
      expect(subject.cap_height).to        eq(30)
      expect(subject.font_flags).to        eq(1)
      expect(subject.italic_angle).to      eq(0)
      expect(subject.font_name).to         eq("Helvetica")
      expect(subject.leading).to           eq(0)
      expect(subject.max_width).to         eq(500)
      expect(subject.stem_v).to            eq(0)
      expect(subject.x_height).to          eq(0)
      expect(subject.font_stretch).to      eq(:Condensed)
      expect(subject.font_weight).to       eq(500)
      expect(subject.font_family).to       eq("BoldItalic")
    end

  end

  describe "#glyph_width" do
    skip
  end

  describe "#glyph_to_pdf_scale_factor" do
    skip
  end
end