From 937b43de00cc48e44cc690961aa64fd7ed0d5aa4 Mon Sep 17 00:00:00 2001 From: Youngki Ahn Date: Sat, 30 Mar 2013 16:01:50 +0900 Subject: [PATCH] _Font::GetTextExtentList() API added Change-Id: I33968571f7e03f2ab3b8589d6a827125bf62bf84 Signed-off-by: Youngki Ahn --- src/graphics/FGrp_FontImpl.cpp | 37 ++++++++++++++++++++++++++++++++++--- src/graphics/inc/FGrp_FontImpl.h | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+), 3 deletions(-) mode change 100644 => 100755 src/graphics/FGrp_FontImpl.cpp mode change 100644 => 100755 src/graphics/inc/FGrp_FontImpl.h diff --git a/src/graphics/FGrp_FontImpl.cpp b/src/graphics/FGrp_FontImpl.cpp old mode 100644 new mode 100755 index 8c6fa66..349d73e --- a/src/graphics/FGrp_FontImpl.cpp +++ b/src/graphics/FGrp_FontImpl.cpp @@ -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 > 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 >::Iterator iter = outAccumList.Begin(); iter != outAccumList.End(); ++iter) + { + _FloatPair pairF = + { + _ResUtil::ConvertToVirCoord(static_cast(iter->first)), + _ResUtil::ConvertToVirCoord(static_cast(iter->second)) + }; + + outList.Add(pairF); + } + + return true; +} + }} // Tizen::Graphics diff --git a/src/graphics/inc/FGrp_FontImpl.h b/src/graphics/inc/FGrp_FontImpl.h old mode 100644 new mode 100755 index d6e824a..513e13d --- a/src/graphics/inc/FGrp_FontImpl.h +++ b/src/graphics/inc/FGrp_FontImpl.h @@ -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. * -- 2.7.4