mirror of
https://github.com/openjdk/jdk.git
synced 2026-04-03 19:48:46 +00:00
8380028: Fix Page8 of manual test java/awt/print/PrinterJob/PrintTextTest.java on macOS
Reviewed-by: prr, psadhukhan
This commit is contained in:
parent
ce9b3b59aa
commit
cddee6d6eb
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.lwawt.macosx;
|
||||
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.font.*;
|
||||
|
||||
@ -73,12 +72,17 @@ public class CTextPipe implements TextPipe {
|
||||
|
||||
@Override
|
||||
public void drawString(final SunGraphics2D sg2d, final String s, final double x, final double y) {
|
||||
|
||||
FontInfo info = sg2d.getFontInfo();
|
||||
double dx = x + info.originX;
|
||||
double dy = y + info.originY;
|
||||
|
||||
final long nativeStrikePtr = getNativeStrikePtr(sg2d);
|
||||
if (OSXSurfaceData.IsSimpleColor(sg2d.paint) && nativeStrikePtr != 0) {
|
||||
final OSXSurfaceData surfaceData = (OSXSurfaceData)sg2d.getSurfaceData();
|
||||
surfaceData.drawString(this, sg2d, nativeStrikePtr, s, x, y);
|
||||
surfaceData.drawString(this, sg2d, nativeStrikePtr, s, dx, dy);
|
||||
} else {
|
||||
drawTextAsShape(sg2d, s, x, y);
|
||||
drawTextAsShape(sg2d, s, dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,6 +157,15 @@ public class CTextPipe implements TextPipe {
|
||||
final Font prevFont = sg2d.getFont();
|
||||
sg2d.setFont(gV.getFont());
|
||||
|
||||
int flags = gV.getLayoutFlags();
|
||||
boolean positionAdjustments = (flags & GlyphVector.FLAG_HAS_POSITION_ADJUSTMENTS) != 0;
|
||||
if (positionAdjustments) {
|
||||
// make sure GV positions are initialized, so they are available later in native code; this
|
||||
// will already be the case if the user explicitly set the glyph positions, but not if the
|
||||
// position adjustment flag was set because of a font translation transform or font tracking
|
||||
gV.getGlyphPosition(0);
|
||||
}
|
||||
|
||||
if (hasSlotData(gV)) {
|
||||
final int length = gV.getNumGlyphs();
|
||||
float[] positions = gV.getGlyphPositions(0, length, null);
|
||||
@ -177,12 +190,17 @@ public class CTextPipe implements TextPipe {
|
||||
|
||||
@Override
|
||||
public void drawChars(final SunGraphics2D sg2d, final char[] data, final int offset, final int length, final int x, final int y) {
|
||||
|
||||
FontInfo info = sg2d.getFontInfo();
|
||||
double dx = x + info.originX;
|
||||
double dy = y + info.originY;
|
||||
|
||||
final long nativeStrikePtr = getNativeStrikePtr(sg2d);
|
||||
if (OSXSurfaceData.IsSimpleColor(sg2d.paint) && nativeStrikePtr != 0) {
|
||||
final OSXSurfaceData surfaceData = (OSXSurfaceData)sg2d.getSurfaceData();
|
||||
surfaceData.drawUnicodes(this, sg2d, nativeStrikePtr, data, offset, length, x, y);
|
||||
surfaceData.drawUnicodes(this, sg2d, nativeStrikePtr, data, offset, length, (float) dx, (float) dy);
|
||||
} else {
|
||||
drawTextAsShape(sg2d, new String(data, offset, length), x, y);
|
||||
drawTextAsShape(sg2d, new String(data, offset, length), dx, dy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,7 +209,8 @@ public class CTextPipe implements TextPipe {
|
||||
}
|
||||
|
||||
public static final class Tracer extends CTextPipe {
|
||||
void doDrawString(final SurfaceData sData, final long nativeStrikePtr, final String s, final float x, final float y) {
|
||||
@Override
|
||||
public void doDrawString(final SurfaceData sData, final long nativeStrikePtr, final String s, final double x, final double y) {
|
||||
GraphicsPrimitive.tracePrimitive("QuartzDrawString");
|
||||
super.doDrawString(sData, nativeStrikePtr, s, x, y);
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1137,7 +1137,7 @@ public class AffineTransform implements Cloneable, java.io.Serializable {
|
||||
* The values are stored in the array as
|
||||
* { m00 m10 m01 m11 m02 m12 }.
|
||||
* An array of 4 doubles can also be specified, in which case only the
|
||||
* first four elements representing the non-transform
|
||||
* first four elements representing the non-translation
|
||||
* parts of the array are retrieved and the values are stored into
|
||||
* the array as { m00 m10 m01 m11 }
|
||||
* @param flatmatrix the double array used to store the returned
|
||||
|
||||
@ -596,7 +596,9 @@ public final class SunGraphics2D
|
||||
textAt.scale(ptSize, ptSize);
|
||||
info.originX = (float)textAt.getTranslateX();
|
||||
info.originY = (float)textAt.getTranslateY();
|
||||
textAt.translate(-info.originX, -info.originY);
|
||||
textAt.setTransform(textAt.getScaleX(), textAt.getShearY(),
|
||||
textAt.getShearX(), textAt.getScaleY(),
|
||||
0, 0);
|
||||
if (transformState >= TRANSFORM_TRANSLATESCALE) {
|
||||
transform.getMatrix(info.devTx = new double[4]);
|
||||
devAt = new AffineTransform(info.devTx);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2026, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6425068 7156751 7157659 8029204 8132890 8148334 8344637 8368702
|
||||
* @bug 6425068 7156751 7157659 8029204 8132890 8148334 8344637 8368702 8380028
|
||||
* @key printer
|
||||
* @summary Confirm that text prints where we expect to the length we expect.
|
||||
* @library /java/awt/regtesthelpers
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user