diff options
| -rw-r--r-- | CHANGELOG.adoc | 1 | ||||
| -rw-r--r-- | lib/asciidoctor/pdf/converter.rb | 11 | ||||
| -rw-r--r-- | spec/cover_page_spec.rb | 24 |
3 files changed, 30 insertions, 6 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 12f99047..6d844220 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -20,6 +20,7 @@ Enhancements:: Bug Fixes:: +* set the base font of the front cover image is a PDF and the title page is not active (#2092) * pass through warnings in background SVG to logger (#1940) * keep closing quote with trailing ellipsis in text enclosed in typographic quotes (#321) * collapse space in front of hidden index term (#2061) diff --git a/lib/asciidoctor/pdf/converter.rb b/lib/asciidoctor/pdf/converter.rb index f7cf95d5..34cfe448 100644 --- a/lib/asciidoctor/pdf/converter.rb +++ b/lib/asciidoctor/pdf/converter.rb @@ -192,17 +192,14 @@ module Asciidoctor # NOTE: a new page will already be started (page_number = 2) if the front cover image is a PDF layout_cover_page doc, :front has_front_cover = page_number > marked_page_number - - if (title_page_on = doc.doctype == 'book' || (doc.attr? 'title-page')) - layout_title_page doc - has_title_page = page_number == (has_front_cover ? 2 : 1) - end + has_title_page = layout_title_page doc if (title_page_on = doc.doctype == 'book' || (doc.attr? 'title-page')) @page_margin_by_side[:cover] = @page_margin_by_side[:recto] if @media == 'prepress' && page_number == 0 start_new_page unless page&.empty? # rubocop:disable Lint/SafeNavigationWithEmpty - # NOTE: font must be set before content is written to the main or scratch document + # NOTE: the base font must be set before any content is written to the main or scratch document + # this method is called inside layout_title_page if the title page is active font @theme.base_font_family, size: @root_font_size, style: @theme.base_font_style unless has_title_page unless title_page_on @@ -2712,6 +2709,7 @@ module Asciidoctor node.id ? %(<a id="#{node.id}">#{DummyText}</a>#{quoted_text}) : quoted_text end + # Returns a Boolean indicating whether the title page was created def layout_title_page doc return unless doc.header? && !doc.notitle && @theme.title_page != false @@ -2843,6 +2841,7 @@ module Asciidoctor end layout_prose DummyText, margin: 0, line_height: 1, normalize: false if page.empty? + true end def layout_cover_page doc, face diff --git a/spec/cover_page_spec.rb b/spec/cover_page_spec.rb index a9dba2b1..3d810b74 100644 --- a/spec/cover_page_spec.rb +++ b/spec/cover_page_spec.rb @@ -367,6 +367,30 @@ describe 'Asciidoctor::PDF::Converter - Cover Page' do File.unlink dest_file end + it 'should set the base font for a book when front cover image is a PDF and title page is off' do + pdf = to_pdf <<~EOS, analyze: true + = Document Title + :front-cover-image: #{fixture_file 'blue-letter.pdf', relative: true} + :doctype: book + :notitle: + + content + EOS + + (expect (pdf.find_unique_text 'content')[:font_name]).to eql 'NotoSerif' + end + + it 'should set the base font for an article when front cover image is a PDF and title page is off' do + pdf = to_pdf <<~EOS, analyze: true + = Document Title + :front-cover-image: #{fixture_file 'blue-letter.pdf', relative: true} + + content + EOS + + (expect (pdf.find_unique_text 'content')[:font_name]).to eql 'NotoSerif' + end + it 'should not allow page size of PDF cover page to affect page size of document' do input = <<~EOS = Document Title |
