On Thu, 10 Feb 2022 11:36:38 GMT, Jay Bhaskar <d...@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) Looking at the GraphicsContexCG source, we can see that the It looks correct to call fill rect instead of draw line. The GraphicsContexJava implementation seems to be the cause of the underline tilt. Also, there seems to be no need to call drawLine() multiple times by referring to last(). ``` cpp void GraphicsContextCG::drawLinesForText(const FloatPoint& point, float thickness, const DashArray& widths, bool printing, bool doubleLines, StrokeStyle strokeStyle) { if (!widths.size()) return; Color localStrokeColor(strokeColor()); FloatRect bounds = computeLineBoundsAndAntialiasingModeForText(FloatRect(point, FloatSize(widths.last(), thickness)), printing, localStrokeColor); if (bounds.isEmpty()) return; bool fillColorIsNotEqualToStrokeColor = fillColor() != localStrokeColor; Vector<CGRect, 4> dashBounds; ASSERT(!(widths.size() % 2)); dashBounds.reserveInitialCapacity(dashBounds.size() / 2); float dashWidth = 0; switch (strokeStyle) { case DottedStroke: dashWidth = bounds.height(); break; case DashedStroke: dashWidth = 2 * bounds.height(); break; case SolidStroke: default: break; } for (size_t i = 0; i < widths.size(); i += 2) { auto left = widths[i]; auto width = widths[i+1] - widths[i]; if (!dashWidth) dashBounds.append(CGRectMake(bounds.x() + left, bounds.y(), width, bounds.height())); else { auto startParticle = static_cast<int>(std::ceil(left / (2 * dashWidth))); auto endParticle = static_cast<int>((left + width) / (2 * dashWidth)); for (auto j = startParticle; j < endParticle; ++j) dashBounds.append(CGRectMake(bounds.x() + j * 2 * dashWidth, bounds.y(), dashWidth, bounds.height())); } } if (doubleLines) { // The space between double underlines is equal to the height of the underline for (size_t i = 0; i < widths.size(); i += 2) dashBounds.append(CGRectMake(bounds.x() + widths[i], bounds.y() + 2 * bounds.height(), widths[i+1] - widths[i], bounds.height())); } if (fillColorIsNotEqualToStrokeColor) setCGFillColor(platformContext(), localStrokeColor); CGContextFillRects(platformContext(), dashBounds.data(), dashBounds.size()); if (fillColorIsNotEqualToStrokeColor) setCGFillColor(platformContext(), fillColor()); } ------------- PR: https://git.openjdk.java.net/jfx/pull/731