8220150: macos10.14 Mojave returns anti-aliased glyphs instead of aliased B&W glyphs

Reviewed-by: serb, kcr
This commit is contained in:
Phil Race 2020-04-06 12:01:34 -07:00
parent 38716935d2
commit 5a5e4bbfee
6 changed files with 52 additions and 4 deletions

@ -110,6 +110,16 @@ public class FontStrikeDesc {
* must therefore include device and font transforms.
*/
public static int getAAHintIntVal(Object aa, Font2D font2D, int ptSize) {
if (FontUtilities.isMacOSX14 &&
(aa == VALUE_TEXT_ANTIALIAS_OFF ||
aa == VALUE_TEXT_ANTIALIAS_DEFAULT ||
aa == VALUE_TEXT_ANTIALIAS_ON ||
aa == VALUE_TEXT_ANTIALIAS_GASP))
{
return INTVAL_TEXT_ANTIALIAS_ON;
}
if (aa == VALUE_TEXT_ANTIALIAS_OFF ||
aa == VALUE_TEXT_ANTIALIAS_DEFAULT) {
return INTVAL_TEXT_ANTIALIAS_OFF;
@ -142,6 +152,16 @@ public class FontStrikeDesc {
public static int getAAHintIntVal(Font2D font2D, Font font,
FontRenderContext frc) {
Object aa = frc.getAntiAliasingHint();
if (FontUtilities.isMacOSX14 &&
(aa == VALUE_TEXT_ANTIALIAS_OFF ||
aa == VALUE_TEXT_ANTIALIAS_DEFAULT ||
aa == VALUE_TEXT_ANTIALIAS_ON ||
aa == VALUE_TEXT_ANTIALIAS_GASP))
{
return INTVAL_TEXT_ANTIALIAS_ON;
}
if (aa == VALUE_TEXT_ANTIALIAS_OFF ||
aa == VALUE_TEXT_ANTIALIAS_DEFAULT) {
return INTVAL_TEXT_ANTIALIAS_OFF;

@ -49,6 +49,7 @@ public final class FontUtilities {
public static boolean isLinux;
public static boolean isMacOSX;
public static boolean isMacOSX14;
public static boolean useJDKScaler;
@ -71,7 +72,25 @@ public final class FontUtilities {
isLinux = osName.startsWith("Linux");
isMacOSX = osName.contains("OS X"); // TODO: MacOSX
if (isMacOSX) {
// os.version has values like 10.13.6, 10.14.6
// If it is not positively recognised as 10.13 or less,
// assume it means 10.14 or some later version.
isMacOSX14 = true;
String version = System.getProperty("os.version", "");
if (version.startsWith("10.")) {
version = version.substring(3);
int periodIndex = version.indexOf('.');
if (periodIndex != -1) {
version = version.substring(0, periodIndex);
}
try {
int v = Integer.parseInt(version);
isMacOSX14 = (v >= 14);
} catch (NumberFormatException e) {
}
}
}
/* If set to "jdk", use the JDK's scaler rather than
* the platform one. This may be a no-op on platforms where
* JDK has been configured so that it always relies on the

@ -771,6 +771,11 @@ public final class SunGraphics2D
}
}
}
if (FontUtilities.isMacOSX14 &&
(aahint == SunHints.INTVAL_TEXT_ANTIALIAS_OFF))
{
aahint = SunHints.INTVAL_TEXT_ANTIALIAS_ON;
}
info.aaHint = aahint;
info.fontStrike = info.font2D.getStrike(font, devAt, textAt,
aahint, fmhint);

@ -34,6 +34,7 @@ import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
import java.awt.image.Raster;
import sun.font.FontUtilities;
import sun.java2d.loops.RenderCache;
import sun.java2d.loops.RenderLoops;
import sun.java2d.loops.CompositeType;
@ -448,8 +449,12 @@ public abstract class SurfaceData
colorPrimitives = new LoopPipe();
outlineTextRenderer = new OutlineTextRenderer();
solidTextRenderer = new SolidTextRenderer();
aaTextRenderer = new AATextRenderer();
if (FontUtilities.isMacOSX14) {
solidTextRenderer = aaTextRenderer;
} else {
solidTextRenderer = new SolidTextRenderer();
}
lcdTextRenderer = new LCDTextRenderer();
colorPipe = new AlphaColorPipe();

@ -278,7 +278,6 @@ sun/java2d/SunGraphics2D/DrawImageBilinear.java 8191406 generic-all
sun/java2d/SunGraphics2D/PolyVertTest.java 6986565 generic-all
sun/java2d/SunGraphics2D/SimplePrimQuality.java 6992007 generic-all
sun/java2d/SunGraphics2D/SourceClippingBlitTest/SourceClippingBlitTest.java 8196185 generic-all
sun/java2d/loops/RenderToCustomBufferTest.java 8220150 macosx-all
sun/java2d/pipe/InterpolationQualityTest.java 8171303 windows-all,linux-all,macosx-all
sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh 8221451 linux-all
java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java 8169469 windows-all

@ -22,7 +22,7 @@
*/
/**
* @test
* @bug 8015606
* @bug 8015606 8220150
* @summary Test verifies whether a text is rendered correctly to
* a custom buffered image.
*