RFR: 8280020: Underline and line-through not straight in WebView

Kevin Rushforth kcr at openjdk.java.net
Sat Feb 12 17:45:08 UTC 2022


On Thu, 10 Feb 2022 11:36:38 GMT, Jay Bhaskar <duke at openjdk.java.net> wrote:

> Issue: The end point of  line in drawLinesForText , add thickness to the endPoint.y(). In this case origin which is start point and the end point would not be same, and line would be drawn not straight.
> Solution: Do not add thickness to the y position of end point of line.
> Start Point(x,y) ----------End Point(x + width, 0)

The fix for thickness seems to be as easy as saving the current thickness and setting the value to the thickness argument, and then restoring it, similarly to what is done for `StrokeStyle`. I did a quick test of that and the line thickness now matches Safari and Firefox. The positioning is off by what looks like 1/2 thickness, which would make sense if the values passed in were for the upper end of the (thick) line rather than the center, which is what drawLine expects. Adjusting both the start and end points by `thickness/2` makes WebView match the two browsers.

So the following might be the fix for both the slanted lines, and the fact that we ignore thickness:



        StrokeStyle savedStrokeStyle = strokeStyle();
        setStrokeStyle(stroke);
        float savedStrokeThickness = strokeThickness();
        setStrokeThickness(thickness);

        FloatPoint startPoint = origin + FloatPoint(0, thickness / 2);
        FloatPoint endPoint = startPoint + FloatPoint(width, 0);
        drawLine(
            IntPoint(startPoint.x(), startPoint.y()),
            IntPoint(endPoint.x(), endPoint.y()));

        setStrokeStyle(savedStrokeStyle);
        setStrokeThickness(savedStrokeThickness);


We would need to confirm my hypothesis that the position of the line should be adjusted like this.

-------------

PR: https://git.openjdk.java.net/jfx/pull/731


More information about the openjfx-dev mailing list