Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #2541 don't look for NULL glyph in fallback font as this can impact line height #2542

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 3 additions & 0 deletions docs/modules/theme/pages/prepare-custom-font.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
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
Loading