Skip to content

Draw form widgets' borders, button layouts and automatic sizes as Acrobat does - #133

Open
bobsingor wants to merge 1 commit into
embedpdf/mainfrom
embedpdf/fix/button-borders-spacing
Open

bobsingor wants to merge 1 commit into
embedpdf/mainfrom
embedpdf/fix/button-borders-spacing

Conversation

@bobsingor

Copy link
Copy Markdown
Contributor

Cause

Acrobat 26 redrew our fields itself on Nov 26 2026: 30 fields of every kind in five border styles,
244 push buttons across ten borders and three sizes, and 33 fields at the automatic text size. Its
saved drawings showed three ways ours differ.

  • Border styles. Check boxes, radio buttons and push buttons drew their box with one writer
    (BuildCheckboxBoxStream) that never read /BS /S: dashed drew solid, beveled and inset drew a
    frame twice as thick, and underline drew a whole frame. Acrobat draws every style on these kinds
    as on a text field. A radio button was an ellipse filling its box, where Acrobat draws a circle
    as wide as the box is high, in the middle. A beveled border's shaded edges were mid grey on every
    field kind, where Acrobat shades them by the background (the background less a quarter, light
    grey without one).
  • Button layout. SplitButton followed upstream's form filler: the picture one border width in
    and a side caption against the picture. Acrobat fits the picture twice the border's width in, and
    leaves room around the caption that grows with the border.
  • Automatic size. A field at size 0 took the largest step of CPVT's ladder (… 18, 20, 25, 30 …)
    that fits; Acrobat fits the text exactly, so ours was often 5 to 10% smaller. A list box always
    drew at 12, so a long option ran past the edge and the rows below it were cut off. A check box's
    check was half the size of Acrobat's.

