[Webkit-unassigned] [Bug 171805] SVG textLength not working correctly

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Sep 6 13:46:18 PDT 2022


https://bugs.webkit.org/show_bug.cgi?id=171805

--- Comment #4 from Said Abou-Hallawa <sabouhallawa at apple.com> ---
Comment on attachment 459960
  --> https://bugs.webkit.org/attachment.cgi?id=459960
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;

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220906/9d7b7fd4/attachment.htm>


More information about the webkit-unassigned mailing list