diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 9f1bf14ee..26f71e9f7 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -55,6 +55,7 @@ Bug Fixes:: * remove deprecated, undocumented `svg-font-family` theme key (the correct key is `svg-fallback-font-family`) * major improvement to OTF support following release of ttfunk 1.8.0 (automatic transitive dependency of prawn) * don't allow AsciiDoc table cell to overrun bottom of page on which it fits (#2538) +* don't look for NULL glyph in fallback font as this can impact line height (#2541) == 2.3.18 (2024-07-27) - @mojavelinux diff --git a/docs/modules/theme/pages/prepare-custom-font.adoc b/docs/modules/theme/pages/prepare-custom-font.adoc index 00bb88d32..794e6e588 100644 --- a/docs/modules/theme/pages/prepare-custom-font.adoc +++ b/docs/modules/theme/pages/prepare-custom-font.adoc @@ -112,6 +112,9 @@ The fonts used by the default theme in Asciidoctor PDF provide all of these glyp If the .notdef glyph is non-empty (i.e., contains splines), it will be used as the default glyph when the document requests a character that's missing from the font. Unlike other glyphs, the .notdef glyph is referenced by name only, meaning it does not have a designated Unicode code point. +Although Asciidoctor PDF uses the \u0000 character as a placeholder for inline anchors, the font is not required to provide this character. +Asciidoctor PDF assumes that the primary font provides this character and uses the font metrics from that font as though it were there. + If you're preparing a font for use in verbatim blocks (e.g., a listing block), you'll also need this range of characters: * \u2460 to \u2468 - circled numbers diff --git a/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb b/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb index 0bdaa0ad1..740be8732 100644 --- a/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb +++ b/lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb @@ -61,8 +61,8 @@ def analyze_glyphs_for_fallback_font_support fragment_hash form_fragments_from_like_font_glyph_pairs font_glyph_pairs, fragment_hash end - # TODO: remove once Prawn 2.5 is released def find_font_for_this_glyph char, current_font, current_font_opts = {}, fallback_fonts_to_check = [], original_font = current_font + return current_font if char == ?\u0000 # never look for NUL character in fallback fonts as it's not rendered (doc = @document).font current_font, current_font_opts if doc.font.glyph_present? char current_font diff --git a/spec/font_spec.rb b/spec/font_spec.rb index 51364772a..4539c419a 100644 --- a/spec/font_spec.rb +++ b/spec/font_spec.rb @@ -88,6 +88,28 @@ (expect text[:font_name]).to eql 'NotoSerif-Bold' end + it 'should not look for NUL glyph in fallback font when missing from primary font' do + pdf_theme = { + extends: 'default', + font_catalog: { + 'Noto Serif' => { + 'normal' => 'notoserif-regular-subset.ttf', + }, + 'M+ 1p Fallback' => { + 'normal' => 'mplus1p-regular-fallback.ttf', + }, + }, + base_font_family: 'M+ 1p Fallback', + font_fallbacks: ['Noto Serif'], + } + input = '. [[L1]]List item with anchor' + pdf = to_pdf input, analyze: true, pdf_theme: pdf_theme + marker, text = pdf.text + (expect marker[:font_name]).to eql 'mplus-1p-regular' + (expect text[:font_name]).to eql 'mplus-1p-regular' + (expect marker[:y]).to eql text[:y] + end + it 'should include box drawing glyphs in bundled monospace font', visual: true do input_file = Pathname.new fixture_file 'box-drawing.adoc' to_file = to_pdf_file input_file, 'font-box-drawing.pdf'