Mercurial > mplayer.hg
comparison libass/ass_font.c @ 21614:5d2ca7ca18b5
Move ascender, descender, and kerning computation to ass_font.c.
author | eugeni |
---|---|
date | Sat, 16 Dec 2006 19:17:50 +0000 |
parents | 62bd8e0d3a0f |
children | 62989854d340 |
comparison
equal
deleted
inserted
replaced
21613:8547ae79e74b | 21614:5d2ca7ca18b5 |
---|---|
176 FT_Set_Transform(font->face, &font->m, &font->v); | 176 FT_Set_Transform(font->face, &font->m, &font->v); |
177 FT_Set_Pixel_Sizes(font->face, 0, font->size); | 177 FT_Set_Pixel_Sizes(font->face, 0, font->size); |
178 } | 178 } |
179 #endif | 179 #endif |
180 | 180 |
181 void ass_font_get_asc_desc(ass_font_t* font, uint32_t ch, int* asc, int* desc) | |
182 { | |
183 FT_Face face = font->face; | |
184 if (FT_Get_Char_Index(face, ch)) { | |
185 int v, v2; | |
186 v = face->size->metrics.ascender; | |
187 v2 = FT_MulFix(face->bbox.yMax, face->size->metrics.y_scale); | |
188 *asc = (v > v2 * 0.9) ? v : v2; | |
189 | |
190 v = - face->size->metrics.descender; | |
191 v2 = - FT_MulFix(face->bbox.yMin, face->size->metrics.y_scale); | |
192 *desc = (v > v2 * 0.9) ? v : v2; | |
193 return; | |
194 } | |
195 | |
196 *asc = *desc = 0; | |
197 } | |
198 | |
181 FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch) | 199 FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch) |
182 { | 200 { |
183 int error; | 201 int error; |
184 int index; | 202 int index; |
185 FT_Glyph glyph; | 203 FT_Glyph glyph; |
224 } | 242 } |
225 | 243 |
226 return glyph; | 244 return glyph; |
227 } | 245 } |
228 | 246 |
247 FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2) | |
248 { | |
249 FT_Vector v = {0, 0}; | |
250 int i1, i2; | |
251 | |
252 if (!FT_HAS_KERNING(font->face)) | |
253 return v; | |
254 i1 = FT_Get_Char_Index(font->face, c1); | |
255 i2 = FT_Get_Char_Index(font->face, c2); | |
256 if (i1 && i2) | |
257 FT_Get_Kerning(font->face, i1, i2, FT_KERNING_DEFAULT, &v); | |
258 return v; | |
259 } | |
260 | |
229 void ass_font_free(ass_font_t* font) | 261 void ass_font_free(ass_font_t* font) |
230 { | 262 { |
231 if (font->face) FT_Done_Face(font->face); | 263 if (font->face) FT_Done_Face(font->face); |
232 if (font->path) free(font->path); | 264 if (font->path) free(font->path); |
233 if (font->desc.family) free(font->desc.family); | 265 if (font->desc.family) free(font->desc.family); |