Skip to content

Make an inline form font an object of its own before an appearance names it - #134

Merged
bobsingor merged 3 commits into
embedpdf/mainfrom
embedpdf/fix/inline-dr-font
Nov 29, 2026
Merged

bobsingor merged 3 commits into
embedpdf/mainfrom
embedpdf/fix/inline-dr-font

Conversation

@bobsingor

@bobsingor bobsingor commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Cause

Filled fields blank in Acrobat. When a form's font is written inline in /AcroForm /DR (a dictionary inside /DR, not an object of its own), CPDF_AnnotFontMap::PrepareFontResources gives the appearance a fill writes an inline copy of it (font_dict->Clone()). Acrobat 26 then shows none of the editable text fields filled that way: nothing is drawn, the field has no highlight, and it can't be clicked. Read-only fields still show.

Acrobat was checked one change at a time, starting from the engine's filled file:

  • the fonts in the appearances made objects of their own, /DR still inline: still blank;
  • the /DR font made an object of its own, the appearances keeping their inline copies: every field shows, live;
  • both naming one object: every field shows, live.

So Acrobat minds the font that /DR holds inline. Real forms keep their /DR fonts as objects of their own (none of 131 real-world forms in a local scan writes them inline); hand-written and generated files often don't.

A stray appearance on a created field. CollectRawTxnControls takes a field without /Kids to be its own widget even when it is not a widget annotation. The engine creates a field, sets its flags, then attaches its widgets, so making a new field read-only (EPDFForm_SetFieldFlags, then RegenerateFieldAppearances) drew an appearance with /BBox [0 0 0 0] onto the field dictionary itself, beside its widget's real one. A value written and redrawn before the widget is attached did the same.

Change

  • CPDF_AnnotFontMap::PrepareFontResources stages a copy of an inline default form font. Once preparation succeeds, PublishFontResources gives that copy an object number and installs it in the appearance and in /AcroForm /DR /Font. Form fields, free text and redaction overlays use this path for stored appearances. Existing indirect fonts keep their object numbers.
  • A field without /Kids is its own widget only with /Subtype /Widget, as CPDF_InteractiveForm::AddTerminalField reads it. A field with no widget yet has no controls: its value is written, and nothing is drawn.
  • The ledger’s own-appearance-generator rule records when the font is published and which tests cover it.

Tests

  • EPDFFormEmbedderTest.AFillMakesAnInlineFormFontAnObject: two fills of a form whose /DR font is inline. /DR and both appearances name one new object, in memory and in the saved file.
  • AnInlineFormFontBecomesAnObjectInATransaction: the same in a layer transaction, as the engine writes.
  • AFormFontThatIsAnObjectIsNamedAsItIs: text_form.pdf's font is named as it is, and /DR is not written (nothing of it is promoted on a layer).
  • AFieldWithoutWidgetsGetsNoDrawing: create a field, make it read-only, fill it, then attach a widget. The field dictionary never gets an /AP; the widget does.
  • EPDFAnnotEmbedderTest.FailedFreeTextAppearanceKeepsFormFontInline rejects a zero-width FreeText box and checks the form resources, last object number and absence of an appearance. A retry with a valid box checks that the appearance and form share the published font.
  • The layer-mode writer list includes the two new form writers and the successful FreeText retry.

Checked

On 37e7c9903f, the FreeText regression passed on macOS in ordinary and layer mode. It failed on c3c02b694b, where the rejected call allocated object 5 and changed the inline font to a reference. All 1,412 unit tests passed. The ordinary annotation and form suites had 244 passes and one optional skip. The layer-mode runner reported only its documented redaction crash, and every writer count matched. The strict fork-tag and C API checks passed.

The following checks were run on the preceding revision, c3c02b694b.

  • Without the change the first, second and fourth tests fail; the third passes either way.
  • macOS: unit 1412 passed. Embedder 1888 passed and the 12 golden failures of the base; the suite without those 12 exits 0, and the saved-PDF checker reads its 49 saved PDFs without recovery.
  • The whole suite in layer mode, macOS and Linux: no error. On macOS the counts are the base's apart from the new tests, and every existing test leaves the same number of objects in its layer.
  • Pixel runner (macOS): the same as the base, 147 passed, 26 suppressed, 2 surprises and 51 failures, the same files.
  • Linux x64 in the release image: unit 1419 passed, embedder 1902 passed, none failed.
  • check-fork-tags.py --strict, check-c-api.py (604 functions), check-globals.py on the macOS library.
  • Built into the engine (WebAssembly and macOS): new conformance cases for both changes fail on the released library and pass with this one, on the local and the cloud engine; the whole local (2154) and cloud (1295) engine suites pass.
  • Acrobat 26.002: the filled file that showed four blank fields shows all four with their text, live, and takes the cursor. A form signed while its /DR font was inline, then filled (so this change makes the font an object after the signature): with an approval signature Acrobat says the signed revision is unaltered and lists "Form Fields Filled In"; with a certification at P=2 it says the changes are permitted by the certifying party, with the same list. The engine's signature analysis says permitted for both.

Left

  • Release, and the pin in embed-pdf-viewer, with the engine conformance suite for both changes.
  • check-globals.py on the Linux library: not run.
  • Not part of this change: upstream's form filler (CPDF_BAFontMap) copies an inline font into the appearances it writes the same way. The engine does not write through it.

…mes it

When a form's font is written inline in /AcroForm /DR (a dictionary inside
/DR, not an object of its own), the appearance a fill writes got an inline
copy of it, and Acrobat showed none of the editable fields filled that way:
nothing drawn, no highlight, no click. Acrobat minds the font /DR holds
inline; the appearance's own copy alone does not matter.

The first appearance written into the file that names such a font now makes
it an object of its own, which /DR and the appearance both name.
A field without /Kids was taken to be its own widget even when it is not a
widget annotation. The engine creates a field, sets its flags, then attaches
its widgets, so making a new field read-only drew an appearance with an empty
box onto the field dictionary itself. Such a field is its own widget only
with /Subtype /Widget, as CPDF_InteractiveForm reads it.
@bobsingor
bobsingor merged commit 0585b31 into embedpdf/main Nov 29, 2026
1 check passed
@bobsingor
bobsingor deleted the embedpdf/fix/inline-dr-font branch November 29, 2026 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant