Sha256: 4f1dadcb3ca0c67564d614d3350c9db00eb7819697c4af7a8c91e7733dea9647

Contents?: true

Size: 847 Bytes

Versions: 5

Compression:

Stored size: 847 Bytes

Contents

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

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

module TestHelper

  def set_up_stub_true_type_font(initial_data = ''.b, register_vars: true)
    font = Object.new
    font.define_singleton_method(:io) { @io ||= StringIO.new(initial_data) }
    font.define_singleton_method(:config) { @config ||= {} }
    entry = HexaPDF::Font::TrueType::Table::Directory::Entry.new('mock', 0, 0, initial_data.length)
    @font, @entry = font, entry if register_vars
    [font, entry]
  end

  def create_table(name, data = nil, standalone: false)
    font, entry = standalone ? set_up_stub_true_type_font(register_vars: false) : [@font, @entry]
    if data
      font.io.string = data
      entry.length = font.io.length
    end
    HexaPDF::Font::TrueType::Table.const_get(name).new(font, entry)
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hexapdf-0.24.0 test/hexapdf/font/true_type/table/common.rb
hexapdf-0.23.0 test/hexapdf/font/true_type/table/common.rb
hexapdf-0.22.0 test/hexapdf/font/true_type/table/common.rb
hexapdf-0.21.1 test/hexapdf/font/true_type/table/common.rb
hexapdf-0.21.0 test/hexapdf/font/true_type/table/common.rb