Skip to content

Commit

Permalink
resolves asciidoctor#2541 don't look for NULL glyph in fallback font …
Browse files Browse the repository at this point in the history
…as this can impact line height
  • Loading branch information
mojavelinux committed Oct 4, 2024
1 parent c3e27b1 commit a10e06f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/asciidoctor/pdf/ext/prawn/formatted_text/box.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions spec/font_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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, debug: true
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'
Expand Down

0 comments on commit a10e06f

Please sign in to comment.