BIDI text hint APIs added
authorYoungki Ahn <ykahn@samsung.com>
Mon, 13 May 2013 08:03:25 +0000 (17:03 +0900)
committerYoungki Ahn <ykahn@samsung.com>
Mon, 13 May 2013 08:03:25 +0000 (17:03 +0900)
Change-Id: I527d99cc891f9a1eb1d4aeb1e4b2e3b6caf70355
Signed-off-by: Youngki Ahn <ykahn@samsung.com>
src/graphics/FGrp_Canvas.cpp
src/graphics/FGrp_Canvas.h
src/graphics/FGrp_CanvasImpl.cpp
src/graphics/FGrp_Font.cpp [changed mode: 0644->0755]
src/graphics/FGrp_FontBidiUtil.cpp [changed mode: 0644->0755]
src/graphics/FGrp_FontBidiUtil.h [changed mode: 0644->0755]
src/graphics/FGrp_FontImpl.cpp [changed mode: 0644->0755]
src/graphics/inc/FGrp_CanvasImpl.h
src/graphics/inc/FGrp_FontImpl.h [changed mode: 0644->0755]

index 46008fd..e6e49e2 100755 (executable)
@@ -612,7 +612,6 @@ _Canvas::_Canvas(void)
        , __lineJoinStyle(LINE_JOIN_STYLE_ROUND)
        , __isClipBoundsSet(false)
        , __textOrigin(TEXT_ORIGIN_LEFT_TOP)
-       , __textBidiHint(TEXT_BIDI_HINT_NONE)
        , __applyEmoji(true)
        , __bitmapDrawingQuality(BITMAP_DRAWING_QUALITY_LOW)
        , __compositeMode(COMPOSITE_MODE_SRC_OVER)
index b9a9d2e..a200246 100755 (executable)
@@ -254,7 +254,6 @@ private:
        bool __isClipBoundsSet;
        Rectangle __clipBounds;
        TextOrigin __textOrigin;
-       TextBidiHint __textBidiHint;
        bool __applyEmoji;
 
        struct
index 908b937..3eab72c 100755 (executable)
@@ -2759,22 +2759,6 @@ _CanvasImpl::SetTextOrigin(TextOrigin origin)
        }
 }
 
-void
-_CanvasImpl::SetTextBidiHint(TextBidiHint bidiHint)
-{
-       if (INSTANCE_IS_VALID)
-       {
-               switch (bidiHint)
-               {
-               case TEXT_BIDI_HINT_NONE:
-               case TEXT_BIDI_HINT_LTR:
-               case TEXT_BIDI_HINT_RTL:
-                       this->_pNativeCanvas->__textBidiHint = bidiHint;
-                       break;
-               }
-       }
-}
-
 result
 _CanvasImpl::SetClipBounds(const Rectangle& vcRect)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 33010ae..66d93fb
@@ -548,6 +548,26 @@ struct _TextFragment
 }
 
 
