modules/graphics/src/main/java/com/sun/javafx/sg/prism/NGCanvas.java
Print this page
rev 7082 : RT-37148: [Graphics, Text, Canvas] Draw gradient text broken for Canvas.
*** 1297,1326 ****
}
if (gr != null) {
if (maxWidth > 0.0 && layoutWidth > maxWidth) {
float sx = maxWidth / layoutWidth;
if (rtl) {
! x += maxWidth;
! gr.translate(x - xAlign * sx, y - yAlign);
gr.scale(-sx, 1);
} else {
gr.translate(x - xAlign * sx, y - yAlign);
gr.scale(sx, 1);
}
- ngtext.setLayoutLocation(0, 0);
} else {
if (rtl) {
! x = -(x + layoutWidth);
! xAlign = -xAlign;
gr.scale(-1, 1);
}
- ngtext.setLayoutLocation(xAlign - x, yAlign - y);
}
if (token == FILL_TEXT) {
ngtext.setMode(NGShape.Mode.FILL);
ngtext.setFillPaint(fillPaint);
} else {
ngtext.setMode(NGShape.Mode.STROKE);
ngtext.setDrawStroke(getStroke());
ngtext.setDrawPaint(strokePaint);
}
ngtext.setFont(pgfont);
--- 1297,1337 ----
}
if (gr != null) {
if (maxWidth > 0.0 && layoutWidth > maxWidth) {
float sx = maxWidth / layoutWidth;
if (rtl) {
! gr.translate(x + maxWidth - xAlign * sx, y - yAlign);
gr.scale(-sx, 1);
} else {
gr.translate(x - xAlign * sx, y - yAlign);
gr.scale(sx, 1);
}
} else {
if (rtl) {
! gr.translate(x + layoutWidth - xAlign, y - yAlign);
gr.scale(-1, 1);
+ } else {
+ gr.translate(x - xAlign, y - yAlign);
}
}
if (token == FILL_TEXT) {
ngtext.setMode(NGShape.Mode.FILL);
ngtext.setFillPaint(fillPaint);
+ if (fillPaint.getType() == Paint.Type.LINEAR_GRADIENT && fillPaint.isProportional()) {
+ ngtext.setContentBounds(new RectBounds(0, 0, layoutWidth, layoutHeight));
+ }
} else {
+ if (strokePaint.getType() == Paint.Type.LINEAR_GRADIENT && strokePaint.isProportional()) {
+ int flag = PrismTextLayout.TYPE_TEXT;
+ Shape textShape = textLayout.getShape(flag, null);
+ RectBounds shapeBounds = new RectBounds();
+ strokebounds(getStroke(), textShape, shapeBounds, BaseTransform.IDENTITY_TRANSFORM);
+ RectBounds textBounds = new RectBounds();
+ textLayout.getBounds(null, textBounds);
+ textBounds.unionWith(shapeBounds);
+ ngtext.setContentBounds(textBounds);
+ }
ngtext.setMode(NGShape.Mode.STROKE);
ngtext.setDrawStroke(getStroke());
ngtext.setDrawPaint(strokePaint);
}
ngtext.setFont(pgfont);