8164818: Reg. test java/awt/font/TextLayout/VisibleAdvance.java fails
authorprr
Wed, 31 Aug 2016 13:40:06 -0700
changeset 40988 cc334ef95225
parent 40987 eb13c2ec3f9a
child 40989 0a9030f6613d
8164818: Reg. test java/awt/font/TextLayout/VisibleAdvance.java fails Reviewed-by: serb, psadhukhan
jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c
jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc
jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h
jdk/test/java/awt/font/TextLayout/VisibleAdvance.java
--- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c	Wed Aug 31 12:49:03 2016 +0300
+++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c	Wed Aug 31 13:40:06 2016 -0700
@@ -78,7 +78,7 @@
     int i;
     float x=0, y=0;
     float startX, startY;
-    float scale = 1.0f/64.0f/devScale;
+    float scale = 1.0f / FloatToFixedScale / devScale;
     unsigned int* glyphs;
     float* positions;
     int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv;
--- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc	Wed Aug 31 12:49:03 2016 +0300
+++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc	Wed Aug 31 13:40:06 2016 -0700
@@ -55,10 +55,6 @@
     return (*glyph != 0);
 }
 
-// This is also define in freetypescaler.c and similar macros are
-// in fontscalerdefs.h. Consider tidying this up.
-#define FloatToF26Dot6(x) ((unsigned int) ((x)*64))
-
 static hb_position_t
 hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED,
 			   void *font_data,
@@ -84,7 +80,7 @@
     fadv *= jdkFontInfo->devScale;
     env->DeleteLocalRef(pt);
 
-    return FloatToF26Dot6(fadv); // should this round ?
+    return FloatToFixed(fadv);
 }
 
 static hb_position_t
@@ -111,7 +107,7 @@
     fadv = env->GetFloatField(pt, sunFontIDs.yFID);
     env->DeleteLocalRef(pt);
 
-    return FloatToF26Dot6(fadv); // should this round ?
+    return FloatToFixed(fadv);
   
 }
 
@@ -205,8 +201,8 @@
         *x = 0; *y = 0;
         return true;
     }
-    *x = FloatToF26Dot6(env->GetFloatField(pt, sunFontIDs.xFID));
-    *y = FloatToF26Dot6(env->GetFloatField(pt, sunFontIDs.yFID));
+    *x = FloatToFixed(env->GetFloatField(pt, sunFontIDs.xFID));
+    *y = FloatToFixed(env->GetFloatField(pt, sunFontIDs.yFID));
     env->DeleteLocalRef(pt);
 
   return true;
@@ -325,8 +321,8 @@
                        _hb_jdk_get_font_funcs (),
                        jdkFontInfo, (hb_destroy_func_t) _do_nothing);
     hb_font_set_scale (font,
-                      FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale),
-                      FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale));
+                      FloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale),
+                      FloatToFixed(jdkFontInfo->ptSize*jdkFontInfo->devScale));
   return font;
 }
 
@@ -343,8 +339,8 @@
     hb_face_destroy(face);
 
     hb_font_set_scale(font,
-                     FloatToF26Dot6(jdkFontInfo->ptSize),
-                     FloatToF26Dot6(jdkFontInfo->ptSize));
+                     FloatToFixed(jdkFontInfo->ptSize),
+                     FloatToFixed(jdkFontInfo->ptSize));
     return font;
 }
 #endif
--- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h	Wed Aug 31 12:49:03 2016 +0300
+++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h	Wed Aug 31 13:40:06 2016 -0700
@@ -48,6 +48,10 @@
 } JDKFontInfo;
 
 
+// Use 16.16 for better precision than 26.6
+#define FloatToFixedScale ((float)(1 << 16))
+#define FloatToFixed(f) ((unsigned int)((f) * FloatToFixedScale))
+
 /*
  * Note:
  *
--- a/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java	Wed Aug 31 12:49:03 2016 +0300
+++ b/jdk/test/java/awt/font/TextLayout/VisibleAdvance.java	Wed Aug 31 13:40:06 2016 -0700
@@ -29,7 +29,7 @@
 
 /* @test
  * @summary verify TextLine advance
- * @bug 6582460
+ * @bug 6582460 8164818
  */
 
 /*