diff options
author | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-12-16 19:17:50 +0000 |
---|---|---|
committer | eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-12-16 19:17:50 +0000 |
commit | 480ebb8a0ad161f8fc3c1e32389d22c084b387d2 (patch) | |
tree | aeed0aec41ef8da2adcd5ab2a5025d59b3df66a2 /libass/ass_font.c | |
parent | 44b83998075b66c2733c1186fbcd64ea7b2af192 (diff) | |
download | libass-480ebb8a0ad161f8fc3c1e32389d22c084b387d2.tar.bz2 libass-480ebb8a0ad161f8fc3c1e32389d22c084b387d2.tar.xz |
Move ascender, descender, and kerning computation to ass_font.c.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21630 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass/ass_font.c')
-rw-r--r-- | libass/ass_font.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c index 80490fa..c09a05a 100644 --- a/libass/ass_font.c +++ b/libass/ass_font.c @@ -178,6 +178,24 @@ static void ass_font_reselect(void* fontconfig_priv, ass_font_t* font) } #endif +void ass_font_get_asc_desc(ass_font_t* font, uint32_t ch, int* asc, int* desc) +{ + FT_Face face = font->face; + if (FT_Get_Char_Index(face, ch)) { + int v, v2; + v = face->size->metrics.ascender; + v2 = FT_MulFix(face->bbox.yMax, face->size->metrics.y_scale); + *asc = (v > v2 * 0.9) ? v : v2; + + v = - face->size->metrics.descender; + v2 = - FT_MulFix(face->bbox.yMin, face->size->metrics.y_scale); + *desc = (v > v2 * 0.9) ? v : v2; + return; + } + + *asc = *desc = 0; +} + FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch) { int error; @@ -226,6 +244,20 @@ FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch return glyph; } +FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2) +{ + FT_Vector v = {0, 0}; + int i1, i2; + + if (!FT_HAS_KERNING(font->face)) + return v; + i1 = FT_Get_Char_Index(font->face, c1); + i2 = FT_Get_Char_Index(font->face, c2); + if (i1 && i2) + FT_Get_Kerning(font->face, i1, i2, FT_KERNING_DEFAULT, &v); + return v; +} + void ass_font_free(ass_font_t* font) { if (font->face) FT_Done_Face(font->face); |