aboutsummaryrefslogtreecommitdiff
path: root/guilib/GUIFontTTF.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'guilib/GUIFontTTF.cpp')
-rw-r--r--guilib/GUIFontTTF.cpp38
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))
{