Change FontMetrics format to match GlyphMetrics 04/35004/1
authorPaul Wisbey <p.wisbey@samsung.com>
Thu, 5 Feb 2015 13:08:16 +0000 (13:08 +0000)
committerPaul Wisbey <p.wisbey@samsung.com>
Thu, 5 Feb 2015 16:42:12 +0000 (16:42 +0000)
Change-Id: I38e069322f03c421fe9d5bce5ba2d2fc1b737a75

text/dali/internal/text-abstraction/font-client-impl.cpp
text/dali/internal/text-abstraction/font-client-impl.h
text/dali/public-api/text-abstraction/font-metrics.cpp
text/dali/public-api/text-abstraction/font-metrics.h
text/dali/public-api/text-abstraction/glyph-info.h

index 3fcb756..bdd0f9e 100644 (file)
 // INTERNAL INCLUDES
 #include <singleton-service-impl.h>
 
+/**
+ * Conversion from Fractional26.6 to float
+ */
+namespace
+{
+const float FROM_266 = 1.0f / 64.0f;
+}
+
 namespace Dali
 {
 
@@ -240,7 +248,10 @@ struct FontClient::Plugin
         id = mFontCache.size() + 1;
 
         FT_Size_Metrics& ftMetrics = ftFace->size->metrics;
-        FontMetrics metrics( ftMetrics.ascender, ftMetrics.descender, ftMetrics.height );
+
+        FontMetrics metrics( static_cast< float >( ftMetrics.ascender  ) * FROM_266,
+                             static_cast< float >( ftMetrics.descender ) * FROM_266,
+                             static_cast< float >( ftMetrics.height    ) * FROM_266 );
 
         mFontCache.push_back( CacheItem( id, ftFace, path, pointSize, faceIndex, metrics ) );
       }
index 083020e..7a758f3 100644 (file)
@@ -34,14 +34,6 @@ 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 51b1d85..f1a172c 100644 (file)
@@ -31,12 +31,12 @@ FontMetrics::FontMetrics()
 {
 }
 
-FontMetrics::FontMetrics( signed long ascender26Dot6,
-                          signed long descender26Dot6,
-                          signed long height26Dot6 )
-: ascender( ascender26Dot6 ),
-  descender( descender26Dot6 ),
-  height( height26Dot6 )
+FontMetrics::FontMetrics( float ascenderPixels,
+                          float descenderPixels,
+                          float heightPixels )
+: ascender( ascenderPixels ),
+  descender( descenderPixels ),
+  height( heightPixels )
 {
 }
 
index e941c1e..4472525 100644 (file)
@@ -25,7 +25,7 @@ namespace TextAbstraction
 {
 
 /**
- * The metrics for a Font expressed in 26.6 fractional pixel format.
+ * The metrics for a Font expressed in pixels.
  */
 struct FontMetrics
 {
@@ -35,15 +35,15 @@ struct FontMetrics
   FontMetrics();
 
   /**
-   * @brief Create the font metrics in 26.6 fractional pixel format.
+   * @brief Create the font metrics in pixels.
    */
-  FontMetrics( signed long ascender26Dot6,
-               signed long descender26Dot6,
-               signed long height26Dot6 );
+  FontMetrics( float ascenderPixels,
+               float descenderPixels,
+               float heightPixels );
 
-  signed long ascender;   ///< The ascender in 26.6 fractional pixels.
-  signed long descender;  ///< The descender in 26.6 fractional pixels.
-  signed long height;     ///< The height in 26.6 fractional pixels.
+  float ascender;   ///< The ascender in pixels.
+  float descender;  ///< The descender in pixels.
+  float height;     ///< The height in pixels.
 };
 
 } // Dali
index 0cb3c7f..f0521e4 100644 (file)
@@ -29,7 +29,7 @@ namespace TextAbstraction
 
 /**
  * The information describing a glyph (font ID, index, metrics)
- * The metrics have been converted from Fractional26.6 to floats.
+ * The metrics are in pixels.
  */
 struct GlyphInfo
 {
@@ -43,8 +43,8 @@ struct GlyphInfo
    */
   GlyphInfo( FontId font, GlyphIndex i );
 
-  FontId fontId;       ///< Identifies the font containing the glyph
-  GlyphIndex index;    ///< Uniquely identifies a glyph for a given FontId
+  FontId fontId;    ///< Identifies the font containing the glyph
+  GlyphIndex index; ///< Uniquely identifies a glyph for a given FontId
   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