Skip to content

Commit 5a5e4bb

Browse files
committed
8220150: macos10.14 Mojave returns anti-aliased glyphs instead of aliased B&W glyphs
Reviewed-by: serb, kcr
1 parent 3871693 commit 5a5e4bb

6 files changed

Lines changed: 52 additions & 4 deletions

File tree

src/java.desktop/share/classes/sun/font/FontStrikeDesc.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@ public boolean equals(Object obj) {
110110
* must therefore include device and font transforms.
111111
*/
112112
public static int getAAHintIntVal(Object aa, Font2D font2D, int ptSize) {
113+
114+
if (FontUtilities.isMacOSX14 &&
115+
(aa == VALUE_TEXT_ANTIALIAS_OFF ||
116+
aa == VALUE_TEXT_ANTIALIAS_DEFAULT ||
117+
aa == VALUE_TEXT_ANTIALIAS_ON ||
118+
aa == VALUE_TEXT_ANTIALIAS_GASP))
119+
{
120+
return INTVAL_TEXT_ANTIALIAS_ON;
121+
}
122+
113123
if (aa == VALUE_TEXT_ANTIALIAS_OFF ||
114124
aa == VALUE_TEXT_ANTIALIAS_DEFAULT) {
115125
return INTVAL_TEXT_ANTIALIAS_OFF;
@@ -142,6 +152,16 @@ public static int getAAHintIntVal(Object aa, Font2D font2D, int ptSize) {
142152
public static int getAAHintIntVal(Font2D font2D, Font font,
143153
FontRenderContext frc) {
144154
Object aa = frc.getAntiAliasingHint();
155+
156+
if (FontUtilities.isMacOSX14 &&
157+
(aa == VALUE_TEXT_ANTIALIAS_OFF ||
158+
aa == VALUE_TEXT_ANTIALIAS_DEFAULT ||
159+
aa == VALUE_TEXT_ANTIALIAS_ON ||
160+
aa == VALUE_TEXT_ANTIALIAS_GASP))
161+
{
162+
return INTVAL_TEXT_ANTIALIAS_ON;
163+
}
164+
145165
if (aa == VALUE_TEXT_ANTIALIAS_OFF ||
146166
aa == VALUE_TEXT_ANTIALIAS_DEFAULT) {
147167
return INTVAL_TEXT_ANTIALIAS_OFF;

src/java.desktop/share/classes/sun/font/FontUtilities.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public final class FontUtilities {
4949
public static boolean isLinux;
5050

5151
public static boolean isMacOSX;
52+
public static boolean isMacOSX14;
5253

5354
public static boolean useJDKScaler;
5455

@@ -71,7 +72,25 @@ public Object run() {
7172
isLinux = osName.startsWith("Linux");
7273

7374
isMacOSX = osName.contains("OS X"); // TODO: MacOSX
74-
75+
if (isMacOSX) {
76+
// os.version has values like 10.13.6, 10.14.6
77+
// If it is not positively recognised as 10.13 or less,
78+
// assume it means 10.14 or some later version.
79+
isMacOSX14 = true;
80+
String version = System.getProperty("os.version", "");
81+
if (version.startsWith("10.")) {
82+
version = version.substring(3);
83+
int periodIndex = version.indexOf('.');
84+
if (periodIndex != -1) {
85+
version = version.substring(0, periodIndex);
86+
}
87+
try {
88+
int v = Integer.parseInt(version);
89+
isMacOSX14 = (v >= 14);
90+
} catch (NumberFormatException e) {
91+
}
92+
}
93+
}
7594
/* If set to "jdk", use the JDK's scaler rather than
7695
* the platform one. This may be a no-op on platforms where
7796
* JDK has been configured so that it always relies on the

src/java.desktop/share/classes/sun/java2d/SunGraphics2D.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,11 @@ public FontInfo checkFontInfo(FontInfo info, Font font,
771771
}
772772
}
773773
}
774+
if (FontUtilities.isMacOSX14 &&
775+
(aahint == SunHints.INTVAL_TEXT_ANTIALIAS_OFF))
776+
{
777+
aahint = SunHints.INTVAL_TEXT_ANTIALIAS_ON;
778+
}
774779
info.aaHint = aahint;
775780
info.fontStrike = info.font2D.getStrike(font, devAt, textAt,
776781
aahint, fmhint);

src/java.desktop/share/classes/sun/java2d/SurfaceData.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import java.awt.image.IndexColorModel;
3535
import java.awt.image.Raster;
3636

37+
import sun.font.FontUtilities;
3738
import sun.java2d.loops.RenderCache;
3839
import sun.java2d.loops.RenderLoops;
3940
import sun.java2d.loops.CompositeType;
@@ -448,8 +449,12 @@ public PixelToPgramLoopConverter(ShapeDrawPipe shapepipe,
448449
colorPrimitives = new LoopPipe();
449450

450451
outlineTextRenderer = new OutlineTextRenderer();
451-
solidTextRenderer = new SolidTextRenderer();
452452
aaTextRenderer = new AATextRenderer();
453+
if (FontUtilities.isMacOSX14) {
454+
solidTextRenderer = aaTextRenderer;
455+
} else {
456+
solidTextRenderer = new SolidTextRenderer();
457+
}
453458
lcdTextRenderer = new LCDTextRenderer();
454459

455460
colorPipe = new AlphaColorPipe();

test/jdk/ProblemList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ sun/java2d/SunGraphics2D/DrawImageBilinear.java 8191406 generic-all
278278
sun/java2d/SunGraphics2D/PolyVertTest.java 6986565 generic-all
279279
sun/java2d/SunGraphics2D/SimplePrimQuality.java 6992007 generic-all
280280
sun/java2d/SunGraphics2D/SourceClippingBlitTest/SourceClippingBlitTest.java 8196185 generic-all
281-
sun/java2d/loops/RenderToCustomBufferTest.java 8220150 macosx-all
282281
sun/java2d/pipe/InterpolationQualityTest.java 8171303 windows-all,linux-all,macosx-all
283282
sun/java2d/X11SurfaceData/SharedMemoryPixmapsTest/SharedMemoryPixmapsTest.sh 8221451 linux-all
284283
java/awt/FullScreen/DisplayChangeVITest/DisplayChangeVITest.java 8169469 windows-all

test/jdk/sun/java2d/loops/RenderToCustomBufferTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
/**
2424
* @test
25-
* @bug 8015606
25+
* @bug 8015606 8220150
2626
* @summary Test verifies whether a text is rendered correctly to
2727
* a custom buffered image.
2828
*

0 commit comments

Comments
 (0)