From e8032bc820dd0079db103165cf3d4d84f429edb7 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Wed, 12 Aug 2009 05:26:55 +0200 Subject: 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. --- libass/ass_font.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) 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" @@ -367,6 +368,22 @@ static int ass_strike_outline_glyph(FT_Face face, ASS_Font *font, return 1; } +/** + * 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) { -- cgit v1.2.3