Sha256: 84deb4af46857383b4b5e443a8e4b495efd1c1d6bfdb7a79949d9f2f3a584e75

Contents?: true

Size: 810 Bytes

Versions: 2

Compression:

Stored size: 810 Bytes

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 "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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hexapdf-0.2.0 test/hexapdf/font_loader/test_from_configuration.rb
hexapdf-0.1.0 test/hexapdf/font_loader/test_from_configuration.rb