Returning GlypInfo information in floats rather than fractional26.6 26/34926/3
authorRichard Underhill <r.underhill@partner.samsung.com>
Wed, 4 Feb 2015 11:47:34 +0000 (11:47 +0000)
committerRichard Underhill <r.underhill@partner.samsung.com>
Wed, 4 Feb 2015 14:57:36 +0000 (14:57 +0000)
Change-Id: I13dacd55c3877ad88a53cd52f8a56a3fb5604531
Signed-off-by: Richard Underhill <r.underhill@partner.samsung.com>
text/dali/internal/text-abstraction/font-client-impl.cpp
text/dali/internal/text-abstraction/font-client-impl.h
text/dali/public-api/text-abstraction/glyph-info.h

index 04ec0b8..3fcb756 100644 (file)
@@ -293,19 +293,19 @@ struct FontClient::Plugin
 
         if( FT_Err_Ok == error )
         {
-          array[i].width  = ftFace->glyph->metrics.width;
-          array[i].height = ftFace->glyph->metrics.height;
+          array[i].width  = static_cast< float >( ftFace->glyph->metrics.width ) * FROM_266;
+          array[i].height = static_cast< float >( ftFace->glyph->metrics.height ) * FROM_266 ;
           if( horizontal )
           {
-            array[i].xBearing = ftFace->glyph->metrics.horiBearingX;
-            array[i].yBearing = ftFace->glyph->metrics.horiBearingY;
-            array[i].advance  = ftFace->glyph->metrics.horiAdvance;
+            array[i].xBearing = static_cast< float >( ftFace->glyph->metrics.horiBearingX ) * FROM_266;
+            array[i].yBearing = static_cast< float >( ftFace->glyph->metrics.horiBearingY ) * FROM_266;
+            array[i].advance  = static_cast< float >( ftFace->glyph->metrics.horiAdvance ) * FROM_266;
           }
           else
           {
-            array[i].xBearing = ftFace->glyph->metrics.vertBearingX;
-            array[i].yBearing = ftFace->glyph->metrics.vertBearingY;
-            array[i].advance  = ftFace->glyph->metrics.vertAdvance;
+            array[i].xBearing = static_cast< float >( ftFace->glyph->metrics.vertBearingX ) * FROM_266;
+            array[i].yBearing = static_cast< float >( ftFace->glyph->metrics.vertBearingY ) * FROM_266;
+            array[i].advance  = static_cast< float >( ftFace->glyph->metrics.vertAdvance ) * FROM_266;
           }
         }
         else
index 7a758f3..083020e 100644 (file)
@@ -34,6 +34,14 @@ namespace Internal
 {
 
 /**
+ * Conversion from Fractional26.6 to float
+ */
+namespace
+{
+   const float FROM_266 = 1.0f / 64.0f;
+}
+
+/**
  * Implementation of the FontClient
  */
 class FontClient : public Dali::BaseObject
index 3a94935..0cb3c7f 100644 (file)
@@ -29,7 +29,7 @@ namespace TextAbstraction
 
 /**
  * The information describing a glyph (font ID, index, metrics)
- * The metrics are expressed in 26.6 fractional pixel format.
+ * The metrics have been converted from Fractional26.6 to floats.
  */
 struct GlyphInfo
 {
@@ -45,11 +45,11 @@ struct GlyphInfo
 
   FontId fontId;       ///< Identifies the font containing the glyph
   GlyphIndex index;    ///< Uniquely identifies a glyph for a given FontId
-  uint32_t width;      ///< The width of the glyph
-  uint32_t height;     ///< The height of the glyph
-  uint32_t xBearing;   ///< The distance from the cursor position to the leftmost border of the glyph
-  uint32_t yBearing;   ///< The distance from the baseline to the topmost border of the glyph
-  uint32_t advance;    ///< The distance to move the cursor for this glyph
+  float width;      ///< The width of the glyph
+  float height;     ///< The height of the glyph
+  float xBearing;   ///< The distance from the cursor position to the leftmost border of the glyph
+  float yBearing;   ///< The distance from the baseline to the topmost border of the glyph
+  float advance;    ///< The distance to move the cursor for this glyph
 };
 
 } // Dali