WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
171805
SVG textLength not working correctly
https://bugs.webkit.org/show_bug.cgi?id=171805
Summary
SVG textLength not working correctly
Jason Davies
Reported
2017-05-08 08:51:20 PDT
Created
attachment 309363
[details]
Minimal demonstration of textLength bug. Open the attached bug.svg file, containing <text textLength="1200">test</text>. Notice how the right-hand edge of the text does not line up with the red rectangle. I've reported the same bug for Chrome:
https://bugs.chromium.org/p/chromium/issues/detail?id=719522
FireFox exhibits the correct behaviour.
Attachments
Minimal demonstration of textLength bug.
(264 bytes, image/svg+xml)
2017-05-08 08:51 PDT
,
Jason Davies
no flags
Details
Patch
(3.20 KB, patch)
2022-06-02 07:11 PDT
,
Tom Bigelajzen
tombigel
: review?
ews-feeder
: commit-queue-
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2017-05-08 19:45:13 PDT
<
rdar://problem/32066826
>
Tom Bigelajzen
Comment 2
2022-06-02 07:11:17 PDT
Created
attachment 459960
[details]
Patch
Tom Bigelajzen
Comment 3
2022-06-02 07:17:27 PDT
I created a minimal patch for this bug without tests etc. just to show that it's fixable by copying the logic from the Chromium bug fix from 5 years ago. I don't have the time or knowledge to go through all the way with this patch (tests etc.) and will appreciate if someone with the right knowledge could complete the last mile with this fix
Said Abou-Hallawa
Comment 4
2022-09-06 13:46:18 PDT
Comment on
attachment 459960
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=459960&action=review
> Source/WebCore/rendering/svg/SVGTextChunk.cpp:147 > + float textLengthShift = desiredTextLength() - totalLength(); > + if (totalCharacters() > 1) { > + textLengthShift /= totalCharacters() - 1; > + }
I think this code should look like this: float textLengthShift = 0; if (totalCharacters() > 1) textLengthShift = (desiredTextLength() - totalLength()) / (totalCharacters() - 1);
> Source/WebCore/rendering/svg/SVGTextLayoutEngine.cpp:210 > - if (textContentElement->lengthAdjust() == SVGLengthAdjustSpacing) > - m_textPathSpacing = (desiredTextLength - totalLength) / totalCharacters; > + if (textContentElement->lengthAdjust() == SVGLengthAdjustSpacing && totalCharacters > 1) > + m_textPathSpacing = (desiredTextLength - totalLength) / (totalCharacters - 1); > else > m_textPathScaling = desiredTextLength / totalLength;
I think this if-statement should be like this: if (textContentElement->lengthAdjust() == SVGLengthAdjustSpacing) { if (totalCharacters > 1) m_textPathSpacing = (desiredTextLength - totalLength) / (totalCharacters - 1); } else m_textPathScaling = desiredTextLength / totalLength;
Said Abou-Hallawa
Comment 5
2022-09-06 13:48:02 PDT
(In reply to Tom Bigelajzen from
comment #3
)
> I created a minimal patch for this bug without tests etc. just to show that > it's fixable by copying the logic from the Chromium bug fix from 5 years ago. > > I don't have the time or knowledge to go through all the way with this patch > (tests etc.) and will appreciate if someone with the right knowledge could > complete the last mile with this fix
The failed tests need to be rebaslined since the inter-character spacing width has changed.
Ahmad Saleem
Comment 6
2023-01-14 02:50:41 PST
PR -
https://github.com/WebKit/WebKit/pull/8655
Let's try.. @Said - I already took your review of this patch and incorporated it. :-)
EWS
Comment 7
2023-01-14 13:29:22 PST
Committed
258921@main
(5c38a23d96c2): <
https://commits.webkit.org/258921@main
> Reviewed commits have been landed. Closing PR #8655 and removing active labels.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug