Repository navigation
Draw an overline as thick as the font's underline (#741) - #756
Open
gravitypdf-bot wants to merge 2 commits into
Open
gravitypdf-bot wants to merge 2 commits into
gravitypdf-bot wants to merge 2 commits into
Conversation
The overline block in Cell() divided the font key by the table's shrink factor and cast it to an integer, so it looked up font 0, never found the font's underline thickness or cap height, and fell back to 0.06 em and 700/1000 em. The size it measured those against was also left unshrunk. Read the key and size as the underline and line-through blocks do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Draw the overline and the underline in one document, and take the CSS modes from DrawnStyles rather than a copy of its provider. Co-Authored-By: Claude Opus 5.5 <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.
Fixes #741
Found while working on #552
Problem
text-decoration: overlineis drawn at a fixed 0.06 em, whatever the font, so it comes out heavier than the underline on the same text.underlineThickness(44/1000)underlineThicknessautosize)Cause
The
// OVERLINEblock inCell()read:The font key is a string such as
dejavuserifcondensed; casting it to a number gives0, so$this->fonts[0]was looked up, the font'sutandCapHeightwere never found, and the 60/1000 and 700/1000 fallbacks were always used. The/ $shrin_kthat belongs on the size was on the key, so in a shrunk table the overline was measured at the unshrunk size.Fix
Read the key and size as the underline and line-through blocks do: the key as is, the size divided by
$shrin_k. The overline now takes the font's underline thickness, sits at the font's cap height (729/1000 for DejaVu Serif Condensed, rather than the 700 fallback, so it moves up slightly), and shrinks with its table.Based on
gravitypdf: #722 edits the same overline block, but only the lines after these two, so the two apply independently.Legacy mode
This is a plain bug fix, so it applies in both
cssModes.Tests
tests/Mpdf/OverlineThicknessTest.php: in both modes, an overline at 40pt is drawn at the font's underline thickness, the same width as the underline, for a TrueType font (DejaVu Serif Condensed, 1.76 pt) and a core font (Times, 2.0 pt); and in a table shrunk to fit, the overline is thinned to the same width as the underline. All fail before the fix.overline-thickness: DejaVu Serif Condensed and DejaVu Sans Condensed text at 40pt with underline, overline and both, and a table shrunk to fit with both lines; each caption says the lines match. Fails before the fix (page RMSE 0.0587).decorations-amendment-legacy,decorations-amendment-standardanddecorations-propagate: each draws overlined text, and the only change in their objects is the overline's width (0.720 → 0.528, 0.600 → 0.440) and its height on the page. Checked page by page.Checks
composer test: OK, 12739 tests (31 skipped, none of them snapshots;--group snapshot219 OK)composer cs: cleangravitypdf(stale baseline, Regenerate the PHPStan baseline for PHPStan 2.3, so the Lint job passes again #716), none new🤖 Generated with Claude Code