Repository navigation
Draw a text outline with no colour in the colour of its text - #681
Merged
Merged
Conversation
27 of 28 tasks
text-outline-width without a text-outline-color read a colour that was never set and raised an undefined-key warning. In standard mode the outline now takes the colour of each piece of text, as text-outline-color is currentColor by default; the text-outline shorthand with a width alone draws it too, and currentColor written in text-outline-color is passed on as the keyword. Legacy mode keeps the stroke colour it drew in before, without the warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
jakejackson1
force-pushed
the
fix/650-text-outline-default-colour
branch
from
October 6, 2026 04:12
ceacdaf to
577de55
Compare
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 #650
Part of #552, part of #520
Problem
text-outline-widthwith notext-outline-colorraised a warning when the document was written:The outline was stroked in black, whatever the colour of the text. In a browser,
-webkit-text-stroke-color, the nearest CSS equivalent, defaults tocurrentColor, the colour of the text.Two related cases, measured on
gravitypdf:p { color: #0a0; text-outline-width: 0.2mm }p { color: #0a0; text-outline: 0.2mm }p { color: #0a0; text-outline: 0.2mm currentColor }with<span style="color: #00f">insideCause
SetTextOutline()read$params['outline-COLOR']unconditionally. Only atext-outline-colordeclaration sets that key, so an outline given a width alone read a key that was never set, andSetDColor(null)left the stroke colour as it was. In practice that was the black that resets at the start of each block.Fix
Mpdf::SetTextOutline()takes the colour of the text run as a second argument.printbuffer()passes the run's colour ($vetor[3]). With no outline colour, standard mode strokes in that colour, or black when the text has none. Legacy mode leaves the stroke colour as it was, so its output stays byte-identical, without the warning. The colour is resolved at draw time, not at merge time, becausetext-outline-coloris inherited and mPDF passes it to inline content throughtextparam. Each piece of text then gets its own colour.text-outline-color: currentColoris no longer resolved to a fixed colour inCssMergerunder standard mode. It moved fromCURRENT_COLOR_PROPERTIESto a newLEGACY_CURRENT_COLOR_PROPERTIES.setCSS()reads the keyword as "no outline colour", which clears any colour inherited from an ancestor, and the draw-time default then applies. A writtencurrentColortherefore behaves the same as the default, and a descendant of another colour is outlined in its own colour, as CSS inheritscurrentColoras the keyword. Legacy mode resolves it at merge as Draw currentColor, and a border or shadow with no colour, in the element's colour #651 does.text-outlineshorthand with a width alone (text-outline: 0.2mm) sets the width and resets the colour tocurrentColorin standard mode, as a shorthand resets the parts it does not name (resetsOmittedParts()). Legacy mode ignores it, as before.Legacy mode
Legacy output does not change. The warning is gone, the outline keeps the stroke colour already set (black), the one-value shorthand is still ignored, and a written
currentColoris still resolved at the element. No snapshot fixture changed.Tests
In
CurrentColorTest, through itsuncompressed()helper, which fails on any warning or notice:<span>outlines the span in blue and the rest in green. This holds for a width with no colour, the one-value shorthand, the shorthand after a colour, and a writtencurrentColor.testEveryColourPropertyResolvesCurrentColornow expects standard mode to keepcurrentcolorinTEXT-OUTLINE-COLOR.With the
src/changes reverted, 29 of these cases fail.Checks
vendor/bin/phpunit --exclude-group snapshot: OK, 11948 tests, 31 skippedvendor/bin/phpunit --group snapshot: OK, 208 tests, no fixture changedcomposer cs: clean--memory-limit=2G): no errorsphp -lon PHP 5.6 (docker) for each changed file: no syntax errors🤖 Generated with Claude Code