Repository navigation
Show a list box's rows whole in its appearance (#426) - #444
Merged
Merged
Conversation
This was referenced Sep 23, 2026
The appearance of an active list box split the height inside its border between the rows by the font's line height, so the last row was cut off. It now takes its rows from the select tag, gives each an equal share of that height, shrinks the font to keep each row whole, and draws only that many rows, starting at the first selection when it would fall below the last. A highlight fills its row. Rebased onto gravitypdf as one commit: the branch's six commits had added a combo box drop-down arrow and then taken it out again, as viewers draw their own, so only the list box change remains. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jakejackson1
force-pushed
the
fix/426-choice-appearances
branch
from
September 23, 2026 22:12
3fddda3 to
38764f6
Compare
jakejackson1
changed the base branch from
feature/pdfa-2-conformance
to
gravitypdf
September 23, 2026 22:12
jakejackson1
added a commit
that referenced
this pull request
Sep 23, 2026
#444's list box test looked for the Tm each appearance line was placed with. The lines now go through Mpdf::Text(), which places them with Td. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
jakejackson1
added a commit
that referenced
this pull request
Sep 23, 2026
…s drawn (#408) (#448) * Shape and order the text of a form widget's appearance as page text is drawn Appearance text was written character by character, so Arabic and Indic values showed unjoined glyphs and right-to-left values ran in logical order. Each line now goes through applyOTL() and magic_reverse_dir(), is measured as shaped, and is written with the operators Cell() uses: applyGPOSpdf() where OTL positioned glyphs, a plain string otherwise. With the appearances right, no form asks the viewer to redraw them, so /NeedAppearances, the /ZaDb font it needed for checkboxes (#59) and Otl::hasComplexScript() go. A text area with an auto font size is drawn at the largest size up to 12pt at which its wrapped text fits the field's height. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Write appearance text through Mpdf::Text(), and measure each word of a field once Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Say why appearance text sets the font size and keeps word widths Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Check that an active field's Arabic value is fitted by its shaped width, and trimmed by shaping what fits again fitLine() measures appearance text through emWidth(), which now shapes it, so a shaped value is sized by the width it is drawn at and a trimmed one is the shaped start of the value, not a cut of the whole shaped line. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Draw an appearance line with the shaping it was measured with, instead of shaping it again A fitted line was already shaped to be measured, and the draw loop shaped it again. It now takes the shaped text, its OTL data and its width from the same per-field cache emWidth() fills. Say why the appearance sets its font in an empty text object. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Say plainly how the shaped fitting test's value is measured Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Refresh the form snapshots whose appearance text is shaped and written by Mpdf::Text() form-fields-active, form-fields-pdfa, page-break-avoid-references and page-break-avoid-forms. Against the #433 fixtures, the Arabic value is shaped and right to left in both renderers, poppler draws form-fields-active from its appearances now that /NeedAppearances is gone, and "A field" takes the fi ligature on pages 2 and 3 of page-break-avoid-references. page-break-avoid-forms changes in bytes only. The maxlength field's fitted value is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Read a list box's rows from the operators Mpdf::Text() writes #444's list box test looked for the Tm each appearance line was placed with. The lines now go through Mpdf::Text(), which places them with Td. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * Add a snapshot of active fields showing shaped text beside the same text on the page Each row puts a value written on the page next to an active field showing it in the same font: Arabic, Arabic with vowel marks, Hebrew, a value mixing directions, Kannada and Thai, a value shrunk to fit, a wrapped and an auto-sized text area, a combo box, a list box and a button. Before #408 the fields drew Arabic unjoined and every right-to-left value backwards, broke up Kannada, misplaced Thai marks, and left an auto-sized text area at 12pt. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased onto
gravitypdfafter #470 as one commit, sincefeature/pdfa-2-conformancehad already been merged by #330. The branch's earlier commits added the combo box arrow and then removed it, so only the list box change is left.print_ob_select()passesSetFormChoice()therowsthat #446 now records on the select, guarded for callers that build their own attributes (#441'sFormFieldShrinkTest).form-fields-activeandform-fields-pdfawere refreshed again: the only difference fromgravitypdfis that the list box and multiple select show their rows whole ("Fourth" was cut off before).Fixes #426
Fixes the list box rows in the appearance streams #387 draws for choice fields. Since #387, every viewer draws a Latin-only form from these streams.
#426 raised two problems. This fixes the first, the clipped list box rows. It deliberately does not do the second, a drop-down arrow in the combo box's appearance: see below.
What changed
List box rows are shown whole.
Tag\Selectmakes a list boxsize× the font size tall, plus padding. That is shorter thansizerows at the font's own line height (ascent − descent, about 1.16 em in DejaVu). The old layout used the natural line height below a 2pt top padding, so the last row ran past the clip at the border and a one-row box could show the top of the next option.size="3"at the default size and about 10% atsize="10".sizerows are drawn. Scrolling to the first selected option works as before.Tag\Selectnow stores the row count it used for the height as$objattr['rows'].print_ob_select()passes it through a new optional$rowsargument ofSetFormChoice(), so the row split cannot drift from the box height. This doesn't change the layout.A combo box's appearance has no drop-down arrow. An earlier revision of this PR drew one. Acrobat draws its own button over a combo box, and pdf.js lays an HTML
<select>over it, so the arrow showed twice in exactly the viewers where the field is used. Acrobat's own combo box appearances carry no arrow either. So a printed or flattened combo box shows no arrow, as one Acrobat made would, which is the trade-off #426's second point raised. The appearance is unchanged from #387 apart from the rows fix above, and a test now holds every choice appearance to having no arrow, with its text clipped at the full inner width.Snapshots
form-fields-activeandform-fields-pdfa: thesize="3"andsize="4"list boxes show their last row ("Third", "Fourth") whole and slightly more tightly spaced. Nothing else moves.page-break-avoid-forms: unchanged from the base branch in its pixels.Each refresh was checked by rasterising old against new. The last refresh, which removed the arrow, differs from the fixture before it only in the button's pixels.
Verification
composer test: 3886 tests OK. The 5 skips are the checks that regenerate the Unicode, OpenType and emoji tables, unrelated to this change.composer test -- --group=snapshot: 90 OK.--group=conformance(veraPDF): 29 OK.composer test -- --group=conformance(veraPDF): 26 OK, including the active-form cases.composer csclean;php -lunder PHP 5.6 clean. PHPStan 2.2.15 reports only the unmatchedSvg.phpbaseline entry that Drop the isset() on a foreach variable that PHPStan 2.2.15 no longer reports #451 fixes ongravitypdf.FormAppearanceTest:testListBoxShowsItsRowsWhole: 1, 3 and 6 rows, in embedded and core fonts, at 16pt. Exactlysizelines are drawn, the clip height issizerows, and each line's ascent-to-descent box lies inside its own row. It fails on the base branch for every case: the one-row box drew a second line with a negative baseline.testAChoiceFieldAppearanceHasNoDropDownArrow: a combo box and one- and two-row list boxes draw no triangle and clip at the full inner width. It fails for the combo box on the previous revision.Limits / follow-ups
🤖 Generated with Claude Code