Skip to content
Permalink
Browse files
8220150: macos10.14 Mojave returns anti-aliased glyphs instead of ali…
…ased B&W glyphs

Reviewed-by: serb, kcr
  • Loading branch information
prrace committed Apr 6, 2020
1 parent 3871693 commit 5a5e4bbfeef36a9fda074eb42702f878042408d2
Showing 6 changed files with 52 additions and 4 deletions.
@@ -110,6 +110,16 @@ public boolean equals(Object obj) {
* 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 static int getAAHintIntVal(Object aa, Font2D font2D, int ptSize) {
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 Object run() {
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 FontInfo checkFontInfo(FontInfo info, Font font,
}
}
}
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.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 PixelToPgramLoopConverter(ShapeDrawPipe shapepipe,
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.
*

0 comments on commit 5a5e4bb

Please sign in to comment.