summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-08-12 05:26:55 +0200
committerGrigori Goronzy <greg@blackbox>2009-08-12 05:29:22 +0200
commite8032bc820dd0079db103165cf3d4d84f429edb7 (patch)
tree0be40e4016cf6d0ae1d6e6325e134cf2be4c7a5e
parentd30a7c6921e25d3c3430d7f3c6ea5537a167b69b (diff)
downloadlibass-e8032bc820dd0079db103165cf3d4d84f429edb7.tar.bz2
libass-e8032bc820dd0079db103165cf3d4d84f429edb7.tar.xz
Add glyph emboldening fallback
Fallback to embolden manually with FreeType in case a bold face was requested, but no bold variant is available. The glyphs are slightly emboldened (much less than FT_GlyphSlot_Embolden would do) and the metrics are not touched at all.
-rw-r--r--libass/ass_font.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c
index e6da4bc..b4e4046 100644
--- a/libass/ass_font.c
+++ b/libass/ass_font.c
@@ -26,6 +26,7 @@
#include FT_SYNTHESIS_H
#include FT_GLYPH_H
#include FT_TRUETYPE_TABLES_H
+#include FT_OUTLINE_H
#include "ass.h"
#include "ass_library.h"
@@ -368,6 +369,22 @@ static int ass_strike_outline_glyph(FT_Face face, ASS_Font *font,
}
/**
+ * Slightly embold a glyph without touching its metrics
+ */
+static void ass_glyph_embolden(FT_GlyphSlot slot)
+{
+ int str;
+
+ if (slot->format != FT_GLYPH_FORMAT_OUTLINE)
+ return;
+
+ str = FT_MulFix(slot->face->units_per_EM,
+ slot->face->size->metrics.y_scale) / 64;
+
+ FT_Outline_Embolden(&slot->outline, str);
+}
+
+/**
* \brief Get a glyph
* \param ch character code
**/
@@ -443,6 +460,11 @@ FT_Glyph ass_font_get_glyph(void *fontconfig_priv, ASS_Font *font,
(font->desc.italic > 55)) {
FT_GlyphSlot_Oblique(face->glyph);
}
+
+ if (!(face->style_flags & FT_STYLE_FLAG_BOLD) &&
+ (font->desc.bold > 80)) {
+ ass_glyph_embolden(face->glyph);
+ }
#endif
error = FT_Get_Glyph(face->glyph, &glyph);
if (error) {