comparison libass/ass_font.c @ 23982:17b5fa69243c

Workaround for fonts with zero ascender/descender in horizontal header.
author eugeni
date Fri, 03 Aug 2007 15:22:55 +0000
parents 705628816d98
children 90038c72d69e
comparison
equal deleted inserted replaced
23981:705628816d98 23982:17b5fa69243c
87 return -1; 87 return -1;
88 } 88 }
89 89
90 static void face_set_size(FT_Face face, double size); 90 static void face_set_size(FT_Face face, double size);
91 91
92 static void buggy_font_workaround(FT_Face face)
93 {
94 // Some fonts have zero Ascender/Descender fields in 'hhea' table.
95 // In this case, get the information from 'os2' table or, as
96 // a last resort, from face.bbox.
97 if (face->ascender + face->descender == 0 || face->height == 0) {
98 TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
99 if (os2) {
100 face->ascender = os2->sTypoAscender;
101 face->descender = os2->sTypoDescender;
102 face->height = face->ascender - face->descender;
103 } else {
104 face->ascender = face->bbox.yMax;
105 face->descender = face->bbox.yMin;
106 face->height = face->ascender - face->descender;
107 }
108 }
109 }
110
92 /** 111 /**
93 * \brief Select a face with the given charcode and add it to ass_font_t 112 * \brief Select a face with the given charcode and add it to ass_font_t
94 * \return index of the new face in font->faces, -1 if failed 113 * \return index of the new face in font->faces, -1 if failed
95 */ 114 */
96 static int add_face(void* fc_priv, ass_font_t* font, uint32_t ch) 115 static int add_face(void* fc_priv, ass_font_t* font, uint32_t ch)
121 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningFont, path, index); 140 mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_ErrorOpeningFont, path, index);
122 return -1; 141 return -1;
123 } 142 }
124 } 143 }
125 charmap_magic(face); 144 charmap_magic(face);
145 buggy_font_workaround(face);
126 146
127 font->faces[font->n_faces++] = face; 147 font->faces[font->n_faces++] = face;
128 update_transform(font); 148 update_transform(font);
129 face_set_size(face, font->size); 149 face_set_size(face, font->size);
130 return font->n_faces - 1; 150 return font->n_faces - 1;