Sha256: eb3af29218a4d884f0a6c68840de86d900117de215833b459c6ba38121477ee6

Contents?: true

Size: 1.08 KB

Versions: 8

Compression:

Stored size: 1.08 KB

Contents

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

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

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

  it "loads the font if the name contains a valid variant" do
    wrapper = @obj.call(@doc, "Helvetica bold")
    assert_equal("Helvetica-Bold", wrapper.wrapped_font.font_name)
    wrapper = @obj.call(@doc, "Helvetica italic")
    assert_equal("Helvetica-Oblique", wrapper.wrapped_font.font_name)
    wrapper = @obj.call(@doc, "Helvetica bold_italic")
    assert_equal("Helvetica-BoldOblique", wrapper.wrapped_font.font_name)
  end

  it "returns nil if the font name contains an unknown variant" do
    assert_nil(@obj.call(@doc, "Helvetica oblique"))
  end

  it "ignores a supplied variant keyword argument" do
    wrapper = @obj.call(@doc, "Helvetica bold", variant: :italic)
    assert_equal("Helvetica-Bold", wrapper.wrapped_font.font_name)
  end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hexapdf-1.0.2 test/hexapdf/font_loader/test_variant_from_name.rb
hexapdf-1.0.1 test/hexapdf/font_loader/test_variant_from_name.rb
hexapdf-1.0.0 test/hexapdf/font_loader/test_variant_from_name.rb
hexapdf-0.47.0 test/hexapdf/font_loader/test_variant_from_name.rb
hexapdf-0.46.0 test/hexapdf/font_loader/test_variant_from_name.rb
hexapdf-0.45.0 test/hexapdf/font_loader/test_variant_from_name.rb
hexapdf-0.44.0 test/hexapdf/font_loader/test_variant_from_name.rb
hexapdf-0.41.0 test/hexapdf/font_loader/test_variant_from_name.rb