[icu_le] Fix scaling
authorBehdad Esfahbod <behdad@behdad.org>
Thu, 23 May 2013 19:43:02 +0000 (15:43 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Thu, 23 May 2013 19:43:02 +0000 (15:43 -0400)
Seems to work...

src/hb-icu-le.cc
src/hb-icu-le/PortableFontInstance.cpp
src/hb-icu-le/PortableFontInstance.h

index c05d330..350f5c6 100644 (file)
@@ -63,6 +63,8 @@ _hb_icu_le_shaper_font_data_create (hb_font_t *font)
 {
   LEErrorCode status = LE_NO_ERROR;
   hb_icu_le_shaper_font_data_t *data = new PortableFontInstance (font->face,
+                                                                1,
+                                                                1,
                                                                 font->x_scale,
                                                                 font->y_scale,
                                                                 status);
index c38e2b1..9d423c4 100644 (file)
 #include <string.h>
 
 
-PortableFontInstance::PortableFontInstance(hb_face_t *face, float xScale, float yScale, LEErrorCode &status)
-    : fFace(face), fXScale(xScale), fYScale(yScale), fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0),
+PortableFontInstance::PortableFontInstance(hb_face_t *face,
+                                          float xScale,
+                                          float yScale,
+                                          unsigned int xPixelsPerEM,
+                                          unsigned int yPixelsPerEM,
+                                          LEErrorCode &status)
+    : fFace(face),
+      fXScale(xScale), fYScale(yScale),
+      fXPixelsPerEM(xPixelsPerEM), fYPixelsPerEM(yPixelsPerEM),
+      fUnitsPerEM(0), fAscent(0), fDescent(0), fLeading(0),
       fNAMETable(NULL), fNameCount(0), fNameStringOffset(0), fCMAPMapper(NULL), fHMTXTable(NULL), fNumGlyphs(0), fNumLongHorMetrics(0)
 {
     if (LE_FAILURE(status)) {
@@ -194,8 +202,7 @@ void PortableFontInstance::getGlyphAdvance(LEGlyphID glyph, LEPoint &advance) co
         index = fNumLongHorMetrics - 1;
     }
 
-    advance.fX = xUnitsToPoints(SWAPW(fHMTXTable->hMetrics[index].advanceWidth));
-    advance.fY = 0;
+    transformFunits (SWAPW(fHMTXTable->hMetrics[index].advanceWidth), 0, advance);
 }
 
 le_bool PortableFontInstance::getGlyphPoint(LEGlyphID /*glyph*/, le_int32 /*pointNumber*/, LEPoint &/*point*/) const
@@ -249,20 +256,20 @@ LEGlyphID PortableFontInstance::mapCharToGlyph(LEUnicode32 ch) const
 
 float PortableFontInstance::getXPixelsPerEm() const
 {
-    return fXScale;
+    return fXPixelsPerEM;
 }
 
 float PortableFontInstance::getYPixelsPerEm() const
 {
-    return fYScale;
+    return fYPixelsPerEM;
 }
 
 float PortableFontInstance::getScaleFactorX() const
 {
-    return 1.0;
+    return fXScale;
 }
 
 float PortableFontInstance::getScaleFactorY() const
 {
-    return 1.0;
+    return fYScale;
 }
index 0794560..5b92d83 100644 (file)
@@ -36,6 +36,8 @@ private:
 
     float     fXScale;
     float     fYScale;
+    unsigned int fXPixelsPerEM;
+    unsigned int fYPixelsPerEM;
     le_int32  fUnitsPerEM;
     le_int32  fAscent;
     le_int32  fDescent;
@@ -59,7 +61,12 @@ protected:
     hb_blob_t *readFontTable(LETag tableTag) const;
 
 public:
-    PortableFontInstance(hb_face_t *face, float xScale, float yScale, LEErrorCode &status);
+    PortableFontInstance(hb_face_t *face,
+                        float xScale,
+                        float yScale,
+                        unsigned int xPixelsPerEM,
+                        unsigned int yPixelsPerEM,
+                        LEErrorCode &status);
 
     virtual ~PortableFontInstance();