Ligature Glyphs generate spaces and break text - Need a built-in ligature-aware text normalization
Bug
The PDF's embedded font encoding maps ligature glyphs (fi, fl, ff, ffi, ffl) to separate characters with spaces. Both Docling's layout model and native backend produce identical broken text — Docling just passes through what the PDF gives it. ...
Steps to reproduce
Text with ligature glyphs is processed by Docling. Docling produces text with space separated characters Examples:
Ligature Pattern fi veri fi cation → verification fl in fl ammation → inflammation ff a ff ect → affect ffi a ffi nity → affinity ffl wa ffl e → waffle Apostrophe Virchow ' s → Virchow's En-dash T cell e mediated → T cell–mediated Word join Humoralimmunity.Naïve → Humoralimmunity. Naïve
Standard PDF ligatures and their Unicode points
LIGATURE_MAP = { "\ufb00": "ff", # ff ligature "\ufb01": "fi", # fi ligature "\ufb02": "fl", # fl ligature "\ufb03": "ffi", # ffi ligature "\ufb04": "ffl", # ffl ligature "\ufb05": "ft", # ft ligature (rare) "\ufb06": "st", # st ligature (rare) "\u2013": "–", # en-dash "\u2014": "—", # em-dash "\u2019": "'", # right single quote (apostrophe) } ...
Docling version
v2.93.0 ...
Python version
Python 3.13.13 ...
Possible solution
A built-in ligature-aware text normalization
Hi @drjagan! I'm Dosu and I’m helping the docling team.
This is a known area that has been worked on. PR #3057 introduced built-in ligature normalization in the PageAssembleModel.sanitize_text() method [1], which handles exactly the ligature map you've described (U+FB00–U+FB06) and absorbs spurious spaces between ligature glyphs and the following word characters using a regex pattern [2].
However, as reported in issue #3056, some users have noted that the fix only partially resolves the problem depending on the specific PDF [3]. The issue may be that in certain PDFs, the font encoding maps ligatures to literal /uniFB01-style strings or breaks text in ways that the current regex doesn't capture — for example, when the ligature glyph is not preserved as its Unicode codepoint but rather as a raw glyph name.
Since you're on v2.93.0, you should already have the ligature normalization from PR #3057 plus the extended support for Dutch ligatures and Private-Use Area glyphs added in April 2026 [4]. If you're still seeing broken text, the issue likely lies in how the PDF backend extracts the glyphs before they reach the sanitization step — the characters may not be arriving as their Unicode ligature codepoints (U+FB00–U+FB06) at all.
Could you share a sample PDF that reproduces this? That would help the maintainers determine whether the text is arriving as proper Unicode ligatures (which should already be handled) or in some other encoding that bypasses the current normalization.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
Hi @drjagan, I’d like to look into this, but since Docling already seems to have some ligature normalization, I think the first step is to reproduce the exact failure.
Could you share a minimal sample PDF where these broken outputs still appear in v2.93.0? Once reproducible, I can check whether the text reaches sanitize_text() as Unicode ligatures, glyph names, or already-separated characters.
@sriharan0804 here is a reproducer for the ligature part of this issue, with PDFs that can be redistributed. Short version: the split is gone since docling-parse 7.21.0.
Files. Two CC BY articles from the PMC Open Access subset, published by Taylor & Francis (typeset with Arbortext Advanced Print Publisher, distilled with Acrobat Distiller):
- PMC9487863, 15 pages, doi:10.1080/17441692.2021.1923776
- PMC9612937, 18 pages, doi:10.1080/17441692.2022.2103581
Result. Words split around an f-ligature in the text lines of docling-parse (signi fi cant, e ff ect, a ffl icted), counted against the pypdfium2 words of the same page:
| docling-parse | PMC9487863 | PMC9612937 |
|---|---|---|
| 7.19.1 | 125 | 105 |
| 7.20.0 | 125 | 105 |
| 7.21.0 | 0 | 0 |
| 7.22.0 | 0 | 0 |
| 7.22.1 | 0 | 0 |
With docling 2.132.0 (docling-parse 7.22.1) the exported Markdown of the first four pages of PMC9487863 has no split word left.
What happens in these files. The ligatures are not U+FB0x characters of the text font. Each one is a single glyph painted from a companion subset font (AdvOT1ef757c0+fb next to AdvOT1ef757c0), and docling-parse already decodes it to plain ff / fi. The character cells of "significant" on page 3 of PMC9487863 are the same in 7.20.0 and 7.22.1:
['i' AdvOT1ef757c0] ['g' AdvOT1ef757c0] ['n' AdvOT1ef757c0] ['i' AdvOT1ef757c0] ['fi' AdvOT1ef757c0+fb] ['c' AdvOT1ef757c0] ['a' AdvOT1ef757c0] ...
What differs is the word cells: up to 7.20.0 the word is cut at both font changes (signi, fi, cant). So the text reaches sanitize_text() as three separate words with no U+FB0x in it, which is why the normalisation from #3057 has nothing to act on. 7.21.0 contains the rewrite of cell contraction (docling-project/docling-parse#351) and the words come out whole. I only bisected by release, not by commit.
One side effect on the same files: 7.21.0 and 7.22.0 glue some neighbouring words together (5 and 30 cases, the regression of docling-project/docling-parse#355); 7.22.1 is back to 1 and 0.
Not covered. The other symptoms of the original report (Virchow ' s, the en dash read as e, Humoralimmunity.Naïve) do not appear in these two files with any of the versions above, so they probably come from a different font construct. A sample from @drjagan would still be needed for those.
Script (needs docling-parse and pypdfium2, downloads the two PDFs)
import re
import urllib.request
from importlib.metadata import version
from pathlib import Path
import pypdfium2 as pdfium
from docling_parse.pdf_parser import DoclingPdfParser
# CC BY articles from the PMC Open Access subset (Taylor & Francis, Global Public Health)
PDFS = {
"PMC9487863": "https://pmc-oa-opendata.s3.amazonaws.com/PMC9487863.1/PMC9487863.1.pdf",
"PMC9612937": "https://pmc-oa-opendata.s3.amazonaws.com/PMC9612937.1/PMC9612937.1.pdf",
}
LIGATURES = {"ff", "fi", "fl", "ffi", "ffl"}
WORD = re.compile(r"[^\W\d_]+")
print(f"docling-parse {version('docling-parse')}, pypdfium2 {version('pypdfium2')}")
for name, url in PDFS.items():
path = Path(f"{name}.pdf")
if not path.exists():
urllib.request.urlretrieve(url, path)
reference = pdfium.PdfDocument(path)
splits = []
for page_no, page in DoclingPdfParser(loglevel="fatal").load(path_or_stream=str(path)).iterate_pages():
text = reference[page_no - 1].get_textpage().get_text_range()
words = {w.lower() for w in WORD.findall(re.sub(chr(0xFFFE) + r"\s*", "", text))} # U+FFFE: line-end hyphen
for cell in page.textline_cells:
tokens = cell.text.split(" ")
for i, token in enumerate(tokens):
if token.lower() not in LIGATURES or token.lower() in words:
continue
left = (WORD.findall(tokens[i - 1]) or [""])[-1] if i > 0 else ""
right = (WORD.findall(tokens[i + 1]) or [""])[0] if i + 1 < len(tokens) else ""
for a, b in ((left, right), ("", right), (left, "")):
if (a or b) and f"{a}{token}{b}".lower() in words:
splits.append(" ".join(x for x in (a, token, b) if x))
break
print(f"{name}: {len(splits)} words split around a ligature, e.g. {splits[:6]}")
Output with 7.20.0, then 7.22.1:
docling-parse 7.20.0, pypdfium2 5.13.0
PMC9487863: 125 words split around a ligature, e.g. ['e ff ectiveness', 'e ff ect', 'identi fi able', 'o ff er', 'identi fi ed', 'e ff ective']
PMC9612937: 105 words split around a ligature, e.g. ['fi ve', 'de fi nition', 'modi fi ed', 'de fi nition', 'de fi ned', 'a ff ects']
docling-parse 7.22.1, pypdfium2 5.13.0
PMC9487863: 0 words split around a ligature, e.g. []
PMC9612937: 0 words split around a ligature, e.g. []
Classification labels added: priority:medium, pdf.
These labels are advisory. Maintainers can correct them. The workflow preserves these corrections.
Still happening on docling-parse 7.26.0 with a different PDF pattern (space glyph kerned back over the ligature). Root cause and repro: docling-project/docling-parse#470