summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-07-20 00:18:55 +0200
committerGrigori Goronzy <greg@blackbox>2009-07-20 00:18:55 +0200
commit0ba4d4ceb16c1d3d678bcab63506ae6671b87889 (patch)
tree433851d22035fec8fdfef9f0d607a4150eeee7c0
parent5f0aa788e9342db7c9ec0d4cd08f5bf19d85bbaa (diff)
downloadlibass-0ba4d4ceb16c1d3d678bcab63506ae6671b87889.tar.bz2
libass-0ba4d4ceb16c1d3d678bcab63506ae6671b87889.tar.xz
Font metrics: prefer OS/2 table for ascender/descender
If possible, use ascender/descender from the OS/2 TTF table. This is another try to get libass to match VSFilter in regard to vertical font metrics.
-rw-r--r--libass/ass_font.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c
index 35d34cf..8a93a4e 100644
--- a/libass/ass_font.c
+++ b/libass/ass_font.c
@@ -46,8 +46,8 @@ static void charmap_magic(ass_library_t *library, FT_Face face)
FT_CharMap cmap = face->charmaps[i];
unsigned pid = cmap->platform_id;
unsigned eid = cmap->encoding_id;
- if (pid == 3 /*microsoft */
- && (eid == 1 /*unicode bmp */
+ if (pid == 3 /*microsoft */
+ && (eid == 1 /*unicode bmp */
|| eid == 10 /*full unicode */ )) {
FT_Set_Charmap(face, cmap);
return;
@@ -267,10 +267,16 @@ void ass_font_get_asc_desc(ass_font_t *font, uint32_t ch, int *asc,
int i;
for (i = 0; i < font->n_faces; ++i) {
FT_Face face = font->faces[i];
+ TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
if (FT_Get_Char_Index(face, ch)) {
int y_scale = face->size->metrics.y_scale;
- *asc = FT_MulFix(face->ascender, y_scale);
- *desc = FT_MulFix(-face->descender, y_scale);
+ if (os2) {
+ *asc = FT_MulFix(os2->usWinAscent, y_scale);
+ *desc = FT_MulFix(os2->usWinDescent, y_scale);
+ } else {
+ *asc = FT_MulFix(face->ascender, y_scale);
+ *desc = FT_MulFix(-face->descender, y_scale);
+ }
return;
}
}