Sha256: 51f19142643a4b11edf53f630151a7bed274fb848e558655064a03f5ff4d3f99

Contents?: true

Size: 1.1 KB

Versions: 52

Compression:

Stored size: 1.1 KB

Contents

# -*- encoding: utf-8 -*-

require 'test_helper'
require 'hexapdf/document'
require 'hexapdf/type/font_type3'

describe HexaPDF::Type::FontType3 do
  before do
    @doc = HexaPDF::Document.new
    @font = @doc.add({Type: :Font, Subtype: :Type3, Encoding: :WinAnsiEncoding,
                      FirstChar: 32, LastChar: 34, Widths: [600, 0, 700],
                      FontBBox: [0, 100, 100, 0], FontMatrix: [0.002, 0, 0, 0.002, 0, 0],
                      CharProcs: {}})
  end

  describe "bounding_box" do
    it "returns the font's bounding box" do
      assert_equal([0, 0, 100, 100], @font.bounding_box)
    end

    it "inverts the y-values if necessary based on /FontMatrix" do
      @font[:FontMatrix][3] *= -1
      assert_equal([0, -100, 100, 0], @font.bounding_box)
    end
  end

  it "returns the glyph scaling factor" do
    assert_equal(0.002, @font.glyph_scaling_factor)
  end

  describe "validation" do
    it "works for valid objects" do
      assert(@font.validate)
    end

    it "fails if the Encoding key is missing" do
      @font.delete(:Encoding)
      refute(@font.validate)
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
hexapdf-1.2.0 test/hexapdf/type/test_font_type3.rb
hexapdf-1.1.1 test/hexapdf/type/test_font_type3.rb
hexapdf-1.1.0 test/hexapdf/type/test_font_type3.rb
hexapdf-1.0.3 test/hexapdf/type/test_font_type3.rb
hexapdf-1.0.2 test/hexapdf/type/test_font_type3.rb
hexapdf-1.0.1 test/hexapdf/type/test_font_type3.rb
hexapdf-1.0.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.47.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.46.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.45.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.44.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.41.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.40.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.39.1 test/hexapdf/type/test_font_type3.rb
hexapdf-0.39.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.38.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.37.2 test/hexapdf/type/test_font_type3.rb
hexapdf-0.37.1 test/hexapdf/type/test_font_type3.rb
hexapdf-0.37.0 test/hexapdf/type/test_font_type3.rb
hexapdf-0.36.0 test/hexapdf/type/test_font_type3.rb