2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrp_FontImpl.cpp
20 * @brief This is the implementation file for _FontImpl class.
29 #include <FBaseSysLog.h>
30 #include <FBaseRtMutex.h>
32 #include "FGrp_FontImpl.h"
33 #include "FGrp_Font.h"
34 #include "FGrp_ResUtil.h"
35 #include "util/FGrp_Util.h"
38 using namespace Tizen::Base::Runtime;
40 #define IF_NOT_INITIALIZED(code) if (this->_pNativeFont == null || this->_pCoordHolder == null) \
44 #define IF_NOT_CONSTRUCTED(code) if (this->_pNativeFont == null || (!this->_pNativeFont->IsConstructed())) \
48 #define IsSucceeded(X) (!IsFailed(X))
52 #define CRITICAL_SECTION _MutexGuard __mutexGuard__
54 #define CRITICAL_SECTION
58 namespace Tizen { namespace Graphics
66 Mutex* pMutex = GetMutexInstance();
72 Mutex* pMutex = GetMutexInstance();
77 static void __InitCreateMutex(void)
81 _MutexGuard::pMutexInstance = &mutex;
84 static Mutex* GetMutexInstance(void)
86 static pthread_once_t once_block = PTHREAD_ONCE_INIT;
88 if (_MutexGuard::pMutexInstance == null)
90 pthread_once(&once_block, __InitCreateMutex);
93 return _MutexGuard::pMutexInstance;
97 static Mutex* pMutexInstance;
100 Mutex* _MutexGuard::pMutexInstance = null;
103 struct _FontCoordHolder
105 _ResUtil::CoordHolder <int> size;
106 _ResUtil::CoordHolder <int> charSpace;
107 _ResUtil::CoordHolder <float> sizeF;
108 _ResUtil::CoordHolder <float> charSpaceF;
116 void Reset(int _size)
120 sizeF = static_cast<float>(_size);
124 void Reset(float _size)
126 size = static_cast<int>(_size);
134 _FontImpl::_FontImpl()
136 , _pCoordHolder(new (std::nothrow) _FontCoordHolder)
137 , _pNativeFont(new (std::nothrow) _Font)
139 if (_pNativeFont == null || _pCoordHolder == null)
142 delete _pCoordHolder;
145 _pCoordHolder = null;
148 _Util::CarveMagicKey(*this, _magicKey);
151 _FontImpl::_FontImpl(const _FontImpl& obj)
152 : _pCoordHolder(new (std::nothrow) _FontCoordHolder)
157 *_pCoordHolder = *obj._pCoordHolder;
160 _pNativeFont = obj._pNativeFont->CloneN();
162 if (_pNativeFont == null || _pCoordHolder == null)
165 delete _pCoordHolder;
168 _pCoordHolder = null;
171 _Util::CarveMagicKey(*this, _magicKey);
174 _FontImpl::~_FontImpl()
184 delete _pCoordHolder;
188 _Util::EraseMagicKey(*this, _magicKey);
192 _FontImpl::Construct(int style, int vcSize)
195 IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
198 _Util::FixedPoint26_6 pcSize(_ResUtil::ConvertToPhyCoordHeight(static_cast<float>(vcSize)));
200 if (vcSize > 0 && pcSize <= 1)
202 pcSize = _Util::FixedPoint26_6(1);
205 result r = _pNativeFont->Construct(style, pcSize);
206 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to construct _Font", GetErrorMessage(r));
208 _pCoordHolder->Reset(vcSize);
214 _FontImpl::Construct(const Tizen::Base::String& fontName, int style, int vcSize, bool isPathEnabled)
217 IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
220 _Util::FixedPoint26_6 pcSize(_ResUtil::ConvertToPhyCoordHeight(static_cast<float>(vcSize)));
222 if (vcSize > 0 && pcSize <= 1)
224 pcSize = _Util::FixedPoint26_6(1);
227 result r = _pNativeFont->Construct(fontName, style, pcSize, isPathEnabled);
228 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to construct _Font", GetErrorMessage(r));
230 _pCoordHolder->Reset(vcSize);
236 _FontImpl::Construct(const Tizen::Base::ByteBuffer& fontData, int style, int vcSize)
239 IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
242 _Util::FixedPoint26_6 pcSize(_ResUtil::ConvertToPhyCoordHeight(static_cast<float>(vcSize)));
244 if (vcSize > 0 && pcSize <= 1)
246 pcSize = _Util::FixedPoint26_6(1);
249 result r = _pNativeFont->Construct(fontData, style, pcSize);
250 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to construct _Font", GetErrorMessage(r));
252 _pCoordHolder->Reset(vcSize);
258 _FontImpl::Construct(int style, float vcSize)
261 IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
264 _Util::FixedPoint26_6 pcSize(_ResUtil::ConvertToPhyCoordHeight(vcSize));
266 if (vcSize > 0.0f && pcSize <= 1.0f)
268 pcSize = _Util::FixedPoint26_6(1.0f);
271 result r = _pNativeFont->Construct(style, pcSize);
272 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to construct _Font", GetErrorMessage(r));
274 _pCoordHolder->Reset(vcSize);
280 _FontImpl::Construct(const Tizen::Base::String& fontName, int style, float vcSize, bool isPathEnabled)
283 IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
286 _Util::FixedPoint26_6 pcSize(_ResUtil::ConvertToPhyCoordHeight(vcSize));
288 if (vcSize > 0.0f && pcSize <= 1.0f)
290 pcSize = _Util::FixedPoint26_6(1.0f);
293 result r = _pNativeFont->Construct(fontName, style, pcSize, isPathEnabled);
294 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to construct _Font", GetErrorMessage(r));
296 _pCoordHolder->Reset(vcSize);
302 _FontImpl::Construct(const Tizen::Base::ByteBuffer& fontData, int style, float vcSize)
305 IF_NOT_INITIALIZED(return E_OUT_OF_MEMORY);
308 _Util::FixedPoint26_6 pcSize(_ResUtil::ConvertToPhyCoordHeight(vcSize));
310 if (vcSize > 0.0f && pcSize <= 1.0f)
312 pcSize = _Util::FixedPoint26_6(1.0f);
315 result r = _pNativeFont->Construct(fontData, style, pcSize);
316 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to construct _Font", GetErrorMessage(r));
318 _pCoordHolder->Reset(vcSize);
324 _FontImpl::IsConstructed(void) const
327 IF_NOT_CONSTRUCTED(return false);
333 _FontImpl::GetMaxHeight(void) const
336 IF_NOT_CONSTRUCTED(return -1);
338 int pcMaxHeight = _DoubleToIntForPos(ceil(_pNativeFont->GetMaxHeight().ToDouble()));
340 for (int i = pcMaxHeight; i < INT_MAX; i++)
342 if (_ResUtil::ConvertToPhyCoord(_ResUtil::ConvertToVirCoordY(i)) >= pcMaxHeight)
349 int vcMaxHeight = _ResUtil::ConvertToVirCoordY(pcMaxHeight);
355 _FontImpl::GetMaxHeightF(void) const
358 IF_NOT_CONSTRUCTED(return -1.0f);
360 float pcMaxHeight = float(ceil(_pNativeFont->GetMaxHeight().ToDouble()));
361 float vcMaxHeight = _ResUtil::ConvertToVirCoordY(pcMaxHeight);
367 _FontImpl::GetMaxWidth(void) const
370 IF_NOT_CONSTRUCTED(return -1);
372 int pcMaxWidth = _pNativeFont->GetMaxWidth().ToInt();
373 int vcMaxWidth = _ResUtil::ConvertToVirCoordX(pcMaxWidth);
379 _FontImpl::GetMaxWidthF(void) const
382 IF_NOT_CONSTRUCTED(return -1.0f);
384 float pcMaxWidth = _pNativeFont->GetMaxWidth().ToFloat();
385 float vcMaxWidth = _ResUtil::ConvertToVirCoordX(pcMaxWidth);
391 _FontImpl::GetAscender(void) const
394 IF_NOT_CONSTRUCTED(return -1);
396 int pcAscender = _DoubleToIntForPos(ceil(_pNativeFont->GetAscender().ToDouble()));
398 for (int i = pcAscender; i < INT_MAX; i++)
400 if (_ResUtil::ConvertToPhyCoord(_ResUtil::ConvertToVirCoordY(i)) >= pcAscender)
407 int vcAscender = _ResUtil::ConvertToVirCoordY(pcAscender);
413 _FontImpl::GetAscenderF(void) const
416 IF_NOT_CONSTRUCTED(return -1.0f);
418 float pcAscender = float(ceil(_pNativeFont->GetAscender().ToDouble()));
419 float vcAscender = _ResUtil::ConvertToVirCoordY(pcAscender);
425 _FontImpl::GetDescender(void) const
428 IF_NOT_CONSTRUCTED(return -1);
430 int pcDescender = _DoubleToIntForPos(ceil(_pNativeFont->GetDescender().ToDouble()));
437 for (int i = pcDescender; i < INT_MAX; i++)
439 if (_ResUtil::ConvertToPhyCoord(_ResUtil::ConvertToVirCoordY(i)) >= pcDescender)
446 int vcDescender = _ResUtil::ConvertToVirCoordY(pcDescender);
452 _FontImpl::GetDescenderF(void) const
455 IF_NOT_CONSTRUCTED(return -1.0f);
457 float pcDescender = float(ceil(_pNativeFont->GetDescender().ToDouble()));
458 float vcDescender = _ResUtil::ConvertToVirCoordY(pcDescender);
460 if (vcDescender < 0.0f)
462 vcDescender *= -1.0f;
469 _FontImpl::GetLeftBear(wchar_t character, int& vcLeftBear) const
472 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
474 _Util::FixedPoint22_10 pcLeftBear(0);
475 result r = _pNativeFont->GetLeftBear(character, pcLeftBear);
480 vcLeftBear = _ResUtil::ConvertToVirCoordX(pcLeftBear.ToInt());
487 _FontImpl::GetLeftBear(wchar_t character, float& vcLeftBear) const
490 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
492 _Util::FixedPoint22_10 pcLeftBear(0);
493 result r = _pNativeFont->GetLeftBear(character, pcLeftBear);
497 vcLeftBear = _ResUtil::ConvertToVirCoordX(pcLeftBear.ToFloat());
504 _FontImpl::GetRightBear(wchar_t character, int& vcRightBear) const
507 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
509 _Util::FixedPoint22_10 pcRightBear(0);
510 result r = _pNativeFont->GetRightBear(character, pcRightBear);
515 vcRightBear = _ResUtil::ConvertToVirCoordX(pcRightBear.ToInt());
522 _FontImpl::GetRightBear(wchar_t character, float& vcRightBear) const
525 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
527 _Util::FixedPoint22_10 pcRightBear(0);
528 result r = _pNativeFont->GetRightBear(character, pcRightBear);
532 vcRightBear = _ResUtil::ConvertToVirCoordX(pcRightBear.ToFloat());
539 _FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, Dimension& vcDim, bool outline) const
542 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
546 if (_ResUtil::NeedToConvertCoord())
549 result r = _pNativeFont->GetTextExtent(INT_MAX, _Util::String(text.GetPointer(), text.GetLength(), 0, length), outline, dummyCount, pcDim);
553 vcDim = _ResUtil::ConvertToVirCoord(pcDim);
560 return _pNativeFont->GetTextExtent(INT_MAX, _Util::String(text.GetPointer(), text.GetLength(), 0, length), outline, dummyCount, vcDim);
565 _FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, FloatDimension& vcDim, bool outline) const
568 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
573 result r = _pNativeFont->GetTextExtent(INT_MAX, _Util::String(text.GetPointer(), text.GetLength(), 0, length), outline, dummyCount, pcDim);
577 vcDim.width = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.width));
578 vcDim.height = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.height));
585 _FontImpl::IsBold(void) const
588 IF_NOT_CONSTRUCTED(return false);
590 return _pNativeFont->IsBold();
594 _FontImpl::IsItalic(void) const
597 IF_NOT_CONSTRUCTED(return false);
599 return _pNativeFont->IsItalic();
603 _FontImpl::IsPlain(void) const
606 IF_NOT_CONSTRUCTED(return false);
608 return _pNativeFont->IsPlain();
612 _FontImpl::IsStrikeOut(void) const
615 IF_NOT_CONSTRUCTED(return false);
617 return _pNativeFont->IsStrikeOut();
621 _FontImpl::IsUnderlined(void) const
624 IF_NOT_CONSTRUCTED(return false);
626 return _pNativeFont->IsUnderlined();
630 _FontImpl::GetSize(void) const
633 IF_NOT_CONSTRUCTED(return -1);
635 return _pCoordHolder->size.required;
639 _FontImpl::GetSizeF(void) const
642 IF_NOT_CONSTRUCTED(return -1.0f);
644 return _pCoordHolder->sizeF.required;
648 _FontImpl::SetStrikeOut(bool strikeOut)
651 IF_NOT_CONSTRUCTED(return);
653 _pNativeFont->SetStrikeOut(strikeOut);
659 _FontImpl::SetUnderline(bool underline)
662 IF_NOT_CONSTRUCTED(return);
664 _pNativeFont->SetUnderline(underline);
670 _FontImpl::SetCharSpace(int vcSpace)
673 IF_NOT_CONSTRUCTED(return);
676 _pCoordHolder->charSpace = vcSpace;
679 int pcSpace = _ResUtil::ConvertToPhyCoordWidth(vcSpace);
681 _pNativeFont->SetCharSpace(pcSpace);
687 _FontImpl::SetCharSpace(float vcSpace)
690 IF_NOT_CONSTRUCTED(return);
693 _pCoordHolder->charSpaceF = vcSpace;
696 float pcSpace = _ResUtil::ConvertToPhyCoordWidth(vcSpace);
698 _pNativeFont->SetCharSpace(_FloatToIntForPos(pcSpace));
704 _FontImpl::GetCharSpace(void) const
707 IF_NOT_CONSTRUCTED(return 0);
709 return _pCoordHolder->charSpace.required;
713 _FontImpl::GetCharSpaceF(void) const
716 IF_NOT_CONSTRUCTED(return 0.0f);
718 return _pCoordHolder->charSpaceF.required;
722 _FontImpl::GetFaceName(void) const
725 IF_NOT_CONSTRUCTED(return "");
727 return _pNativeFont->GetFaceName();
730 Tizen::Base::Collection::IList*
731 _FontImpl::GetSystemFontListN(void)
734 return _Font::GetSystemFontListN();
738 _FontImpl::GetFaceName(const Tizen::Base::String& filePath)
741 return _Font::GetFaceName(filePath);
745 _FontImpl::CloneN(void)
748 IF_NOT_CONSTRUCTED(return null);
750 std::auto_ptr<_FontImpl> pFontImpl(new (std::nothrow) _FontImpl(*this));
752 SysTryReturn(NID_GRP, pFontImpl.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Failed to allocated memory");
753 SysTryReturn(NID_GRP, pFontImpl->_pNativeFont, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] FontEx::CloneN() has been failed");
755 return pFontImpl.release();
759 _FontImpl::CloneN(const Font& font)
763 // check the validation of input param
764 SysTryReturn(NID_GRP, font.__pImpl && font.__pImpl->IsConstructed(), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid input param given");
766 // make sure if the copy construction is well done
767 std::auto_ptr<Font> pFont(new (std::nothrow) Font(font));
769 SysTryReturn(NID_GRP, pFont.get() && pFont->__pImpl && pFont->__pImpl->IsConstructed(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory");
771 return pFont.release();
775 _FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, Dimension& vcDim) const
778 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
780 SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
781 "The length(%d) & startIndex(%d) of the given text is out of range", length, startIndex);
783 if (_ResUtil::NeedToConvertCoord())
785 int pcWidth = _ResUtil::ToPhyCoordW(vcWidth);
787 result r = _pNativeFont->GetTextExtent(pcWidth, _Util::String(text.GetPointer(), text.GetLength(), startIndex, length), outline, count, pcDim);
791 vcDim = _ResUtil::ConvertToVirCoord(pcDim);
798 return _pNativeFont->GetTextExtent(vcWidth, _Util::String(text.GetPointer(), text.GetLength(), startIndex, length), outline, count, vcDim);
803 _FontImpl::GetTextExtent(int vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, Dimension& vcDim) const
806 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
808 SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
809 "The length(%d) & startIndex(%d) of the given text is out of range", length, startIndex);
811 if (_ResUtil::NeedToConvertCoord())
813 int pcWidth = _ResUtil::ToPhyCoordW(vcWidth);
815 result r = _pNativeFont->GetTextExtent(pcWidth, _Util::String(text.GetPointer(), text.GetLength(), startIndex, length), outline, delimiter, count, pcDim);
819 vcDim = _ResUtil::ConvertToVirCoord(pcDim);
826 return _pNativeFont->GetTextExtent(vcWidth, _Util::String(text.GetPointer(), text.GetLength(), startIndex, length), outline, delimiter, count, vcDim);
831 _FontImpl::GetTextExtent(float vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, FloatDimension& vcDim) const
834 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
836 SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
837 "The length(%d) & startIndex(%d) of the given text is out of range", length, startIndex);
839 int pcWidth = _FloatToIntForPos(_ResUtil::ToPhyCoordW(vcWidth));
841 result r = _pNativeFont->GetTextExtent(pcWidth, _Util::String(text.GetPointer(), text.GetLength(), startIndex, length), outline, count, pcDim);
845 vcDim.width = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.width));
846 vcDim.height = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.height));
853 _FontImpl::GetTextExtent(float vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, const Tizen::Base::String& delimiter, int& count, FloatDimension& vcDim) const
856 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
858 SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < text.GetLength(), E_OUT_OF_RANGE,
859 "The length(%d) & startIndex(%d) of the given text is out of range", length, startIndex);
861 int pcWidth = _FloatToIntForPos(_ResUtil::ToPhyCoordW(vcWidth));
863 result r = _pNativeFont->GetTextExtent(pcWidth, _Util::String(text.GetPointer(), text.GetLength(), startIndex, length), outline, delimiter, count, pcDim);
867 vcDim.width = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.width));
868 vcDim.height = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.height));
875 _FontImpl::SetSize(int vcSize)
878 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
879 SysTryReturnResult(NID_GRP, vcSize > 0, E_INVALID_ARG, "Font size should be greater than 0");
881 _pCoordHolder->Reset(vcSize);
884 _Util::FixedPoint26_6 pcSize(_ResUtil::ConvertToPhyCoordHeight(vcSize));
886 if (vcSize > 0 && pcSize <= 1)
888 pcSize = _Util::FixedPoint26_6(1);
890 _pCoordHolder->size.phyCoord = 1;
891 _pCoordHolder->size.virCoord = vcSize;
894 result r = _pNativeFont->SetSize(pcSize);
895 SysTryReturnResult(NID_GRP, r == E_SUCCESS, E_SYSTEM, "Failed to set the size of _Font");
901 _FontImpl::SetSize(float vcSize)
904 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
905 SysTryReturnResult(NID_GRP, vcSize > 0.0f, E_INVALID_ARG, "Font size should be greater than 0");
907 _pCoordHolder->Reset(vcSize);
910 _Util::FixedPoint26_6 pcSize(_ResUtil::ConvertToPhyCoordHeight(vcSize));
912 if (vcSize > 0.0f && pcSize <= 1.0f)
914 pcSize = _Util::FixedPoint26_6(1.0f);
916 _pCoordHolder->sizeF.phyCoord = 1.0f;
917 _pCoordHolder->sizeF.virCoord = vcSize;
920 result r = _pNativeFont->SetSize(pcSize);
921 SysTryReturnResult(NID_GRP, r == E_SUCCESS, E_SYSTEM, "Failed to set the size of _Font");
927 _FontImpl::SetStyle(int style)
930 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
931 SysTryReturnResult(NID_GRP, style > FONT_STYLE_MIN && style <= (FONT_STYLE_PLAIN | FONT_STYLE_BOLD | FONT_STYLE_ITALIC), E_INVALID_ARG,
932 "Style(%d) is invalid", style);
934 result r = _pNativeFont->SetStyle(style);
935 SysTryReturnResult(NID_GRP, r == E_SUCCESS, E_SYSTEM, "Failed to set the style of _Font");
941 _FontImpl::GetStyle(void) const
944 IF_NOT_CONSTRUCTED(return FONT_STYLE_PLAIN);
946 return _pNativeFont->GetStyle();
950 _FontImpl::GetLeading(void) const
953 IF_NOT_CONSTRUCTED(return -1);
955 int pcLeading = _DoubleToIntForPos(ceil(_pNativeFont->GetLeading().ToDouble()));
957 for (int i = pcLeading; i < INT_MAX; i++)
959 if (_ResUtil::ConvertToPhyCoord(_ResUtil::ConvertToVirCoordY(i)) >= pcLeading)
966 int vcLeading = _ResUtil::ConvertToVirCoordY(pcLeading);
972 _FontImpl::GetLeadingF(void) const
975 IF_NOT_CONSTRUCTED(return -1.0f);
977 float pcLeading = float(ceil(_pNativeFont->GetLeading().ToDouble()));
978 float vcLeading = _ResUtil::ConvertToVirCoordY(pcLeading);
984 _FontImpl::GetInstance(Font& font)
987 return (&font != null) ? font.__pImpl : null;
991 _FontImpl::GetInstance(const Font& font)
994 return (&font != null) ? font.__pImpl : null;
998 _FontImpl::UpdateDefaultFont(const Tizen::Base::String& key)
1001 return _Font::UpdateDefaultFont(key);
1005 _FontImpl::GetTextExtentList(const Tizen::Base::String& string, int startIndex, int length, Tizen::Base::Collection::ArrayListT<_FloatPair>& outList) const
1008 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
1010 SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < string.GetLength(), E_OUT_OF_RANGE,
1011 "The length(%d) & startIndex(%d) of the given text is out of range", length, startIndex);
1013 _Util::String text(string.GetPointer(), string.GetLength(), startIndex, length);
1014 _Util::AccumList<_Util::Pair<int, int> > outAccumList;
1016 result r = _pNativeFont->GetTextExtentList(text, outAccumList);
1018 SysTryReturn(NID_GRP, r == E_SUCCESS, r, r, "[%s] Failed to get the internal text extent information", GetErrorMessage(r));
1020 outList.RemoveAll();
1022 for (_Util::AccumList<_Util::Pair<int, int> >::Iterator iter = outAccumList.Begin(); iter != outAccumList.End(); ++iter)
1026 _ResUtil::ConvertToVirCoord(static_cast<float>(iter->first)),
1027 _ResUtil::ConvertToVirCoord(static_cast<float>(iter->second))
1037 _FontImpl::__GetTextExtent(const wchar_t* text, int textLength, int length, FloatDimension& vcDim, bool outline) const
1039 // This method must synchronize with _FontImpl::GetTextExtent(const Tizen::Base::String& text, int length, FloatDimension& vcDim, bool outline)
1042 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
1047 result r = _pNativeFont->GetTextExtent(INT_MAX, _Util::String(text, textLength, 0, length), outline, dummyCount, pcDim);
1051 vcDim.width = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.width));
1052 vcDim.height = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.height));
1059 _FontImpl::__GetTextExtent(float vcWidth, const wchar_t* text, int textLength, int startIndex, int length, bool outline, int& count, FloatDimension& vcDim) const
1061 // This method must synchronize with _FontImpl::GetTextExtent(float vcWidth, const Tizen::Base::String& text, int startIndex, int length, bool outline, int& count, FloatDimension& vcDim)
1064 IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED);
1066 SysTryReturnResult(NID_GRP, startIndex >= 0 && length >= 0 && startIndex < textLength, E_OUT_OF_RANGE,
1067 "The length(%d) & startIndex(%d) of the given text is out of range", length, startIndex);
1069 int pcWidth = _FloatToIntForPos(_ResUtil::ToPhyCoordW(vcWidth));
1071 result r = _pNativeFont->GetTextExtent(pcWidth, _Util::String(text, textLength, startIndex, length), outline, count, pcDim);
1075 vcDim.width = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.width));
1076 vcDim.height = _ResUtil::ConvertToVirCoord(static_cast<float>(pcDim.height));
1082 }} // Tizen::Graphics
1085 namespace Tizen { namespace Graphics
1088 TextBidiHint _bidiHint = TEXT_BIDI_HINT_NONE;
1091 _SetTextBidiHint(TextBidiHint bidiHint)
1095 case TEXT_BIDI_HINT_NONE:
1096 case TEXT_BIDI_HINT_LTR:
1097 case TEXT_BIDI_HINT_RTL:
1098 _bidiHint = bidiHint;
1104 _GetTextBidiHint(void)
1109 }} // Tizen::Graphics
1112 namespace Tizen { namespace Graphics
1116 _SetTextBidiBase(TextBidiBase bidiBase)
1120 case TEXT_BIDI_BASE_LTR:
1121 _TextBidiUtil::SetTextBidiBase(true);
1123 case TEXT_BIDI_BASE_RTL:
1124 _TextBidiUtil::SetTextBidiBase(false);
1130 _GetTextBidiBase(void)
1132 return (_TextBidiUtil::IsTextBidiBaseLtr()) ? TEXT_BIDI_BASE_LTR : TEXT_BIDI_BASE_RTL;
1135 }} // Tizen::Graphics
1137 ////////////////////////////////////////////////////////////////////////////////
1139 // Temporary code for test case
1141 ////////////////////////////////////////////////////////////////////////////////
1145 #include "FGrp_FontUtil.h"
1147 namespace Tizen { namespace Graphics
1149 _OSP_EXPORT_ bool _TestGetTextExtentList(Tizen::Graphics::Font& font, const Tizen::Base::String& string, std::vector<std::pair<int, int> >& outList)
1151 _Font* pInternalFont = _GetFontEx(font);
1152 _Util::String text(string.GetPointer(), string.GetLength());
1153 _Util::AccumList<_Util::Pair<int, int> > outAccumList;
1155 if (pInternalFont->GetTextExtentList(text, outAccumList) != E_SUCCESS)
1162 for (_Util::AccumList<_Util::Pair<int, int> >::Iterator iter = outAccumList.Begin(); iter != outAccumList.End(); ++iter)
1164 outList.push_back(std::make_pair(iter->first, iter->second));
1170 }} // Tizen::Graphics