modified GetTextExtent for TextObject
authorSungyeon Woo <s.woo@samsung.com>
Tue, 19 Mar 2013 03:42:46 +0000 (12:42 +0900)
committerSungyeon Woo <s.woo@samsung.com>
Tue, 19 Mar 2013 04:18:01 +0000 (13:18 +0900)
Change-Id: I169c53c8bb2c8ad3d81688d8e7dbef89a0402bf0
Signed-off-by: Sungyeon Woo <s.woo@samsung.com>
src/graphics/FGrp_Font.cpp

index 36dad79..df340d5 100644 (file)
@@ -1112,17 +1112,36 @@ _Font::GetTextExtent(int width, const _Util::String& text, bool outline, int& co
 
                if (r != E_SUCCESS)
                {
-                       //?? need log
                        return r;
                }
 
                int left = 0;
                int right = 0;
+               int determinedCount = -1;
 
                for (GapList::Iterator i = gapList.Begin(); i != gapList.End(); ++i)
                {
                        left = (i->first < left) ? i->first : left;
                        right = (i->second > right) ? i->second : right;
+
+                       if (determinedCount < 0 && i->first < width && i->second >= width)\r
+                       {\r
+                               if (i != gapList.Begin())\r
+                               {\r
+                                       if (i - gapList.Begin() - 1 < text.length)\r
+                                       {\r
+                                               determinedCount = bidiProperty.pBidiIndex[i - gapList.Begin() - 1];\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               determinedCount = text.length;\r
+                                       }\r
+                               }\r
+                               else\r
+                               {\r
+                                       determinedCount = 0;\r
+                               }\r
+                       }\r
                }
 
                if (right - left <= width)
@@ -1130,9 +1149,27 @@ _Font::GetTextExtent(int width, const _Util::String& text, bool outline, int& co
                        pcDim.SetSize(right - left, __fontAttrib.size.ToInt());
                        count = text.length;
                }
-               else
+               else
                {
-                       return this->GetTextExtent(width, _Util::String(text.pStart, text.length - 1), outline, count, pcDim);
+                       _TextBidiPropertyWithReorder determinedBidiProperty(text.pStart, text.length);\r
+\r
+                       GapList determinedGapList;
+
+                       result r = this->__GetTextExtentList(determinedBidiProperty, determinedGapList);
+
+                       if (r != E_SUCCESS)
+                       {
+                               return r;
+                       }
+
+                       for (GapList::Iterator i = determinedGapList.Begin(); i != determinedGapList.End(); ++i)
+                       {
+                               left = (i->first < left) ? i->first : left;
+                               right = (i->second > right) ? i->second : right;
+                       }\r
+\r
+                       pcDim.SetSize(right - left, __fontAttrib.size.ToInt());\r
+                       count = (determinedCount >= 0) ? determinedCount : 0;
                }
 
                return E_SUCCESS;