Sha256: 0e77f5c04878dbc62f3604c65ceeedfaa99e1ee4f8fc1f4017183b06774700c0

Contents?: true

Size: 840 Bytes

Versions: 3

Compression:

Stored size: 840 Bytes

Contents

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

require 'test_helper'
require 'hexapdf/document'
require 'hexapdf/type/font'

describe HexaPDF::Type::Font do
  before do
    @doc = HexaPDF::Document.new
    cmap = @doc.add({}, stream: <<-EOF)
      2 beginbfchar
      <20> <0041>
      <22> <0042>
      endbfchar
    EOF
    @font = @doc.add({Type: :Font, BaseFont: :TestFont, ToUnicode: cmap})
  end

  it "must always be an indirect" do
    assert(@font.must_be_indirect?)
  end

  describe "to_utf" do
    it "uses the /ToUnicode CMap if it is available" do
      assert_equal("A", @font.to_utf8(32))
      assert_equal("B", @font.to_utf8(34))
      assert_equal("", @font.to_utf8(0))
    end

    it "returns an empty string if no /ToUnicode CMap is available" do
      @font.delete(:ToUnicode)
      assert_equal("", @font.to_utf8(32))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hexapdf-0.3.0 test/hexapdf/type/test_font.rb
hexapdf-0.2.0 test/hexapdf/type/test_font.rb
hexapdf-0.1.0 test/hexapdf/type/test_font.rb