File: rbpdf_font_func_test.rb

package info (click to toggle)
ruby-rbpdf 1.21.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,488 kB
  • sloc: ruby: 138,259; makefile: 12
file content (45 lines) | stat: -rw-r--r-- 1,183 bytes parent folder | download | duplicates (4)
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
# Copyright (c) 2011-2017 NAITOH Jun
# Released under the MIT license
# http://www.opensource.org/licenses/MIT

require 'test_helper'

class RbpdfFontFuncTest < Test::Unit::TestCase
  class MYPDF < RBPDF
    def putAPXObject(w=0, h=0, stream='')
      super
    end
  end
  test "Font get_font_descent function test 1" do
    pdf = RBPDF.new
    fontdescent = pdf.get_font_descent('times', '', 18)
    assert_in_delta 0.95, fontdescent, 0.01
  end

  test "Font get_font_descent function test 2" do
    pdf = RBPDF.new
    fontdescent = pdf.get_font_descent('freesans', '', 18)
    assert_in_delta 1.91, fontdescent, 0.01
  end

  test "Font get_font_ascent function test 1" do
    pdf = RBPDF.new
    fontascent = pdf.get_font_ascent('times', '', 18)
    assert_in_delta 5.39, fontascent, 0.01
  end

  test "Font get_font_ascent function test 2" do
    pdf = RBPDF.new
    fontascent = pdf.get_font_ascent('freesans', '', 18)
    assert_in_delta 6.35, fontascent, 0.01
  end

  test "putAPXObject test" do
    pdf = MYPDF.new

    apxo_obj_id = pdf.putAPXObject
    assert_equal 400001, apxo_obj_id
    apxo_obj_id = pdf.putAPXObject
    assert_equal 400002, apxo_obj_id
  end
end