8145901: Printed content is overlapping.
authorprr
Mon, 22 Aug 2016 10:35:16 -0700
changeset 40712 0ff80fba9c97
parent 40711 16129dbd3671
child 40713 8119b320ccb0
8145901: Printed content is overlapping. 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
--- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c	Mon Aug 22 18:23:46 2016 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c	Mon Aug 22 10:35:16 2016 -0700
@@ -72,12 +72,13 @@
 int storeGVData(JNIEnv* env,
                jobject gvdata, jint slot, jint baseIndex, jobject startPt,
                int glyphCount, hb_glyph_info_t *glyphInfo,
-               hb_glyph_position_t *glyphPos, hb_direction_t direction) {
+               hb_glyph_position_t *glyphPos, hb_direction_t direction,
+               float devScale) {
 
     int i;
     float x=0, y=0;
     float startX, startY;
-    float scale = 1.0f/64.0f;
+    float scale = 1.0f/64.0f/devScale;
     unsigned int* glyphs;
     float* positions;
     int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv;
@@ -216,7 +217,11 @@
     fi->ptSize = ptSize;
     fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]);
     fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]);
-
+    if (!aat && (getenv("HB_NODEVTX") != NULL)) {
+        fi->devScale = fi->xPtSize / fi->ptSize;
+    } else {
+        fi->devScale = 1.0f;
+    }
     return fi;
 }
 
@@ -309,7 +314,8 @@
      // by calling code.
 
      storeGVData(env, gvdata, slot, baseIndex, startPt,
-                 glyphCount, glyphInfo, glyphPos, direction);
+                 glyphCount, glyphInfo, glyphPos, direction,
+                 jdkFontInfo->devScale);
 
      hb_buffer_destroy (buffer);
      hb_font_destroy(hbfont);
--- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc	Mon Aug 22 18:23:46 2016 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc	Mon Aug 22 10:35:16 2016 -0700
@@ -52,6 +52,7 @@
  
     *glyph = (hb_codepoint_t)
           env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, u);
+printf("unicode=%x glyph=%x\n", unicode, *glyph);
     return (*glyph != 0);
 }
 
@@ -81,6 +82,7 @@
         return 0;
     }
     fadv = env->GetFloatField(pt, sunFontIDs.xFID);
+    fadv *= jdkFontInfo->devScale;
     env->DeleteLocalRef(pt);
 
     return FloatToF26Dot6(fadv); // should this round ?
@@ -324,8 +326,8 @@
                        _hb_jdk_get_font_funcs (),
                        jdkFontInfo, (hb_destroy_func_t) _do_nothing);
     hb_font_set_scale (font,
-                      FloatToF26Dot6(jdkFontInfo->xPtSize),
-                      FloatToF26Dot6(jdkFontInfo->yPtSize));
+                      FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale),
+                      FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale));
   return font;
 }
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h	Mon Aug 22 18:23:46 2016 +0530
+++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h	Mon Aug 22 10:35:16 2016 -0700
@@ -43,6 +43,7 @@
     float ptSize;
     float xPtSize;
     float yPtSize;
+    float devScale; // How much applying the full glyph tx scales x distance.
     jboolean aat;
 } JDKFontInfo;