test/hexapdf/layout/test_style.rb in hexapdf-0.19.0 vs test/hexapdf/layout/test_style.rb in hexapdf-0.19.1
- old
+ new
@@ -595,10 +595,15 @@
end
describe HexaPDF::Layout::Style do
before do
@style = HexaPDF::Layout::Style.new
+ @style.font = Object.new.tap do |obj|
+ obj.define_singleton_method(:pdf_object) do
+ Object.new.tap {|pdf| pdf.define_singleton_method(:glyph_scaling_factor) { 0.001 } }
+ end
+ end
end
it "can assign values on initialization" do
style = HexaPDF::Layout::Style.new(font_size: 10)
assert_equal(10, style.font_size)
@@ -642,10 +647,11 @@
assert_equal(-0.53, style.scaled_item_width(53))
end
end
it "has several simple and dynamically generated properties with default values" do
+ @style = HexaPDF::Layout::Style.new
assert_raises(HexaPDF::Error) { @style.font }
assert_equal(10, @style.font_size)
assert_equal(0, @style.character_spacing)
assert_equal(0, @style.word_spacing)
assert_equal(100, @style.horizontal_scaling)
@@ -723,9 +729,14 @@
wrapped_font.define_singleton_method(:ascender) { 600 }
wrapped_font.define_singleton_method(:descender) { -100 }
font = Object.new
font.define_singleton_method(:scaling_factor) { 1 }
font.define_singleton_method(:wrapped_font) { wrapped_font }
+ font.define_singleton_method(:pdf_object) do
+ obj = Object.new
+ obj.define_singleton_method(:glyph_scaling_factor) { 0.001 }
+ obj
+ end
@style.font = font
end
it "computes them correctly" do
@style.horizontal_scaling(200).character_spacing(1).word_spacing(2)