_Font::GetTextExtentList() API added
authorYoungki Ahn <ykahn@samsung.com>
Sat, 30 Mar 2013 07:01:50 +0000 (16:01 +0900)
committerYoungki Ahn <ykahn@samsung.com>
Sat, 30 Mar 2013 07:01:50 +0000 (16:01 +0900)
Change-Id: I33968571f7e03f2ab3b8589d6a827125bf62bf84
Signed-off-by: Youngki Ahn <ykahn@samsung.com>
src/graphics/FGrp_FontImpl.cpp [changed mode: 0644->0755]
src/graphics/inc/FGrp_FontImpl.h [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 8c6fa66..349d73e
@@ -568,7 +568,7 @@ _FontImpl::SetCharSpace(float vcSpace)
        // convert VC -> PC
        float pcSpace = _ResUtil::ConvertToPhyCoordWidth(vcSpace);
 
-       _pNativeFont->SetCharSpace(pcSpace);
+       _pNativeFont->SetCharSpace(_FloatToIntForPos(pcSpace));
 
        return;
 }
@@ -761,7 +761,7 @@ result
 _FontImpl::SetSize(float vcSize)
 {
        IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
-       SysTryReturnResult(NID_GRP, vcSize > 0.0f, E_INVALID_ARG, "font size should be greater than 0");
+       SysTryReturnResult(NID_GRP, vcSize > 0.0f, E_INVALID_ARG, "Font size should be greater than 0");
 
        _pCoordHolder->Reset(vcSize);
 
@@ -772,7 +772,7 @@ _FontImpl::SetSize(float vcSize)
        {
                pcSize = _Util::FixedPoint26_6(1.0f);
 
-               _pCoordHolder->sizeF.phyCoord = pcSize;
+               _pCoordHolder->sizeF.phyCoord = pcSize.ToFloat();
                _pCoordHolder->sizeF.virCoord = vcSize;
        }
 
@@ -843,6 +843,37 @@ _FontImpl::UpdateDefaultFont(const Tizen::Base::String& key)
        return _Font::UpdateDefaultFont(key);
 }
 
+result
+_FontImpl::GetTextExtentList(const Tizen::Base::String& string, int startIndex, int length, Tizen::Base::Collection::ArrayListT<_FloatPair>& outList)
+{
+       IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
+
+       SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < string.GetLength(), E_OUT_OF_RANGE,
+               "The length(%d) & startIndex(%d) of the given text is out of range", length, startIndex);
+
+       _Util::String text(string.GetPointer(), string.GetLength(), startIndex, length);
+       _Util::AccumList<_Util::Pair<int, int> > outAccumList;
+
+       result r = _pNativeFont->GetTextExtentList(text, outAccumList);
+
+       SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to get the internal text extent information", GetErrorMessage(r));
+
+       outList.RemoveAll();
+
+       for (_Util::AccumList<_Util::Pair<int, int> >::Iterator iter = outAccumList.Begin(); iter != outAccumList.End(); ++iter)
+       {
+               _FloatPair pairF =
+               {
+                       _ResUtil::ConvertToVirCoord(static_cast<float>(iter->first)),
+                       _ResUtil::ConvertToVirCoord(static_cast<float>(iter->second))
+               };
+
+               outList.Add(pairF);
+       }
+
+       return true;
+}
+
 }} // Tizen::Graphics
 
 
old mode 100644 (file)
new mode 100755 (executable)
index d6e824a..513e13d
@@ -49,6 +49,22 @@ class Font;
 
 class _Font;
 
+struct _FloatPair
+{
+       float first;
+       float second;
+
+       friend bool operator ==(const _FloatPair& lhs, const _FloatPair& rhs)
+       {
+               return (lhs.first == rhs.first) && (lhs.second == rhs.second);
+       }
+
+       friend bool operator !=(const _FloatPair& lhs, const _FloatPair& rhs)
+       {
+               return !(operator ==(lhs, rhs));
+       }
+};
+
 class _OSP_EXPORT_ _FontImpl
        : public Tizen::Base::Object
 {
@@ -148,6 +164,8 @@ public:
        result GetTextExtent(int width, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, Dimension& dim) const;
        result GetTextExtent(float width, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, FloatDimension& dim) const;
 
+       result GetTextExtentList(const Tizen::Base::String& text, int startIndex, int length, Tizen::Base::Collection::ArrayListT<_FloatPair>& outList);
+
        /*
         * Sets the font size.
         *