+namespace Tizen { namespace Graphics { namespace _Util
+{
+
+template <>
+inline Tizen::Graphics::_TextBidiProperty::BidiHint Convert<Tizen::Graphics::TextBidiHint, Tizen::Graphics::_TextBidiProperty::BidiHint>(const Tizen::Graphics::TextBidiHint& bidiHint)
+{
+       switch (bidiHint)
+       {
+       case TEXT_BIDI_HINT_LTR:
+               return _TextBidiProperty::BIDI_HINT_LTR;
+       case TEXT_BIDI_HINT_RTL:
+               return _TextBidiProperty::BIDI_HINT_RTL;
+       default:
+               return _TextBidiProperty::BIDI_HINT_NONE;
+       }
+}
+
+}}} // Tizen::Graphics::_Util
+
+
 namespace Tizen { namespace Graphics
 {
 
@@ -890,7 +910,7 @@ _Font::GetTextExtent(int width, const _Util::String& text, bool outline, int& co
                return E_SUCCESS;
        }
 
-       _TextBidiPropertyWithReorder bidiProperty(text.pStart, text.length);
+       _TextBidiPropertyWithReorder bidiProperty(text.pStart, text.length, _Util::Convert<TextBidiHint, _TextBidiProperty::BidiHint>(_GetTextBidiHint()));
 
        if (bidiProperty.HasBidi())
        {
@@ -952,7 +972,7 @@ _Font::GetTextExtent(int width, const _Util::String& text, bool outline, int& co
 
                        while (right - left > width)
                        {
-                               _TextBidiPropertyWithReorder determinedBidiProperty(text.pStart, --tempCount);
+                               _TextBidiPropertyWithReorder determinedBidiProperty(text.pStart, --tempCount, _Util::Convert<TextBidiHint, _TextBidiProperty::BidiHint>(_GetTextBidiHint()));
 
                                GapList determinedGapList;
 
@@ -1484,7 +1504,7 @@ _Font::GetTextExtentList(const _Util::String& text, _Util::AccumList<_Util::Pair
                return E_SUCCESS;
        }
 
-       _TextBidiPropertyWithReorder bidiProperty(text.pStart, text.length);
+       _TextBidiPropertyWithReorder bidiProperty(text.pStart, text.length, _Util::Convert<TextBidiHint, _TextBidiProperty::BidiHint>(_GetTextBidiHint()));
 
        if (bidiProperty.HasBidi())
        {
@@ -1589,7 +1609,7 @@ _Font::__DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String
 
        unsigned long canvasFgColor = canvas.__fgColor;
 
-       _TextBidiPropertyWithReorder bidiProperty(pText, length);
+       _TextBidiPropertyWithReorder bidiProperty(pText, length, _Util::Convert<TextBidiHint, _TextBidiProperty::BidiHint>(_GetTextBidiHint()));
 
        if (bidiProperty.HasBidi())
        {
old mode 100644 (file)
new mode 100755 (executable)
index df4e6e5..65574a5
@@ -138,7 +138,7 @@ _ConvertCharacterCode(DstCode* pDst, const SrcCode* pSrc, int length)
 ////////////////
 
 BidiParagraph*
-_GetBidiParagraphProperty(const wchar_t* pText, size_t len, int* pSegmentIndex)
+_GetBidiParagraphProperty(const wchar_t* pText, size_t len, int* pSegmentIndex, Tizen::Graphics::_TextBidiProperty::BidiHint hint)
 {
        #define CHECK_IF(cond) if (!(cond)) return NULL
 
@@ -227,21 +227,32 @@ _GetBidiParagraphProperty(const wchar_t* pText, size_t len, int* pSegmentIndex)
        {
                FriBidiParType direction = FRIBIDI_PAR_ON;
 
-               for (size_t i = 0;  i < len; i++)
+               switch (hint)
                {
-                       if (FRIBIDI_IS_STRONG(bidiProperty->pCharTypes[i]))
+               case Tizen::Graphics::_TextBidiProperty::BIDI_HINT_LTR:
+                       direction = FRIBIDI_PAR_LTR;
+                       break;
+               case Tizen::Graphics::_TextBidiProperty::BIDI_HINT_RTL:
+                       direction = FRIBIDI_PAR_RTL;
+                       break;
+               default:
+                       for (size_t i = 0;  i < len; i++)
                        {
-                               if (FRIBIDI_IS_RTL(bidiProperty->pCharTypes[i]))
+                               if (FRIBIDI_IS_STRONG(bidiProperty->pCharTypes[i]))
                                {
-                                       direction = FRIBIDI_PAR_RTL;
-                               }
-                               else
-                               {
-                                       direction = FRIBIDI_PAR_LTR;
-                               }
+                                       if (FRIBIDI_IS_RTL(bidiProperty->pCharTypes[i]))
+                                       {
+                                               direction = FRIBIDI_PAR_RTL;
+                                       }
+                                       else
+                                       {
+                                               direction = FRIBIDI_PAR_LTR;
+                                       }
 
-                               break;
+                                       break;
+                               }
                        }
+                       break;
                }
 
                bidiProperty->direction = direction;
@@ -412,7 +423,7 @@ _ReorderBidiLine(wchar_t* pText, size_t start, size_t len, const BidiParagraph&
 namespace Tizen { namespace Graphics
 {
 
-_TextBidiProperty::_TextBidiProperty(const wchar_t* pText, int length)
+_TextBidiProperty::_TextBidiProperty(const wchar_t* pText, int length, BidiHint hint)
        : pEventText(0)
        , pCharType(0)
        , pEmbeddingLevels(0)
@@ -422,7 +433,7 @@ _TextBidiProperty::_TextBidiProperty(const wchar_t* pText, int length)
        , length(0)
        , pReserved(0)
 {
-       BidiParagraph* pBidiProperty = _GetBidiParagraphProperty(pText, length, NULL);
+       BidiParagraph* pBidiProperty = _GetBidiParagraphProperty(pText, length, NULL, hint);
 
        if (pBidiProperty)
        {
@@ -508,8 +519,8 @@ _TextBidiProperty::~_TextBidiProperty(void)
        }
 }
 
-_TextBidiPropertyWithReorder::_TextBidiPropertyWithReorder(const wchar_t* pText, int length)
-       : _TextBidiProperty(pText, length)
+_TextBidiPropertyWithReorder::_TextBidiPropertyWithReorder(const wchar_t* pText, int length, BidiHint hint)
+       : _TextBidiProperty(pText, length, hint)
        , pBidiIndex(0)
        , __pReorderedText(0)
 {
old mode 100644 (file)
new mode 100755 (executable)
index aee3f1f..98c1bfb
@@ -34,6 +34,13 @@ namespace Tizen { namespace Graphics
 
 struct _TextBidiProperty
 {
+       enum BidiHint
+       {
+               BIDI_HINT_NONE,
+               BIDI_HINT_LTR,
+               BIDI_HINT_RTL
+       };
+
        const wchar_t* pEventText;
        const FriBidiCharType* pCharType;
        const FriBidiLevel* pEmbeddingLevels;
@@ -43,7 +50,7 @@ struct _TextBidiProperty
        int length;
        void* pReserved;
 
-       _TextBidiProperty(const wchar_t* pText, int length);
+       _TextBidiProperty(const wchar_t* pText, int length, BidiHint hint = BIDI_HINT_NONE);
        _TextBidiProperty(const _TextBidiProperty& refBidiProperty, int offset, int length);
        virtual ~_TextBidiProperty(void);
 
@@ -58,7 +65,7 @@ struct _TextBidiPropertyWithReorder
 {
        const FriBidiStrIndex* pBidiIndex;
 
-       _TextBidiPropertyWithReorder(const wchar_t* pText, int length);
+       _TextBidiPropertyWithReorder(const wchar_t* pText, int length, BidiHint hint = BIDI_HINT_NONE);
        _TextBidiPropertyWithReorder(const _TextBidiProperty& refBidiProperty, int offset, int length);
        virtual ~_TextBidiPropertyWithReorder(void);
 
old mode 100644 (file)
new mode 100755 (executable)
index a3be434..c7be3c1
@@ -266,7 +266,7 @@ _FontImpl::GetMaxHeight(void) const
 {
        IF_NOT_CONSTRUCTED(return -1);
 
-       int pcMaxHeight = ceil(_pNativeFont->GetMaxHeight().ToDouble());
+       int pcMaxHeight = _DoubleToIntForPos(ceil(_pNativeFont->GetMaxHeight().ToDouble()));
 
        for (int i = pcMaxHeight; i < INT_MAX; i++)
        {
@@ -287,7 +287,7 @@ _FontImpl::GetMaxHeightF(void) const
 {
        IF_NOT_CONSTRUCTED(return -1.0f);
 
-       float pcMaxHeight = ceil(_pNativeFont->GetMaxHeight().ToDouble());
+       float pcMaxHeight = float(ceil(_pNativeFont->GetMaxHeight().ToDouble()));
        float vcMaxHeight = _ResUtil::ConvertToVirCoordY(pcMaxHeight);
 
        return vcMaxHeight;
@@ -822,7 +822,7 @@ _FontImpl::GetLeading(void) const
 {
        IF_NOT_CONSTRUCTED(return -1);
 
-       int pcLeading = ceil(_pNativeFont->GetLeading().ToDouble());
+       int pcLeading = _DoubleToIntForPos(ceil(_pNativeFont->GetLeading().ToDouble()));
 
        for (int i = pcLeading; i < INT_MAX; i++)
        {
@@ -843,7 +843,7 @@ _FontImpl::GetLeadingF(void) const
 {
        IF_NOT_CONSTRUCTED(return -1.0f);
 
-       float pcLeading = ceil(_pNativeFont->GetLeading().ToDouble());
+       float pcLeading = float(ceil(_pNativeFont->GetLeading().ToDouble()));
        float vcLeading = _ResUtil::ConvertToVirCoordY(pcLeading);
 
        return vcLeading;
@@ -901,6 +901,31 @@ _FontImpl::GetTextExtentList(const Tizen::Base::String& string, int startIndex,
 }} // Tizen::Graphics
 
 
+namespace Tizen { namespace Graphics
+{
+
+TextBidiHint _bidiHint = TEXT_BIDI_HINT_NONE;
+
+void
+_SetTextBidiHint(TextBidiHint bidiHint)
+{
+       switch (bidiHint)
+       {
+       case TEXT_BIDI_HINT_NONE:
+       case TEXT_BIDI_HINT_LTR:
+       case TEXT_BIDI_HINT_RTL:
+               _bidiHint = bidiHint;
+               break;
+       }
+}
+
+TextBidiHint
+_GetTextBidiHint(void)
+{
+       return _bidiHint;
+}
+
+}} // Tizen::Graphics
 
 ////////////////////////////////////////////////////////////////////////////////
 //
index bf20e50..86bc22e 100755 (executable)
@@ -80,13 +80,6 @@ enum TextOrigin
        TEXT_ORIGIN_BASELINE
 };
 
-enum TextBidiHint
-{
-       TEXT_BIDI_HINT_NONE,
-       TEXT_BIDI_HINT_LTR,
-       TEXT_BIDI_HINT_RTL
-};
-
 class _OSP_EXPORT_ _CanvasImpl
        : public Tizen::Base::Object
 {
@@ -180,7 +173,6 @@ public:
        Font* GetFontN(void);
 
        void SetTextOrigin(TextOrigin origin);
-       void SetTextBidiHint(TextBidiHint bidiHint);
 
        result DrawText(const Point& point, const Tizen::Base::String& text);
        result DrawText(const Point& point, const Tizen::Base::String& text, int startIndex, int length);
old mode 100644 (file)
new mode 100755 (executable)
index 1208d2d..51b2dd9
@@ -227,6 +227,16 @@ private:
 
 }; // _FontImpl
 
+enum TextBidiHint
+{
+       TEXT_BIDI_HINT_NONE,
+       TEXT_BIDI_HINT_LTR,
+       TEXT_BIDI_HINT_RTL
+};
+
+_OSP_EXPORT_ void _SetTextBidiHint(TextBidiHint bidiHint);
+_OSP_EXPORT_ TextBidiHint _GetTextBidiHint(void);
+
 }} // Tizen::Graphics
 
 #endif // _FGRP_INTERNAL_FONT_IMPL_H_