Change

  • One box for every rectangular widget (WriteFieldBox): text, signature, check box, push
    button (with a caption and with a picture alone) and a radio button that shows a symbol other
    than a circle. BuildCheckboxBoxStream is gone.
  • Radio circle (RadioCircleOf, WriteRadioCircleBox): in the middle of the box, as wide as
    the box is high. The background fills it; the border is a circle line half its width in, dashed
    when the border is; beveled and inset add two half circles inside it, lit at the upper left and
    shaded at the lower right; underline draws the whole circle. The dot is half the circle inside
    its border, in every state.
  • Bevel shade (BeveledShade): GenerateBorderAP takes a beveled border's shade from its
    caller. Widgets pass the background less a quarter (light grey without one), so text, combo, list
    and signature fields change too; free text keeps mid grey.
  • Button layout (ButtonPlate, SplitButton): the picture's part is twice the border's width
    b in (BorderStyleInfo's width, which counts beveled and inset twice). The caption's strip
    reaches 3b and its extent in from its edge, and the caption sits in the middle of the room
    Acrobat measures from: b above the bottom edge, 2b below the top, the right edge itself, 2b
    in from the left. So a caption right of the picture ends 1.5b from the edge and starts 1.5b
    from the picture. When the strip leaves the picture no room, the picture is left out and the
    caption is drawn alone where the rule puts it. Captions are clipped to the button inside its
    border, as Acrobat clips them.
  • Automatic size (CPDF_RichTextLayout::ArrangeField): the largest size the text fits at, to a
    thousandth of a point, between the ladder's ends (4 and 144; 12 for several lines). FreeText still
    steps down the ladder. A redaction label at size 0 goes through the same layout and fits exactly
    too.
  • List box (ListBoxAutoSize): at size 0 the widest option fits the width inside twice the
    border, at most 12. Rows start 2b in, as Acrobat's do; the highlight still reaches the border.
  • Check mark (CheckSymbolRect): as large as Acrobat's ZapfDingbats check, whose size fills the
    box inside its border less b at each side with the font's box (0.963 of the size); the mark is
    0.719 of that size high, in the middle. A radio button that shows a check gets the same mark.
  • DashOperator moves to cpdf_appearancegenerator_internal.h. The ledger's
    own-appearance-generator and rich-text rules say all of this.

Tests

  • CPDFGenerateAPTest.WidgetBoxesDrawEveryBorderStyle: every rectangular widget kind draws the
    same box as a text field in every style, with Acrobat's geometry.
    ChoiceFieldsShadeABeveledBorderByTheirBackground, RadioButtonsDrawACircleInTheMiddleOfTheBox
    (every style, the dot, underline drawn whole). BorderArrayDrawsAsBorderStyleForEveryKind: every
    kind now draws dashes.
  • EPDFWidgetDrawingEmbedderTest.AButtonIsSharedAsAcrobatSharesIt replaces
    AButtonIsSharedAsTheFormFillerSharesIt: Acrobat's measured gaps for ten borders and three sizes,
    and its no-room case. ACaptionThatLeavesTheIconNoRoomIsAlone replaces
    ACaptionTooLargeForTheButtonIsDrawnAlone. The other layout tests now check Acrobat's rule
    (AcrobatButtonParts() in the test, plus explicit numbers in ACaptionAndAnIconEachTakeTheirPart).
  • New epdf_widget_text_size_embeddertest.cpp: a long value fills the width (Acrobat's 8.679), a
    short one fills the height, several lines stop at 12, a list box fits its widest option
    (Acrobat's 8.199 and 12), and the check's size.
  • EPDFRichTextLayoutEmbedderTest.FieldMatchesCpvt: at size 0 the fitted size is never under
    CPVT's step, and the characters are where CPVT puts them at that size.
  • EPDFAppearanceStateEmbedderTest.RadioButtonDrawsTheSymbolItsCaptionNames: the new operators.
  • Every new or changed test fails on 7f399f838 (built and run there); FieldMatchesCpvt passes on
    both.

Checked

  • macOS: unit 1415 passed. Embedder 1884 passed; the 12 known macOS golden failures fail as on the
    base. Saved-file checker over the run's 111 saves: passed. Pixel runner on the base and the
    branch: the same 51 failures of 224.
  • Layer mode for the changed suites: 77 pass, none failing only in layer mode; the writers list
    names the two new tests and drops the two old names; no other count moved.
  • check-fork-tags.py --strict, check-c-api.py (604 functions), check-globals.py on the macOS
    library: passed.
  • Linux (release image, the fork mounted into it): unit 1422 and embedder 1903 passed, none failed.
    Not run: check-globals.py on a Linux library (a full build under emulation); the macOS one passed.
  • Against Acrobat (platform output/picture-buttons-acrobat-check, round four): every 12 pt spacing
    column matches within 0.02 pt except the caption below the picture: a 0.40 pt higher strip and
    a 0.31 pt lower baseline at every border, and 0.52 pt lower when the picture has no room. Our
    caption line is the font's (Helvetica 14.03 high at 12), Acrobat's its own (13.63). Width-decided automatic sizes match within 0.2%; height-decided
    ones are about 5% larger than Acrobat's for the same reason. Border styles: every kind's row
    matches Acrobat's drawing.

Left

  • Release, and the pin in embed-pdf-viewer. The engine's own suites were not run on this runtime:
    tests that read a widget's drawing or an automatic size may move at the pin.
  • By Bob's choice (Nov 26), height-decided automatic sizes and the caption-below line follow each
    font's own measures, not Acrobat's Helvetica factors, so they stay about 5% larger and 0.3 to
    0.5 pt off there.
  • Not changed: a list box scrolled to its selection, Acrobat's light-blue highlight, the combo box
    arrow (Acrobat draws none).

…obat does

Acrobat 26 redrew our fields itself, and its saved drawings are the
reference:

- Check boxes, radio buttons and push buttons draw every border style:
  they share the text field's box (WriteFieldBox), and a radio button
  that shows a circle draws it in the middle of its box, as wide as the
  box is high, with beveled and inset edges as half circles and
  underline as the whole circle. BuildCheckboxBoxStream is gone.
- A beveled widget border's shaded edges are the background less a
  quarter, on every field kind (GenerateBorderAP takes the shade).
- A push button's picture is fitted twice the border's width in, and its
  caption sits where Acrobat puts it, with room that grows with the
  border (ButtonPlate, SplitButton). With no room left the picture is
  left out.
- A field's automatic size is the largest its text fits at, not a step
  of CPVT's ladder; a list box's fits its widest option, at most 12; a
  check box's check is as large as Acrobat's.
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