Sha256: ea1e5a586f456b571d6e1335a9781231b66f9c32817a981ba53a241349e36a12

Contents?: true

Size: 1.04 KB

Versions: 83

Compression:

Stored size: 1.04 KB

Contents

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

require 'test_helper'
require 'hexapdf/font_loader'
require 'hexapdf/document'

describe HexaPDF::FontLoader::Standard14 do
  before do
    @doc = HexaPDF::Document.new
    @obj = HexaPDF::FontLoader::Standard14
  end

  it "loads the font if it is a standard PDF built-in font" do
    wrapper = @obj.call(@doc, "Times")
    assert_equal("Times-Roman", wrapper.wrapped_font.font_name)
    wrapper = @obj.call(@doc, "Helvetica", variant: :bold)
    assert_equal("Helvetica-Bold", wrapper.wrapped_font.font_name)
  end

  it "returns nil for unknown fonts" do
    assert_nil(@obj.call(@doc, "Unknown"))
  end

  it "returns a hash with all standard PDF fonts" do
    assert_equal({
                   'Times' => [:none, :bold, :italic, :bold_italic],
                   'Helvetica' => [:none, :bold, :italic, :bold_italic],
                   'Courier' => [:none, :bold, :italic, :bold_italic],
                   'Symbol' => [:none], 'ZapfDingbats' => [:none]
                 },
                 @obj.available_fonts(@doc))
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
hexapdf-1.0.2 test/hexapdf/font_loader/test_standard14.rb
hexapdf-1.0.1 test/hexapdf/font_loader/test_standard14.rb
hexapdf-1.0.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.47.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.46.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.45.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.44.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.41.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.40.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.39.1 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.39.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.38.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.37.2 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.37.1 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.37.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.36.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.35.1 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.35.0 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.34.1 test/hexapdf/font_loader/test_standard14.rb
hexapdf-0.34.0 test/hexapdf/font_loader/test_standard14.rb