Sha256: d4fc8917d0510520e6140273ad6ff6f7f8c4a25ed6043f2552fe467203f5c1cc

Contents?: true

Size: 1.12 KB

Versions: 16

Compression:

Stored size: 1.12 KB

Contents

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

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

describe HexaPDF::FontLoader::FromConfiguration do
  before do
    @doc = HexaPDF::Document.new
    font_file = File.join(TEST_DATA_DIR, "fonts", "Ubuntu-Title.ttf")
    @doc.config['font.map'] = {'font' => {none: font_file}}
    @klass = HexaPDF::FontLoader::FromConfiguration
  end

  it "loads the configured font" do
    wrapper = @klass.call(@doc, "font")
    assert_equal("Ubuntu-Title", wrapper.wrapped_font.font_name)
  end

  it "passes the subset value to the wrapper" do
    wrapper = @klass.call(@doc, "font")
    assert(wrapper.subset?)
    wrapper = @klass.call(@doc, "font", subset: false)
    refute(wrapper.subset?)
  end

  it "fails if the font file cannot be read" do
    @doc.config['font.map']['font'][:none] << "unknown"
    assert_raises(HexaPDF::Error) { @klass.call(@doc, "font") }
  end

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

  it "returns a hash with all configured fonts" do
    assert_equal({'font' => [:none]}, @klass.available_fonts(@doc))
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
hexapdf-0.14.0 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.13.0 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.12.3 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.12.2 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.12.1 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.12.0 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.9 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.8 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.7 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.6 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.5 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.4 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.3 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.2 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.1 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.11.0 test/hexapdf/font_loader/test_from_configuration.rb