From aee4ab78012ee10824083a24c192761e8d0ff29f Mon Sep 17 00:00:00 2001 From: Sungyeon Woo Date: Fri, 9 Aug 2013 18:49:54 +0900 Subject: [PATCH] add FontImpl::SetXExpansion(float) Change-Id: Ic3cce7f77a59b2f57f66ff04d8c96c7715ed2ce4 Signed-off-by: Sungyeon Woo --- src/graphics/FGrp_Font.cpp | 19 +++++++++++++++---- src/graphics/FGrp_Font.h | 4 ++++ src/graphics/FGrp_FontFt2.cpp | 18 +++++++++++------- src/graphics/FGrp_FontImpl.cpp | 10 ++++++++++ src/graphics/FGrp_IFont.h | 2 +- src/graphics/inc/FGrp_FontImpl.h | 2 ++ 6 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/graphics/FGrp_Font.cpp b/src/graphics/FGrp_Font.cpp index 84298db..65e8b83 100644 --- a/src/graphics/FGrp_Font.cpp +++ b/src/graphics/FGrp_Font.cpp @@ -789,6 +789,14 @@ _Font::GetSize(void) const return __fontAttrib.size; } +result +_Font::SetXExpansion(_Util::FixedPoint26_6 xExpansion) +{ + __fontAttrib.xExpansion = xExpansion; + + return E_SUCCESS; +} + void _Font::SetStrikeOut(bool strikeout) { @@ -838,7 +846,6 @@ _Font::GetSystemFontListN(void) SysTryReturn(NID_GRP, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); return pList.release(); - } Tizen::Base::String @@ -892,6 +899,7 @@ _Font::ApplyAttribute() fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; + fontAttrib.xExpansion = __fontAttrib.xExpansion; rtn = __pNativeFont->SetAttrib(fontAttrib); SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to set font attribute"); @@ -1102,6 +1110,7 @@ _Font::__GetTextExtentEx(int width, const _Util::String& text, bool outline, int fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; + fontAttrib.xExpansion = __fontAttrib.xExpansion; rtn = pFont->SetAttrib(fontAttrib); //SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to set font attribute"); } @@ -1272,6 +1281,7 @@ _Font::__GetTextExtent(int width, const _Util::String& text, bool outline, int& fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; + fontAttrib.xExpansion = __fontAttrib.xExpansion; rtn = pFont->SetAttrib(fontAttrib); //SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to set font attribute"); } @@ -1444,6 +1454,7 @@ _Font::__GetTextExtentList(const _Util::String& text, _Util::AccumList<_Util::Pa fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; + fontAttrib.xExpansion = __fontAttrib.xExpansion; pFont->SetAttrib(fontAttrib); } } @@ -1568,7 +1579,7 @@ _Font::__GetTextExtentList(_TextBidiPropertyWithReorder& bidiProperty, _Util::Ac fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; - + fontAttrib.xExpansion = __fontAttrib.xExpansion; textFragment->pUsingFont->SetAttrib(fontAttrib); } } @@ -1854,7 +1865,7 @@ _Font::__DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; - + fontAttrib.xExpansion = __fontAttrib.xExpansion; textFragment->pUsingFont->SetAttrib(fontAttrib); } } @@ -2013,7 +2024,7 @@ _Font::__DrawText(_Canvas& canvas, const Point& point, const Tizen::Base::String fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_BOLD) ? _IFont::STYLE_BOLD : 0; fontAttrib.style |= (__fontAttrib.style & FONT_STYLE_ITALIC) ? _IFont::STYLE_ITALIC : 0; fontAttrib.style |= (__fontAttrib.underline) ? _IFont::STYLE_UNDERLINE : 0; - + fontAttrib.xExpansion = __fontAttrib.xExpansion; rtn = pFont->SetAttrib(fontAttrib); //SysTryReturn(NID_GRP, rtn, false, E_SYSTEM, "[E_SYSTEM] Failed to set font attribute"); } diff --git a/src/graphics/FGrp_Font.h b/src/graphics/FGrp_Font.h index bdbf2da..b2f9708 100644 --- a/src/graphics/FGrp_Font.h +++ b/src/graphics/FGrp_Font.h @@ -72,6 +72,7 @@ struct _FontAttribute int lineThickness; bool strikeout; bool underline; + _Util::FixedPoint26_6 xExpansion; void Init() { @@ -86,6 +87,7 @@ struct _FontAttribute lineThickness = -1; strikeout = false; underline = false; + xExpansion.Reset(_Util::FixedPoint26_6(1.0f)); } }; @@ -122,6 +124,8 @@ public: _Util::FixedPoint26_6 GetSize(void) const; + result SetXExpansion(_Util::FixedPoint26_6 xExpansion); + void SetStrikeOut(bool strikeOut); void SetUnderline(bool underline); diff --git a/src/graphics/FGrp_FontFt2.cpp b/src/graphics/FGrp_FontFt2.cpp index 179a286..312e573 100644 --- a/src/graphics/FGrp_FontFt2.cpp +++ b/src/graphics/FGrp_FontFt2.cpp @@ -184,8 +184,8 @@ _FontFt2::_FontFt2() __fontAttrib.angle = 0.0f; __fontAttrib.style = _IFont::STYLE_NONE; __fontAttrib.quality = _IFont::QUALITY_HIGH; - __fontAttrib.xExpansion = 100; - __fontAttrib.boldWeight = _Util::FixedPoint26_6(1.0f); + __fontAttrib.xExpansion.Reset(_Util::FixedPoint26_6(1.0f)); + __fontAttrib.boldWeight.Reset(_Util::FixedPoint26_6(1.0f)); #ifdef USE_HASHMAP_FOR_FONT __fallbackFontMap.Construct(1, 0, _fontHashCodeProviderEx, _fontComparerEx); @@ -474,6 +474,11 @@ _FontFt2::AddCache(unsigned long glyphIndex, _Util::FixedPoint26_6 size, int sty return false; } + if (__fontAttrib.xExpansion != 1.0f) + { + return false; + } + return (__fontCache.get()) ? __fontCache->Add(glyphIndex, size, style, pGlyph) : false; } @@ -493,8 +498,7 @@ _FontFt2::SetAttrib(const Attrib& fontAttrib) if (!(fontAttrib.size >= 1) || !(fontAttrib.quality >= 0 && fontAttrib.quality <= 3) || - !(fontAttrib.xExpansion >= 1) || - !(fontAttrib.size.ToInt() * fontAttrib.xExpansion >= _DEFAULT_RES) || + !(fontAttrib.xExpansion > 0.0f) || !(fontAttrib.boldWeight > 0)) { return false; @@ -1205,7 +1209,7 @@ _FontFt2::__SetTransMatrix(void* pMatrix) if (_IsEqual(0.0f, __fontAttrib.angle)) { // apply font size - pTrans->xx = (FT_Fixed) (0x10000 * (__fontAttrib.xExpansion)) / 100; + pTrans->xx = (FT_Fixed) 0x10000 * __fontAttrib.xExpansion.ToDouble(); pTrans->xy = (FT_Fixed) 0; pTrans->yx = (FT_Fixed) 0; pTrans->yy = (FT_Fixed) 0x10000; @@ -1224,9 +1228,9 @@ _FontFt2::__SetTransMatrix(void* pMatrix) { double radAngle = __fontAttrib.angle * radian; - pTrans->xx = (FT_Fixed) (cos(radAngle) * (__fontAttrib.xExpansion) * 0x10000) / 100; + pTrans->xx = (FT_Fixed) (cos(radAngle) * __fontAttrib.xExpansion.ToDouble() * 0x10000); pTrans->xy = (FT_Fixed) (-sin(radAngle) * 0x10000); - pTrans->yx = (FT_Fixed) (sin(radAngle) * (__fontAttrib.xExpansion) * 0x10000) / 100; + pTrans->yx = (FT_Fixed) (sin(radAngle) * __fontAttrib.xExpansion.ToDouble() * 0x10000); pTrans->yy = (FT_Fixed) (cos(radAngle) * 0x10000); // apply italic style diff --git a/src/graphics/FGrp_FontImpl.cpp b/src/graphics/FGrp_FontImpl.cpp index 792b9c5..9040e28 100644 --- a/src/graphics/FGrp_FontImpl.cpp +++ b/src/graphics/FGrp_FontImpl.cpp @@ -697,6 +697,16 @@ _FontImpl::GetSizeF(void) const return _pCoordHolder->size.vcFloatActual; } +result +_FontImpl::SetXExpansion(float xExpansion) +{ + CRITICAL_SECTION; + IF_NOT_CONSTRUCTED(return E_OPERATION_FAILED); + SysTryReturnResult(NID_GRP, xExpansion > 0.0f, E_INVALID_ARG, "Expansion value should be greater than 0"); + + return _pNativeFont->SetXExpansion(_Util::FixedPoint26_6(xExpansion)); +} + void _FontImpl::SetStrikeOut(bool strikeOut) { diff --git a/src/graphics/FGrp_IFont.h b/src/graphics/FGrp_IFont.h index cb2ccf3..838b77e 100644 --- a/src/graphics/FGrp_IFont.h +++ b/src/graphics/FGrp_IFont.h @@ -91,7 +91,7 @@ public: unsigned int style; //!< Style of the font. (_IFont::Style) int quality; //!< Quality of the font. (_IFont::Quality) float angle; //!< Angle of the font. - long xExpansion; //!< Expansion of the font. + _Util::FixedPoint26_6 xExpansion; //!< Expansion of the font. _Util::FixedPoint26_6 boldWeight; //!< Bold weight of the font }; diff --git a/src/graphics/inc/FGrp_FontImpl.h b/src/graphics/inc/FGrp_FontImpl.h index f6d4738..5fa222a 100644 --- a/src/graphics/inc/FGrp_FontImpl.h +++ b/src/graphics/inc/FGrp_FontImpl.h @@ -114,6 +114,8 @@ public: int GetSize(void) const; float GetSizeF(void) const; + result SetXExpansion(float xExpansion); + void SetStrikeOut(bool strikeOut); void SetUnderline(bool underline); -- 2.7.4