summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2022-05-20 03:19:45 -0600
committerDan Allen <dan.j.allen@gmail.com>2022-05-20 14:47:43 -0600
commitb50d46be56b803d66c056838b7ffab51d9d5ea59 (patch)
treeada917162fee4abb0470e0a15edc5970f6d4a157 /spec
parent734b06c39f12f77f51952a2eee47eff5ca28087c (diff)
resolves #2193 fix size and position of full height inline image so it fits within available height of page
- always use bounds height as max height for inline image - subtract top padding from line metrics from ascender for full height image - don't protect bottom gutter if line contains a full height image - add tests
Diffstat (limited to 'spec')
-rw-r--r--spec/image_spec.rb46
-rw-r--r--spec/reference/image-inline-in-block-scale-down-height.pdfbin0 -> 26063 bytes
-rw-r--r--spec/reference/image-inline-scale-down-height.pdfbin24180 -> 23834 bytes
3 files changed, 45 insertions, 1 deletions
diff --git a/spec/image_spec.rb b/spec/image_spec.rb
index d0b7a2ec..4305c2bb 100644
--- a/spec/image_spec.rb
+++ b/spec/image_spec.rb
@@ -507,7 +507,23 @@ describe 'Asciidoctor::PDF::Converter - Image' do
pdf = to_pdf input, analyze: :line
image_h = pdf.lines[1][:to][:y] - pdf.lines[1][:from][:y]
- (expect image_h).to be_within(1).of(350)
+ (expect image_h).to eql 350.0
+ end
+
+ it 'should scale down inline SVG to fit height of next page' do
+ input = <<~'EOS'
+ :pdf-page-size: 200x350
+ :pdf-page-margin: 0
+
+ before
+
+ image:tall.svg[]
+ EOS
+
+ pdf = to_pdf input, analyze: :line
+ (expect pdf.lines.map {|it| it[:page_number] }.uniq).to eql [2]
+ image_h = pdf.lines[1][:to][:y] - pdf.lines[1][:from][:y]
+ (expect image_h).to eql 350.0
end
it 'should display text inside link' do
@@ -1615,6 +1631,34 @@ describe 'Asciidoctor::PDF::Converter - Image' do
(expect line1_spacing).to eql line2_spacing
end
+ it 'should scale image down to fit available height on next page', visual: true do
+ to_file = to_pdf_file <<~'EOS', 'image-inline-pushed-scale-down-height.pdf'
+ :pdf-page-size: A6
+ :pdf-page-layout: landscape
+
+ before
+
+ image:cover.jpg[]
+ EOS
+
+ to_file = to_pdf_file %(image::#{to_file}[page=2]), 'image-inline-pushed-scale-down-height-2.pdf'
+
+ (expect to_file).to visually_match 'image-inline-scale-down-height.pdf'
+ end
+
+ it 'should scale image down to fit available height inside delimited block', visual: true do
+ to_file = to_pdf_file <<~'EOS', 'image-inline-in-block-scale-down-height.pdf'
+ :pdf-page-size: A6
+ :pdf-page-layout: landscape
+
+ ****
+ image:cover.jpg[]
+ ****
+ EOS
+
+ (expect to_file).to visually_match 'image-inline-in-block-scale-down-height.pdf'
+ end
+
it 'should not scale image if pdfwidth matches intrinsic width' do
pdf = to_pdf <<~'EOS', analyze: :image
see image:tux.png[pdfwidth=204] run
diff --git a/spec/reference/image-inline-in-block-scale-down-height.pdf b/spec/reference/image-inline-in-block-scale-down-height.pdf
new file mode 100644
index 00000000..1db693d4
--- /dev/null
+++ b/spec/reference/image-inline-in-block-scale-down-height.pdf
Binary files differ
diff --git a/spec/reference/image-inline-scale-down-height.pdf b/spec/reference/image-inline-scale-down-height.pdf
index 562c1914..4cbc9a2f 100644
--- a/spec/reference/image-inline-scale-down-height.pdf
+++ b/spec/reference/image-inline-scale-down-height.pdf
Binary files differ