diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 7a1c3638d..6055fadd8 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -9,6 +9,7 @@ For a detailed view of what has changed, refer to the {url-repo}/commits/main[co Bug Fixes:: +* don't warn about missing character in fallback font when inline image is advanced to next page (#2492) * support toc start at value for page numbering and running content when toc is added using macro (#2489) * fix page number of index entries in prepress book when page numbering starts at toc or after toc and toc is inserted using macro (#2487) diff --git a/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb b/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb index 4b140bdd6..0bdaa0ad1 100644 --- a/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb +++ b/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb @@ -33,7 +33,9 @@ def draw_fragment_overlay_styles fragment end # help Prawn correctly resolve which font to analyze, including the font style + # also instruct Prawn to ignore fragment for inline image since the text is just a placeholder def analyze_glyphs_for_fallback_font_support fragment_hash + return [fragment_hash] if fragment_hash[:image_obj] fragment_font = fragment_hash[:font] || (original_font = @document.font.family) effective_font_styles = @document.font_styles fragment_font_opts = {} diff --git a/spec/image_spec.rb b/spec/image_spec.rb index 2e6adfda8..1abcb752f 100644 --- a/spec/image_spec.rb +++ b/spec/image_spec.rb @@ -2150,6 +2150,24 @@ def traverse node (expect to_file).to visually_match 'image-wrap-inline.pdf' end + it 'should not warn about missing image placeholder char in fallback font when image is advanced to next page' do + (expect do + filler = %w(filler) * 26 * %(\n\n) + pdf = to_pdf <<~EOS, pdf_theme: { extends: 'default-with-font-fallbacks' } + #{filler} + + #{'x' * 200} Look for the image:square.png[]. + EOS + (expect pdf.pages).to have_size 2 + (expect get_images pdf).to have_size 1 + (expect (get_images pdf, 1)).to be_empty + (expect (get_images pdf, 2)).to have_size 1 + pdf.pages.each do |page| + (expect page.text).not_to include ?\u2063 + end + end).to not_log_message using_log_level: :INFO + end + it 'should increase line height if height if image height is more than 1.5x line height', visual: true do to_file = to_pdf_file <<~'EOS', 'image-inline-extends-line-height.pdf' see tux run + @@ -2188,9 +2206,9 @@ def traverse node (expect to_file).to visually_match 'image-inline-scale-down-height.pdf' end - it 'should not warn about missing glyph for image placeholder char when using AFM font' do + it 'should not warn about missing image placeholder char in AFM font when image is advanced to next page' do (expect do - pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => 'base' }, analyze: :image + pdf = to_pdf <<~'EOS', attribute_overrides: { 'pdf-theme' => 'base' } :pdf-page-size: A6 :pdf-page-layout: landscape @@ -2198,8 +2216,13 @@ def traverse node image:square.png[pdfwidth=7cm] EOS - (expect (images = pdf.images)).to have_size 1 - (expect images[0][:page_number]).to be 2 + (expect pdf.pages).to have_size 2 + (expect get_images pdf).to have_size 1 + (expect (get_images pdf, 1)).to be_empty + (expect (get_images pdf, 2)).to have_size 1 + pdf.pages.each do |page| + (expect page.text).not_to include ?\u2063 + end end).to not_log_message using_log_level: :INFO end