diff options
author | jmarshallnz <jmarshallnz@svn> | 2010-07-24 06:13:30 +0000 |
---|---|---|
committer | jmarshallnz <jmarshallnz@svn> | 2010-07-24 06:13:30 +0000 |
commit | f9abc951435cb503caf0da090b2d7cd310577851 (patch) | |
tree | 27cee73c0f807c950bbddc29ab8028d27c677fa7 /guilib/GUIFontTTF.cpp | |
parent | 7bff444b2cf246db0501fc5f987fc2e210c71672 (diff) |
merged: r32114-r32117
changed: Switch RenderOutline to use a separate border font, inflated by freetype rather than re-rendering the same text over and over. Fixes #9713. (cherry picked from commit e3c5d99a34be15fd30c91f56897f3b032acb090d)
added: Ticket #9680 - Better timecode based seeking in videos, thanks to David Byers (cherry picked from commit b4169ad27ae2e9b890c9e1d8286b23fe82daeac3)
changed: Move OSD toggling action handling into GUIWindowFullScreen (cherry picked from commit 812652466a455eec9309eb37642077ce734e0be7)
changed: map enter/select buttons to select in fullscreen video, to aid in entering timecodes. (cherry picked from commit 1222cc5c53b8cd0aede3f403499b8f27ed7e6088)
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/branches/Dharma@32120 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib/GUIFontTTF.cpp')
-rw-r--r-- | guilib/GUIFontTTF.cpp | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/guilib/GUIFontTTF.cpp b/guilib/GUIFontTTF.cpp index 93aba4c9d7..5270844199 100644 --- a/guilib/GUIFontTTF.cpp +++ b/guilib/GUIFontTTF.cpp @@ -40,6 +40,7 @@ #include FT_FREETYPE_H #include FT_GLYPH_H #include FT_OUTLINE_H +#include FT_STROKER_H #define USE_RELEASE_LIBS @@ -99,12 +100,30 @@ public: return face; }; + + FT_Stroker GetStroker() + { + if (!m_library) + return NULL; + + FT_Stroker stroker; + if (FT_Stroker_New(m_library, &stroker)) + return NULL; + + return stroker; + }; void ReleaseFont(FT_Face face) { assert(face); FT_Done_Face(face); }; + + void ReleaseStroker(FT_Stroker stroker) + { + assert(stroker); + FT_Stroker_Done(stroker); + } unsigned int GetDPI() const { @@ -129,6 +148,7 @@ CGUIFontTTFBase::CGUIFontTTFBase(const CStdString& strFileName) m_vertex = (SVertex*)malloc(m_vertex_size * sizeof(SVertex)); m_face = NULL; + m_stroker = NULL; memset(m_charquick, 0, sizeof(m_charquick)); m_strFileName = strFileName; m_referenceCount = 0; @@ -197,13 +217,16 @@ void CGUIFontTTFBase::Clear() if (m_face) g_freeTypeLibrary.ReleaseFont(m_face); m_face = NULL; + if (m_stroker) + g_freeTypeLibrary.ReleaseStroker(m_stroker); + m_stroker = NULL; free(m_vertex); m_vertex = NULL; m_vertex_count = 0; } -bool CGUIFontTTFBase::Load(const CStdString& strFilename, float height, float aspect, float lineSpacing) +bool CGUIFontTTFBase::Load(const CStdString& strFilename, float height, float aspect, float lineSpacing, bool border) { // we now know that this object is unique - only the GUIFont objects are non-unique, so no need // for reference tracking these fonts @@ -212,6 +235,17 @@ bool CGUIFontTTFBase::Load(const CStdString& strFilename, float height, float as if (!m_face) return false; + if (border) + { + m_stroker = g_freeTypeLibrary.GetStroker(); + + FT_Pos strength = FT_MulFix( m_face->units_per_EM, m_face->size->metrics.y_scale) / 16; + if (strength < 128) strength = 128; + + if (m_stroker) + FT_Stroker_Set(m_stroker, strength, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0); + } + // grab the maximum cell height and width unsigned int m_cellWidth = m_face->bbox.xMax - m_face->bbox.xMin; m_cellHeight = m_face->bbox.yMax - m_face->bbox.yMin; @@ -517,6 +551,8 @@ bool CGUIFontTTFBase::CacheCharacter(wchar_t letter, uint32_t style, Character * CLog::Log(LOGDEBUG, "%s Failed to get glyph %x", __FUNCTION__, letter); return false; } + if (m_stroker) + FT_Glyph_StrokeBorder(&glyph, m_stroker, 0, 1); // render the glyph if (FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, NULL, 1)) { |