Skip to content
Closed
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
6 changes: 4 additions & 2 deletions src/parse/pdf_resources/page_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -2612,12 +2612,14 @@ namespace pdflib
};

// Subset generators (FontForge, fontTools, mPDF, ...) name glyphs by
// bare index: /gid00043, /g43, /glyph43, /cid43, /index43. Such a name
// bare index: /gid00043, /g43, /glyph43, /cid43, /index43. Skia/PDF
// (Chrome print-to-PDF, Notion exports) writes `g%X`, so the index may
// carry hexadecimal digits: /g15C, /gA1. Such a name
// identifies the glyph inside the embedded font program but carries no
// reading text, so keeping it fabricates plausible-looking garbage
// ('gid00043gid00049...') that downstream quality gates cannot detect
// (docling-project/docling-parse#238).
std::regex re_gid(R"((gid|glyph|g|cid|index)\d+)", std::regex::icase);
std::regex re_gid(R"((gid|glyph|g|cid|index)[0-9A-Fa-f]+)", std::regex::icase);

// A small family of PDF producers replaces every descriptive glyph name
// with an uppercase `G<decimal Unicode>` name. Do not infer that convention
Expand Down
2 changes: 1 addition & 1 deletion tests/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from tests.regression_page_selection import REGRESSION_PAGE_SELECTION

HF_DATASET_REPO_ID = "docling-project/regression-dataset-for-docling-parse"
HF_DATASET_REVISION = "6d3458e2a6a729defd700a7b91e57b6cb2ce0290"
HF_DATASET_REVISION = "4103ae9b54a52f6890b57d6711614defd03d77b8"

REGRESSION_DIR = "tests/data/regression"

Expand Down
12 changes: 12 additions & 0 deletions tests/test_unit_nul_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,15 @@ def test_nul_mapping_with_unknown_identity_remains_unresolved():
_extract_character(mapping="0000", glyph_name="gid00043")
== "GLYPH<name:gid00043>"
)


@pytest.mark.parametrize("glyph_name", ["g15C", "g15c", "gA1", "GID00043"])
def test_nul_mapping_with_hexadecimal_glyph_index_name_remains_unresolved(
glyph_name: str,
):
# Skia/PDF names Type 3 glyphs `g%X` (hexadecimal gid), so a bare index
# may carry letters A-F; it still identifies no reading text.
assert (
_extract_character(mapping="0000", glyph_name=glyph_name)
== f"GLYPH<name:{glyph_name}>"
)
Loading