test/hexapdf/layout/test_text_layouter.rb in hexapdf-0.34.1 vs test/hexapdf/layout/test_text_layouter.rb in hexapdf-0.35.0
- old
+ new
@@ -649,29 +649,29 @@
before do
@items = boxes(*[[20, 20]] * 4) + [glue(10), penalty(-5000)]
end
it "aligns the contents to the left" do
- @style.align = :left
+ @style.text_align = :left
result = @layouter.fit(@items, 100, 100)
assert_equal(0, result.lines[0].x_offset)
assert_equal(80, result.lines[0].width)
result = @layouter.fit(@items, proc { 100 }, 100)
assert_equal(0, result.lines[0].x_offset)
assert_equal(80, result.lines[0].width)
end
it "aligns the contents to the center" do
- @style.align = :center
+ @style.text_align = :center
result = @layouter.fit(@items, 100, 100)
assert_equal(10, result.lines[0].x_offset)
result = @layouter.fit(@items, proc { 100 }, 100)
assert_equal(10, result.lines[0].x_offset)
end
it "aligns the contents to the right" do
- @style.align = :right
+ @style.text_align = :right
result = @layouter.fit(@items, 100, 100)
assert_equal(20, result.lines[0].x_offset)
result = @layouter.fit(@items, proc { 100 }, 100)
assert_equal(20, result.lines[0].x_offset)
end
@@ -681,32 +681,32 @@
before do
@items = boxes(*[[20, 20]] * 4)
end
it "aligns the contents to the top" do
- @style.valign = :top
+ @style.text_valign = :top
result = @layouter.fit(@items, 40, 100)
assert_equal(result.lines[0].y_max, result.lines[0].y_offset)
assert_equal(40, result.height)
end
it "aligns the contents to the center" do
- @style.valign = :center
+ @style.text_valign = :center
result = @layouter.fit(@items, 40, 100)
assert_equal((100 - 40) / 2 + 20, result.lines[0].y_offset)
assert_equal(70, result.height)
end
it "aligns the contents to the bottom" do
- @style.valign = :bottom
+ @style.text_valign = :bottom
result = @layouter.fit(@items, 40, 100)
assert_equal(100 - 20 * 2 + 20, result.lines[0].y_offset)
assert_equal(100, result.height)
end
it "doesn't vertically align when layouting in variable-width mode" do
- @style.valign = :bottom
+ @style.text_valign = :bottom
result = @layouter.fit(@items, proc { 40 }, 100)
assert_equal(result.lines[0].y_max, result.lines[0].y_offset)
assert_equal(40, result.height)
end
end
@@ -721,11 +721,11 @@
# Width of spaces: 2.5 * 2 + 5 = 10 (from AFM file, adjusted for font size)
# Line width: 20 * 4 + width_of_spaces = 90
# Missing width: 100 - 90 = 10
# -> Each space must be doubled!
- @style.align = :justify
+ @style.text_align = :justify
result = @layouter.fit(items, 100, 100)
assert(result.remaining_items.empty?)
assert_equal(:success, result.status)
assert_equal(9, result.lines[0].items.count)
assert_in_delta(100, result.lines[0].width)
@@ -768,11 +768,11 @@
@line2w = HexaPDF::Layout::TextFragment.create("more text.", font: @font).width
end
it "respects the x- and y-offsets" do
top = 100
- @layouter.style.valign = :center
- @layouter.style.align = :center
+ @layouter.style.text_valign = :center
+ @layouter.style.text_align = :center
result = @layouter.fit([@frag], @width, top)
result.draw(@canvas, 5, top)
initial_baseline = top - result.lines.first.y_offset