OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ftglyph.c */ | 3 /* ftglyph.c */ |
4 /* */ | 4 /* */ |
5 /* FreeType convenience functions to handle glyphs (body). */ | 5 /* FreeType convenience functions to handle glyphs (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 1996-2005, 2007, 2008, 2010, 2012-2014 by */ | 7 /* Copyright 1996-2015 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 glyph->top = slot->bitmap_top; | 75 glyph->top = slot->bitmap_top; |
76 | 76 |
77 /* do lazy copying whenever possible */ | 77 /* do lazy copying whenever possible */ |
78 if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) | 78 if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) |
79 { | 79 { |
80 glyph->bitmap = slot->bitmap; | 80 glyph->bitmap = slot->bitmap; |
81 slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; | 81 slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP; |
82 } | 82 } |
83 else | 83 else |
84 { | 84 { |
85 FT_Bitmap_New( &glyph->bitmap ); | 85 FT_Bitmap_Init( &glyph->bitmap ); |
86 error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap ); | 86 error = FT_Bitmap_Copy( library, &slot->bitmap, &glyph->bitmap ); |
87 } | 87 } |
88 | 88 |
89 Exit: | 89 Exit: |
90 return error; | 90 return error; |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 FT_CALLBACK_DEF( FT_Error ) | 94 FT_CALLBACK_DEF( FT_Error ) |
95 ft_bitmap_glyph_copy( FT_Glyph bitmap_source, | 95 ft_bitmap_glyph_copy( FT_Glyph bitmap_source, |
(...skipping 23 matching lines...) Expand all Loading... |
119 | 119 |
120 | 120 |
121 FT_CALLBACK_DEF( void ) | 121 FT_CALLBACK_DEF( void ) |
122 ft_bitmap_glyph_bbox( FT_Glyph bitmap_glyph, | 122 ft_bitmap_glyph_bbox( FT_Glyph bitmap_glyph, |
123 FT_BBox* cbox ) | 123 FT_BBox* cbox ) |
124 { | 124 { |
125 FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph; | 125 FT_BitmapGlyph glyph = (FT_BitmapGlyph)bitmap_glyph; |
126 | 126 |
127 | 127 |
128 cbox->xMin = glyph->left << 6; | 128 cbox->xMin = glyph->left << 6; |
129 cbox->xMax = cbox->xMin + ( glyph->bitmap.width << 6 ); | 129 cbox->xMax = cbox->xMin + (FT_Pos)( glyph->bitmap.width << 6 ); |
130 cbox->yMax = glyph->top << 6; | 130 cbox->yMax = glyph->top << 6; |
131 cbox->yMin = cbox->yMax - ( glyph->bitmap.rows << 6 ); | 131 cbox->yMin = cbox->yMax - (FT_Pos)( glyph->bitmap.rows << 6 ); |
132 } | 132 } |
133 | 133 |
134 | 134 |
135 FT_DEFINE_GLYPH(ft_bitmap_glyph_class, | 135 FT_DEFINE_GLYPH(ft_bitmap_glyph_class, |
136 sizeof ( FT_BitmapGlyphRec ), | 136 sizeof ( FT_BitmapGlyphRec ), |
137 FT_GLYPH_FORMAT_BITMAP, | 137 FT_GLYPH_FORMAT_BITMAP, |
138 | 138 |
139 ft_bitmap_glyph_init, | 139 ft_bitmap_glyph_init, |
140 ft_bitmap_glyph_done, | 140 ft_bitmap_glyph_done, |
141 ft_bitmap_glyph_copy, | 141 ft_bitmap_glyph_copy, |
(...skipping 24 matching lines...) Expand all Loading... |
166 | 166 |
167 | 167 |
168 /* check format in glyph slot */ | 168 /* check format in glyph slot */ |
169 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) | 169 if ( slot->format != FT_GLYPH_FORMAT_OUTLINE ) |
170 { | 170 { |
171 error = FT_THROW( Invalid_Glyph_Format ); | 171 error = FT_THROW( Invalid_Glyph_Format ); |
172 goto Exit; | 172 goto Exit; |
173 } | 173 } |
174 | 174 |
175 /* allocate new outline */ | 175 /* allocate new outline */ |
176 error = FT_Outline_New( library, source->n_points, source->n_contours, | 176 error = FT_Outline_New( library, |
| 177 (FT_UInt)source->n_points, |
| 178 source->n_contours, |
177 &glyph->outline ); | 179 &glyph->outline ); |
178 if ( error ) | 180 if ( error ) |
179 goto Exit; | 181 goto Exit; |
180 | 182 |
181 FT_Outline_Copy( source, target ); | 183 FT_Outline_Copy( source, target ); |
182 | 184 |
183 Exit: | 185 Exit: |
184 return error; | 186 return error; |
185 } | 187 } |
186 | 188 |
(...skipping 11 matching lines...) Expand all Loading... |
198 FT_CALLBACK_DEF( FT_Error ) | 200 FT_CALLBACK_DEF( FT_Error ) |
199 ft_outline_glyph_copy( FT_Glyph outline_source, | 201 ft_outline_glyph_copy( FT_Glyph outline_source, |
200 FT_Glyph outline_target ) | 202 FT_Glyph outline_target ) |
201 { | 203 { |
202 FT_OutlineGlyph source = (FT_OutlineGlyph)outline_source; | 204 FT_OutlineGlyph source = (FT_OutlineGlyph)outline_source; |
203 FT_OutlineGlyph target = (FT_OutlineGlyph)outline_target; | 205 FT_OutlineGlyph target = (FT_OutlineGlyph)outline_target; |
204 FT_Error error; | 206 FT_Error error; |
205 FT_Library library = FT_GLYPH( source )->library; | 207 FT_Library library = FT_GLYPH( source )->library; |
206 | 208 |
207 | 209 |
208 error = FT_Outline_New( library, source->outline.n_points, | 210 error = FT_Outline_New( library, |
209 source->outline.n_contours, &target->outline ); | 211 (FT_UInt)source->outline.n_points, |
| 212 source->outline.n_contours, |
| 213 &target->outline ); |
210 if ( !error ) | 214 if ( !error ) |
211 FT_Outline_Copy( &source->outline, &target->outline ); | 215 FT_Outline_Copy( &source->outline, &target->outline ); |
212 | 216 |
213 return error; | 217 return error; |
214 } | 218 } |
215 | 219 |
216 | 220 |
217 FT_CALLBACK_DEF( void ) | 221 FT_CALLBACK_DEF( void ) |
218 ft_outline_glyph_transform( FT_Glyph outline_glyph, | 222 ft_outline_glyph_transform( FT_Glyph outline_glyph, |
219 const FT_Matrix* matrix, | 223 const FT_Matrix* matrix, |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 static FT_Error | 284 static FT_Error |
281 ft_new_glyph( FT_Library library, | 285 ft_new_glyph( FT_Library library, |
282 const FT_Glyph_Class* clazz, | 286 const FT_Glyph_Class* clazz, |
283 FT_Glyph* aglyph ) | 287 FT_Glyph* aglyph ) |
284 { | 288 { |
285 FT_Memory memory = library->memory; | 289 FT_Memory memory = library->memory; |
286 FT_Error error; | 290 FT_Error error; |
287 FT_Glyph glyph = NULL; | 291 FT_Glyph glyph = NULL; |
288 | 292 |
289 | 293 |
290 *aglyph = 0; | 294 *aglyph = NULL; |
291 | 295 |
292 if ( !FT_ALLOC( glyph, clazz->glyph_size ) ) | 296 if ( !FT_ALLOC( glyph, clazz->glyph_size ) ) |
293 { | 297 { |
294 glyph->library = library; | 298 glyph->library = library; |
295 glyph->clazz = clazz; | 299 glyph->clazz = clazz; |
296 glyph->format = clazz->glyph_format; | 300 glyph->format = clazz->glyph_format; |
297 | 301 |
298 *aglyph = glyph; | 302 *aglyph = glyph; |
299 } | 303 } |
300 | 304 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 620 |
617 if ( clazz->glyph_done ) | 621 if ( clazz->glyph_done ) |
618 clazz->glyph_done( glyph ); | 622 clazz->glyph_done( glyph ); |
619 | 623 |
620 FT_FREE( glyph ); | 624 FT_FREE( glyph ); |
621 } | 625 } |
622 } | 626 } |
623 | 627 |
624 | 628 |
625 /* END */ | 629 /* END */ |
OLD | NEW |