aboutsummaryrefslogtreecommitdiffhomepage
path: root/libass
diff options
context:
space:
mode:
authorGravatar eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-08-03 15:22:55 +0000
committerGravatar eugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2007-08-03 15:22:55 +0000
commit6f90765a4067af30ab0c2cab107147476088718d (patch)
tree6abb0dcdd25ee34b3d759cf9e32b87cdfa1493b5 /libass
parent66d6320b51ed477de8014262aa0e5fa83cb0931a (diff)
Workaround for fonts with zero ascender/descender in horizontal header.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24002 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_font.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libass/ass_font.c b/libass/ass_font.c
index 77a585fcaf..b93c41e1b1 100644
--- a/libass/ass_font.c
+++ b/libass/ass_font.c
@@ -89,6 +89,25 @@ static int find_font(ass_library_t* library, char* name)
static void face_set_size(FT_Face face, double size);
+static void buggy_font_workaround(FT_Face face)
+{
+ // Some fonts have zero Ascender/Descender fields in 'hhea' table.
+ // In this case, get the information from 'os2' table or, as
+ // a last resort, from face.bbox.
+ if (face->ascender + face->descender == 0 || face->height == 0) {
+ TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
+ if (os2) {
+ face->ascender = os2->sTypoAscender;
+ face->descender = os2->sTypoDescender;
+ face->height = face->ascender - face->descender;
+ } else {
+ face->ascender = face->bbox.yMax;
+ face->descender = face->bbox.yMin;
+ face->height = face->ascender - face->descender;
+ }
+ }
+}
+
/**
* \brief Select a face with the given charcode and add it to ass_font_t
* \return index of the new face in font->faces, -1 if failed
@@ -123,6 +142,7 @@ static int add_face(void* fc_priv, ass_font_t* font, uint32_t ch)
}
}
charmap_magic(face);
+ buggy_font_workaround(face);
font->faces[font->n_faces++] = face;
update_transform(font);