Sha256: a53a1342aff59f90b68250bc7bccfe86753d93180b4fb49e2316cac4b8bb8b4b

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

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

require 'stringio'
require 'test_helper'
require 'hexapdf/font/true_type'
require 'hexapdf/font/true_type/builder'

describe HexaPDF::Font::TrueType::Builder do
  before do
    font_file = File.join(TEST_DATA_DIR, "fonts", "Ubuntu-Title.ttf")
    @font = HexaPDF::Font::TrueType::Font.new(File.open(font_file))
    @subsetter = HexaPDF::Font::TrueType::Subsetter.new(@font)
  end

  after do
    @font.io.close
  end

  it "builds the font file" do
    tables = {
      "head" => @font[:head].raw_data,
      "glyf" => @font[:glyf].raw_data,
      "loca" => @font[:loca].raw_data,
      "maxp" => @font[:maxp].raw_data,
    }
    font_data = HexaPDF::Font::TrueType::Builder.build(tables)
    built_font = HexaPDF::Font::TrueType::Font.new(StringIO.new(font_data))

    assert(built_font[:head].checksum_valid?)
    assert_equal(@font[:glyf].raw_data, built_font[:glyf].raw_data)
    assert(built_font[:glyf].checksum_valid?)
    assert_equal(@font[:loca].raw_data, built_font[:loca].raw_data)
    assert(built_font[:loca].checksum_valid?)
    assert_equal(@font[:maxp].raw_data, built_font[:maxp].raw_data)
    assert(built_font[:maxp].checksum_valid?)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hexapdf-0.6.0 test/hexapdf/font/true_type/test_builder.rb
hexapdf-0.5.0 test/hexapdf/font/true_type/test_builder.rb
hexapdf-0.4.0 test/hexapdf/font/true_type/test_builder.rb