Sha256: 81be2038dcdcc9d70e13a99d1896e9e0ba2fe6fd1c2e76e02b37f427d19fddcd

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

# coding: utf-8

require 'test/unit/helper'

class ThinReports::Generator::Pdf::TestFont < MiniTest::Unit::TestCase
  include ThinReports::TestHelpers
  
  # Alias
  Font = ThinReports::Generator::Pdf::Font
  
  def setup
    @doc = ThinReports::Generator::Pdf::Document.new
  end
  
  def test_setup_fonts_install_builtin_fonts
    Font::BUILTIN_FONTS.each_key do |font|
      assert_includes @doc.internal.font_families.keys, font
    end
  end
  
  def test_setup_fonts_install_fallback_font
    assert_includes @doc.internal.font_families.keys, 'FallbackFont'
    assert_includes @doc.internal.fallback_fonts, 'FallbackFont'
  end
  
  def test_fallback_font_has_all_styles_as_normal_IPAMincho
    ipam = Font::BUILTIN_FONTS['IPAMincho'][:normal]
    [:normal, :bold, :italic, :bold_italic].each do |style|
       assert_same @doc.internal.font_families['FallbackFont'][style], ipam
    end
  end
  
  def test_setup_fonts_install_alias_fonts_of_CourierNew_and_TimesNewRoman
    assert_same @doc.internal.font_families['Courier New'],
                @doc.internal.font_families['Courier']
    assert_same @doc.internal.font_families['Times New Roman'],
                @doc.internal.font_families['Times-Roman']
  end
  
  def test_default_family
    assert_equal @doc.send(:default_family), 'Helvetica'
  end
  
  def test_default_family_if_missing
    assert_equal @doc.send(:default_family_if_missing, 'unknown font'),
                 @doc.send(:default_family)
    assert_equal @doc.send(:default_family_if_missing, 'IPAMincho'), 'IPAMincho'
  end
  
  def test_font_has_style?
    assert_equal @doc.send(:font_has_style?, 'IPAMincho', :bold), false
    assert_equal @doc.send(:font_has_style?, 'Courier New', :bold), true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinreports-0.6.0.pre3 test/unit/generator/pdf/document/test_font.rb