https://bugs.documentfoundation.org/show_bug.cgi?id=173918

--- Comment #5 from Jamalofski <[email protected]> ---
Still reproducible in 26.8.3.1 with the same setup as comment 4 (Build ID:
861effc5289d539f15c4c18d1ba8579ffd78728b): 0 px of ink between A and B under
MuPDF and poppler, 528 px with 26.2.7.3.

Correction to my analysis in the description and comment 4: setting
HB_SUBSET_FLAGS_NOTDEF_OUTLINE in PhysicalFontFace::CreateFontSubset() is
probably not enough on its own.

What the 26.8.1.1 PDF (attachment 209013) contains: both uncovered characters
are shown with code 2. The embedded Liberation Sans subset has 4 glyphs: gid 0
(.notdef) has 0 contours, gid 2 has 0 contours and a 0 advance in hmtx, and the
format 0 cmap maps code 2 to gid 2. In the 26.2.6.3 PDF (attachment 209015),
gid 0 and gid 2 both hold the 2-contour box.

Why, reading libreoffice-26.8.3.1 and the HarfBuzz it bundles (14.2.1):

1. PDFWriterImpl::registerSimpleGlyph() gives each new glyph the code
m_aMapping.size()+1, so the .notdef used in the text (font glyph 0) gets a code
N >= 1 (2 here), while fillSubsetArrays() also keeps glyph 0 at code 0. The
loop in CreateFontSubset() calls hb_map_set(pGlyphMap, 0, 0), then
hb_map_set(pGlyphMap, 0, N), which overwrites it.

2. hb-subset does not honour the requested mapping for glyph 0:
_create_old_gid_to_new_gid_map() in hb-subset-plan.cc always pushes (0, 0) for
old gid 0. Nothing is placed at gid N, and the cmap that CreateFontSubset()
builds from pEncoding maps code N to gid N, an empty slot.

3. glyf::_populate_subset_glyphs() then empties gid 0 of a non-variable font
unless HB_SUBSET_FLAGS_NOTDEF_OUTLINE is set.

So the flag alone would bring the box back at gid 0, but the text would still
show code N. A complete fix probably also needs the text to use code 0 for font
glyph 0 (in registerSimpleGlyph()), or some other way to get the .notdef
outline at the code the text uses.

On master, registerSimpleGlyph(), fillSubsetArrays() and the hb_map_set() loop
are unchanged, and HarfBuzz 15.1.0 treats glyph 0 the same way; master no
longer adds the format 0 cmap. I have not tested a master build.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to