6930980: Disable TrueType hinting for fonts known not to hint well
authorprr
Fri, 14 Jan 2011 15:07:48 -0800
changeset 7940 7d20d72dd3b9
parent 7939 4b122be94252
child 7941 e71443fb9af6
6930980: Disable TrueType hinting for fonts known not to hint well Reviewed-by: igor, jgodinez
jdk/src/share/classes/sun/font/FileFontStrike.java
jdk/src/share/classes/sun/font/FontScaler.java
jdk/src/share/classes/sun/font/FreetypeFontScaler.java
jdk/src/share/classes/sun/font/NullFontScaler.java
--- a/jdk/src/share/classes/sun/font/FileFontStrike.java	Fri Jan 14 14:25:47 2011 -0800
+++ b/jdk/src/share/classes/sun/font/FileFontStrike.java	Fri Jan 14 15:07:48 2011 -0800
@@ -151,6 +151,23 @@
             }
         }
 
+        /* Amble fonts are better rendered unhinted although there's the
+         * inevitable fuzziness that accompanies this due to no longer
+         * snapping stems to the pixel grid. The exception is that in B&W
+         * mode they are worse without hinting. The down side to that is that
+         * B&W metrics will differ which normally isn't the case, although
+         * since AA mode is part of the measuring context that should be OK.
+         * We don't expect Amble to be installed in the Windows fonts folder.
+         * If we were to, then we'd also might want to disable using the
+         * native rasteriser path which is used for LCD mode for platform
+         * fonts. since we have no way to disable hinting by GDI.
+         * In the case of Amble, since its 'gasp' table says to disable
+         * hinting, I'd expect GDI to follow that, so likely it should
+         * all be consistent even if GDI used.
+         */
+        boolean disableHinting = desc.aaHint != INTVAL_TEXT_ANTIALIAS_OFF &&
+                                 fileFont.familyName.startsWith("Amble");
+
         /* If any of the values is NaN then substitute the null scaler context.
          * This will return null images, zero advance, and empty outlines
          * as no rendering need take place in this case.
@@ -165,7 +182,7 @@
             pScalerContext = fileFont.getScaler().createScalerContext(matrix,
                                     fileFont instanceof TrueTypeFont,
                                     desc.aaHint, desc.fmHint,
-                                    boldness, italic);
+                                    boldness, italic, disableHinting);
         }
 
         mapper = fileFont.getMapper();
--- a/jdk/src/share/classes/sun/font/FontScaler.java	Fri Jan 14 14:25:47 2011 -0800
+++ b/jdk/src/share/classes/sun/font/FontScaler.java	Fri Jan 14 15:07:48 2011 -0800
@@ -242,9 +242,10 @@
         freed when corresponding strike is being released.
      */
     abstract long createScalerContext(double[] matrix,
-                        boolean fontType,
-                        int aa, int fm,
-                        float boldness, float italic);
+                                      boolean fontType,
+                                      int aa, int fm,
+                                      float boldness, float italic,
+                                      boolean disableHinting);
 
     /* Marks context as invalid because native scaler is invalid.
        Notes:
--- a/jdk/src/share/classes/sun/font/FreetypeFontScaler.java	Fri Jan 14 14:25:47 2011 -0800
+++ b/jdk/src/share/classes/sun/font/FreetypeFontScaler.java	Fri Jan 14 15:07:48 2011 -0800
@@ -211,7 +211,8 @@
     }
 
     long createScalerContext(double[] matrix, boolean fontType,
-            int aa, int fm, float boldness, float italic) {
+            int aa, int fm, float boldness, float italic,
+            boolean disableHinting) {
         if (nativeScaler != 0L) {
             return createScalerContextNative(nativeScaler, matrix,
                       fontType, aa, fm, boldness, italic);
--- a/jdk/src/share/classes/sun/font/NullFontScaler.java	Fri Jan 14 14:25:47 2011 -0800
+++ b/jdk/src/share/classes/sun/font/NullFontScaler.java	Fri Jan 14 15:07:48 2011 -0800
@@ -67,7 +67,7 @@
     long getLayoutTableCache() {return 0L;}
 
     long createScalerContext(double[] matrix, boolean fontType, int aa,
-        int fm, float boldness, float italic) {
+        int fm, float boldness, float italic, boolean disableHinting) {
         return getNullScalerContext();
     }