From: Paul Wisbey
Date: Thu, 5 Feb 2015 13:08:16 +0000 (+0000)
Subject: Change FontMetrics format to match GlyphMetrics
X-Git-Tag: new_text_0.1~27
X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F04%2F35004%2F1;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git
Change FontMetrics format to match GlyphMetrics
Change-Id: I38e069322f03c421fe9d5bce5ba2d2fc1b737a75
---
diff --git a/text/dali/internal/text-abstraction/font-client-impl.cpp b/text/dali/internal/text-abstraction/font-client-impl.cpp
index 3fcb756..bdd0f9e 100644
--- a/text/dali/internal/text-abstraction/font-client-impl.cpp
+++ b/text/dali/internal/text-abstraction/font-client-impl.cpp
@@ -29,6 +29,14 @@
// INTERNAL INCLUDES
#include
+/**
+ * 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 ) );
}
diff --git a/text/dali/internal/text-abstraction/font-client-impl.h b/text/dali/internal/text-abstraction/font-client-impl.h
index 083020e..7a758f3 100644
--- a/text/dali/internal/text-abstraction/font-client-impl.h
+++ b/text/dali/internal/text-abstraction/font-client-impl.h
@@ -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
diff --git a/text/dali/public-api/text-abstraction/font-metrics.cpp b/text/dali/public-api/text-abstraction/font-metrics.cpp
index 51b1d85..f1a172c 100644
--- a/text/dali/public-api/text-abstraction/font-metrics.cpp
+++ b/text/dali/public-api/text-abstraction/font-metrics.cpp
@@ -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 )
{
}
diff --git a/text/dali/public-api/text-abstraction/font-metrics.h b/text/dali/public-api/text-abstraction/font-metrics.h
index e941c1e..4472525 100644
--- a/text/dali/public-api/text-abstraction/font-metrics.h
+++ b/text/dali/public-api/text-abstraction/font-metrics.h
@@ -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
diff --git a/text/dali/public-api/text-abstraction/glyph-info.h b/text/dali/public-api/text-abstraction/glyph-info.h
index 0cb3c7f..f0521e4 100644
--- a/text/dali/public-api/text-abstraction/glyph-info.h
+++ b/text/dali/public-api/text-abstraction/glyph-info.h
@@ -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