Mercurial > mplayer.hg
comparison libass/ass_font.c @ 21630:0d8005d2fe5c
Update some comments.
author | eugeni |
---|---|
date | Sun, 17 Dec 2006 12:00:55 +0000 |
parents | ef93ebaef504 |
children | 4a958bd08920 |
comparison
equal
deleted
inserted
replaced
21629:1cdd7e6e4e87 | 21630:0d8005d2fe5c |
---|---|
50 break; | 50 break; |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 /** | |
56 * \brief find a memory font by name | |
57 */ | |
55 static int find_font(ass_library_t* library, char* name) | 58 static int find_font(ass_library_t* library, char* name) |
56 { | 59 { |
57 int i; | 60 int i; |
58 for (i = 0; i < library->num_fontdata; ++i) | 61 for (i = 0; i < library->num_fontdata; ++i) |
59 if (strcasecmp(name, library->fontdata[i].name) == 0) | 62 if (strcasecmp(name, library->fontdata[i].name) == 0) |
60 return i; | 63 return i; |
61 return -1; | 64 return -1; |
62 } | 65 } |
63 | 66 |
67 /** | |
68 * \brief Create a new ass_font_t according to "desc" argument | |
69 */ | |
64 ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_priv, ass_font_desc_t* desc) | 70 ass_font_t* ass_font_new(ass_library_t* library, FT_Library ftlibrary, void* fc_priv, ass_font_desc_t* desc) |
65 { | 71 { |
66 char* path; | 72 char* path; |
67 int index; | 73 int index; |
68 FT_Face face; | 74 FT_Face face; |
114 ass_font_cache_add(font); | 120 ass_font_cache_add(font); |
115 | 121 |
116 return font; | 122 return font; |
117 } | 123 } |
118 | 124 |
125 /** | |
126 * \brief Set font transformation matrix and shift vector | |
127 **/ | |
119 void ass_font_set_transform(ass_font_t* font, FT_Matrix* m, FT_Vector* v) | 128 void ass_font_set_transform(ass_font_t* font, FT_Matrix* m, FT_Vector* v) |
120 { | 129 { |
121 int i; | 130 int i; |
122 font->m.xx = m->xx; | 131 font->m.xx = m->xx; |
123 font->m.xy = m->xy; | 132 font->m.xy = m->xy; |
127 font->v.y = v->y; | 136 font->v.y = v->y; |
128 for (i = 0; i < font->n_faces; ++i) | 137 for (i = 0; i < font->n_faces; ++i) |
129 FT_Set_Transform(font->faces[i], &font->m, &font->v); | 138 FT_Set_Transform(font->faces[i], &font->m, &font->v); |
130 } | 139 } |
131 | 140 |
141 /** | |
142 * \brief Set font size | |
143 **/ | |
132 void ass_font_set_size(ass_font_t* font, int size) | 144 void ass_font_set_size(ass_font_t* font, int size) |
133 { | 145 { |
134 int i; | 146 int i; |
135 if (font->size != size) { | 147 if (font->size != size) { |
136 font->size = size; | 148 font->size = size; |
138 FT_Set_Pixel_Sizes(font->faces[i], 0, size); | 150 FT_Set_Pixel_Sizes(font->faces[i], 0, size); |
139 } | 151 } |
140 } | 152 } |
141 | 153 |
142 #ifdef HAVE_FONTCONFIG | 154 #ifdef HAVE_FONTCONFIG |
155 /** | |
156 * \brief Select a new FT_Face with the given character | |
157 * The new face is added to the end of font->faces. | |
158 **/ | |
143 static void ass_font_reselect(void* fontconfig_priv, ass_font_t* font, uint32_t ch) | 159 static void ass_font_reselect(void* fontconfig_priv, ass_font_t* font, uint32_t ch) |
144 { | 160 { |
145 char* path; | 161 char* path; |
146 int index; | 162 int index; |
147 FT_Face face; | 163 FT_Face face; |
171 FT_Set_Transform(face, &font->m, &font->v); | 187 FT_Set_Transform(face, &font->m, &font->v); |
172 FT_Set_Pixel_Sizes(face, 0, font->size); | 188 FT_Set_Pixel_Sizes(face, 0, font->size); |
173 } | 189 } |
174 #endif | 190 #endif |
175 | 191 |
192 /** | |
193 * \brief Get maximal font ascender and descender. | |
194 * \param ch character code | |
195 * The values are extracted from the font face that provides glyphs for the given character | |
196 **/ | |
176 void ass_font_get_asc_desc(ass_font_t* font, uint32_t ch, int* asc, int* desc) | 197 void ass_font_get_asc_desc(ass_font_t* font, uint32_t ch, int* asc, int* desc) |
177 { | 198 { |
178 int i; | 199 int i; |
179 for (i = 0; i < font->n_faces; ++i) { | 200 for (i = 0; i < font->n_faces; ++i) { |
180 FT_Face face = font->faces[i]; | 201 FT_Face face = font->faces[i]; |
192 } | 213 } |
193 | 214 |
194 *asc = *desc = 0; | 215 *asc = *desc = 0; |
195 } | 216 } |
196 | 217 |
218 /** | |
219 * \brief Get a glyph | |
220 * \param ch character code | |
221 **/ | |
197 FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch) | 222 FT_Glyph ass_font_get_glyph(void* fontconfig_priv, ass_font_t* font, uint32_t ch) |
198 { | 223 { |
199 int error; | 224 int error; |
200 int index = 0; | 225 int index = 0; |
201 int i; | 226 int i; |
251 } | 276 } |
252 | 277 |
253 return glyph; | 278 return glyph; |
254 } | 279 } |
255 | 280 |
281 /** | |
282 * \brief Get kerning for the pair of glyphs. | |
283 **/ | |
256 FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2) | 284 FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2) |
257 { | 285 { |
258 FT_Vector v = {0, 0}; | 286 FT_Vector v = {0, 0}; |
259 int i; | 287 int i; |
260 | 288 |
271 return v; | 299 return v; |
272 } | 300 } |
273 return v; | 301 return v; |
274 } | 302 } |
275 | 303 |
304 /** | |
305 * \brief Deallocate ass_font_t | |
306 **/ | |
276 void ass_font_free(ass_font_t* font) | 307 void ass_font_free(ass_font_t* font) |
277 { | 308 { |
278 int i; | 309 int i; |
279 for (i = 0; i < font->n_faces; ++i) | 310 for (i = 0; i < font->n_faces; ++i) |
280 if (font->faces[i]) FT_Done_Face(font->faces[i]); | 311 if (font->faces[i]) FT_Done_Face(font->faces[i]); |