1282 float sx = maxWidth / layoutWidth;
1283 TEMP_TX.translate(x - xAlign * sx, y - yAlign);
1284 TEMP_TX.scale(sx, 1);
1285 } else {
1286 TEMP_TX.translate(x - xAlign, y - yAlign);
1287 }
1288 textLayout.getBounds(null, bounds);
1289 TEMP_TX.transform(bounds, bounds);
1290 if (token == STROKE_TEXT) {
1291 int flag = PrismTextLayout.TYPE_TEXT;
1292 Shape textShape = textLayout.getShape(flag, null);
1293 RectBounds shapeBounds = new RectBounds();
1294 strokebounds(getStroke(), textShape, shapeBounds, TEMP_TX);
1295 bounds.unionWith(shapeBounds);
1296 }
1297 }
1298 if (gr != null) {
1299 if (maxWidth > 0.0 && layoutWidth > maxWidth) {
1300 float sx = maxWidth / layoutWidth;
1301 if (rtl) {
1302 x += maxWidth;
1303 gr.translate(x - xAlign * sx, y - yAlign);
1304 gr.scale(-sx, 1);
1305 } else {
1306 gr.translate(x - xAlign * sx, y - yAlign);
1307 gr.scale(sx, 1);
1308 }
1309 ngtext.setLayoutLocation(0, 0);
1310 } else {
1311 if (rtl) {
1312 x = -(x + layoutWidth);
1313 xAlign = -xAlign;
1314 gr.scale(-1, 1);
1315 }
1316 ngtext.setLayoutLocation(xAlign - x, yAlign - y);
1317 }
1318 if (token == FILL_TEXT) {
1319 ngtext.setMode(NGShape.Mode.FILL);
1320 ngtext.setFillPaint(fillPaint);
1321 } else {
1322 ngtext.setMode(NGShape.Mode.STROKE);
1323 ngtext.setDrawStroke(getStroke());
1324 ngtext.setDrawPaint(strokePaint);
1325 }
1326 ngtext.setFont(pgfont);
1327 ngtext.setGlyphs(textLayout.getRuns());
1328 ngtext.renderContent(gr);
1329 }
1330 break;
1331 }
1332 default:
1333 throw new InternalError("Unrecognized PGCanvas rendering token: "+token);
1334 }
1335 if (bounds != null) {
1336 if (strokeBounds) {
1337 BasicStroke s = getStroke();
1338 if (s.getType() != BasicStroke.TYPE_INNER) {
1339 float lw = s.getLineWidth();
1340 if (s.getType() == BasicStroke.TYPE_CENTERED) {
1341 lw /= 2f;
|
1282 float sx = maxWidth / layoutWidth;
1283 TEMP_TX.translate(x - xAlign * sx, y - yAlign);
1284 TEMP_TX.scale(sx, 1);
1285 } else {
1286 TEMP_TX.translate(x - xAlign, y - yAlign);
1287 }
1288 textLayout.getBounds(null, bounds);
1289 TEMP_TX.transform(bounds, bounds);
1290 if (token == STROKE_TEXT) {
1291 int flag = PrismTextLayout.TYPE_TEXT;
1292 Shape textShape = textLayout.getShape(flag, null);
1293 RectBounds shapeBounds = new RectBounds();
1294 strokebounds(getStroke(), textShape, shapeBounds, TEMP_TX);
1295 bounds.unionWith(shapeBounds);
1296 }
1297 }
1298 if (gr != null) {
1299 if (maxWidth > 0.0 && layoutWidth > maxWidth) {
1300 float sx = maxWidth / layoutWidth;
1301 if (rtl) {
1302 gr.translate(x + maxWidth - xAlign * sx, y - yAlign);
1303 gr.scale(-sx, 1);
1304 } else {
1305 gr.translate(x - xAlign * sx, y - yAlign);
1306 gr.scale(sx, 1);
1307 }
1308 } else {
1309 if (rtl) {
1310 gr.translate(x + layoutWidth - xAlign, y - yAlign);
1311 gr.scale(-1, 1);
1312 } else {
1313 gr.translate(x - xAlign, y - yAlign);
1314 }
1315 }
1316 if (token == FILL_TEXT) {
1317 ngtext.setMode(NGShape.Mode.FILL);
1318 ngtext.setFillPaint(fillPaint);
1319 if (fillPaint.getType() == Paint.Type.LINEAR_GRADIENT && fillPaint.isProportional()) {
1320 ngtext.setContentBounds(new RectBounds(0, 0, layoutWidth, layoutHeight));
1321 }
1322 } else {
1323 if (strokePaint.getType() == Paint.Type.LINEAR_GRADIENT && strokePaint.isProportional()) {
1324 int flag = PrismTextLayout.TYPE_TEXT;
1325 Shape textShape = textLayout.getShape(flag, null);
1326 RectBounds shapeBounds = new RectBounds();
1327 strokebounds(getStroke(), textShape, shapeBounds, BaseTransform.IDENTITY_TRANSFORM);
1328 RectBounds textBounds = new RectBounds();
1329 textLayout.getBounds(null, textBounds);
1330 textBounds.unionWith(shapeBounds);
1331 ngtext.setContentBounds(textBounds);
1332 }
1333 ngtext.setMode(NGShape.Mode.STROKE);
1334 ngtext.setDrawStroke(getStroke());
1335 ngtext.setDrawPaint(strokePaint);
1336 }
1337 ngtext.setFont(pgfont);
1338 ngtext.setGlyphs(textLayout.getRuns());
1339 ngtext.renderContent(gr);
1340 }
1341 break;
1342 }
1343 default:
1344 throw new InternalError("Unrecognized PGCanvas rendering token: "+token);
1345 }
1346 if (bounds != null) {
1347 if (strokeBounds) {
1348 BasicStroke s = getStroke();
1349 if (s.getType() != BasicStroke.TYPE_INNER) {
1350 float lw = s.getLineWidth();
1351 if (s.getType() == BasicStroke.TYPE_CENTERED) {
1352 lw /= 2f;
|