various cleanups to reduce compiler warnings
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index beb8dcc..7a56507 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -440,8 +440,8 @@
}
- BASE_FUNC( FT_Error ) FT_GlyphLoader_Create_Extra(
- FT_GlyphLoader* loader )
+
+ BASE_FUNC(FT_Error) FT_GlyphLoader_Create_Extra( FT_GlyphLoader* loader )
{
FT_Error error;
FT_Memory memory = loader->memory;
@@ -881,6 +881,8 @@
}
+ static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot );
+
/*************************************************************************/
/* */
/* <Function> */
@@ -926,7 +928,7 @@
if ( !face || !face->size || !face->glyph )
return FT_Err_Invalid_Face_Handle;
- if ( glyph_index >= face->num_glyphs )
+ if ( glyph_index >= (FT_UInt)face->num_glyphs )
return FT_Err_Invalid_Argument;
slot = face->glyph;
@@ -1388,7 +1390,6 @@
FT_Int num_params = 0;
FT_Parameter* params = 0;
-
driver = FT_DRIVER( cur[0] );
if ( args->flags & ft_open_params )
@@ -2213,16 +2214,20 @@
/*************************************************************************/
/* lookup a renderer by glyph format in the library's list */
- static FT_Renderer ft_lookup_renderer( FT_Library library,
- FT_Glyph_Format format,
- FT_ListNode* node )
+ BASE_FUNC(FT_Renderer) FT_Lookup_Renderer( FT_Library library,
+ FT_Glyph_Format format,
+ FT_ListNode *node )
{
FT_ListNode cur = library->renderers.head;
FT_Renderer result = 0;
- if ( node )
+ if (node)
+ {
+ if (*node)
+ cur = (*node)->next;
*node = 0;
+ }
while ( cur )
{
@@ -2237,13 +2242,14 @@
result = renderer;
break;
}
+ cur = cur->next;
}
return result;
}
- static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot )
+ static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot )
{
FT_Face face = slot->face;
FT_Library library = FT_FACE_LIBRARY( face );
@@ -2261,7 +2267,7 @@
{
FT_Renderer renderer;
- renderer = ft_lookup_renderer( library, ft_glyph_format_outline, 0 );
+ renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, 0 );
library->cur_renderer = renderer;
}
@@ -2364,7 +2370,7 @@
FT_EXPORT_FUNC( FT_Renderer ) FT_Get_Renderer( FT_Library library,
FT_Glyph_Format format )
{
- return ft_lookup_renderer( library, format, 0 );
+ return FT_Lookup_Renderer( library, format, 0 );
}
@@ -2409,7 +2415,7 @@
error = FT_Err_Invalid_Argument;
goto Exit;
}
-
+
FT_List_Up( &library->renderers, node );
if ( renderer->glyph_format == ft_glyph_format_outline )
@@ -2433,75 +2439,108 @@
}
- /*************************************************************************/
- /* */
- /* <Function> */
- /* FT_Render_Glyph */
- /* */
- /* <Description> */
- /* Converts a given glyph image to a bitmap. It does so by */
- /* inspecting the glyph image format, find the relevant renderer, and */
- /* invoke it. */
- /* */
- /* <Input> */
- /* slot :: A handle to the glyph slot containing the image to */
- /* convert. */
- /* */
- /* render_mode :: A set of bit flags indicating which kind of bitmap */
- /* to render. For now, only */
- /* `ft_render_mode_anti_alias' is supported by the */
- /* available renderers, but others could appear later */
- /* (e.g. optimized for TV or LCD). */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success. */
- /* */
- /* <Note> */
- /* In case of success, the renderer will be used to convert glyph */
- /* images in the renderer's known format into bitmaps. */
- /* */
- /* This doesn't change the current renderer for other formats. */
- /* */
- /* The slot's native image should be considered lost after the */
- /* conversion. */
- /* */
- FT_EXPORT_FUNC( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot,
- FT_UInt render_mode )
+<<<<<<< ftobjs.c
+ /*************************************************************************
+ *
+ * <Function>
+ * FT_Render_Glyph
+ *
+ * <Description>
+ * Converts a given glyph image to a bitmap. It does so by inspecting
+ * the glyph image format, find the relevant renderer, and invoke it
+ *
+ * <Input>
+ * slot :: handle to the glyph slot containing the image to
+ * convert
+ *
+ * render_mode :: a set of bit flags indicating which kind of bitmap
+ * to render. For now, only 'ft_render_mode_anti_alias'
+ * is supported by the available renderers, but others
+ * could appear later (e.g. LCD or TV optimised)
+ *
+ * <Return>
+ * Error code. 0 means success.
+ *
+ * <Note>
+ * in case of success, the renderer will be used to convert glyph
+ * images in the renderer's known format into bitmaps.
+ *
+ * This doesn't change the current renderer for other formats..
+ *
+ * The slot's native image should be considered lost after the
+ * conversion..
+ *
+ *************************************************************************/
+
+ LOCAL_FUNC
+ FT_Error FT_Render_Glyph_Internal( FT_Library library,
+ FT_GlyphSlot slot,
+ FT_UInt render_mode )
{
FT_Error error = FT_Err_Ok;
FT_Renderer renderer;
- if ( slot )
+ /* if it's already a bitmap, no need to do anything */
+ switch (slot->format)
{
- FT_Face face = slot->face;
- FT_Library library = FT_FACE_LIBRARY( face );
-
-
- /* if it is already a bitmap, no need to do anything */
- switch ( slot->format )
- {
- case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */
+ case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */
break;
-
+
default:
+ {
+ FT_ListNode node = 0;
+ FT_Bool update = 0;
+
/* small shortcut for the very common case */
- if ( slot->format == ft_glyph_format_outline )
+ if (slot->format == ft_glyph_format_outline)
+ {
renderer = library->cur_renderer;
+ node = library->renderers.head;
+ }
else
- renderer = ft_lookup_renderer( library, slot->format, 0 );
-
+ renderer = FT_Lookup_Renderer( library, slot->format, &node );
+
error = FT_Err_Unimplemented_Feature;
- if ( renderer )
- error = renderer->render( renderer, slot, render_mode );
+ while (renderer)
+ {
+ error = renderer->render( renderer, slot, render_mode, 0 );
+ if (!error || error != FT_Err_Cannot_Render_Glyph) break;
+
+ /* FT_Err_Cannot_Render_Glyph is returned when the render mode */
+ /* is unsupported by the current renderer for this glyph image */
+ /* format.. */
+
+ /* now, look for another renderer that supports the same */
+ /* format.. */
+ renderer = FT_Lookup_Renderer( library, slot->format, &node );
+ update = 1;
+ }
+
+ /* if we changed the current renderer for the glyph image format */
+ /* we need to select it as the next current one.. */
+ if (!error && update && renderer)
+ FT_Set_Renderer( library, renderer, 0, 0 );
}
}
- else
- error = FT_Err_Invalid_Argument;
return error;
}
+
+
+ FT_EXPORT_FUNC(FT_Error) FT_Render_Glyph( FT_GlyphSlot slot,
+ FT_UInt render_mode )
+ {
+ FT_Library library;
+
+ if (!slot)
+ return FT_Err_Invalid_Argument;
+
+ library = FT_FACE_LIBRARY(slot->face);
+ return FT_Render_Glyph_Internal( library, slot, render_mode );
+ }
+
/*************************************************************************/
/*************************************************************************/
@@ -2904,7 +2943,7 @@
FT_EXPORT_FUNC( FT_Error ) FT_Done_Library( FT_Library library )
{
FT_Memory memory;
- FT_Int n;
+ FT_UInt n;
if ( !library )
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index beb3789..b9a4c21 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -604,36 +604,34 @@
FT_Outline* outline,
FT_Raster_Params* params )
{
- FT_Error error;
- FT_Renderer renderer;
+ FT_Error error;
+ FT_Bool update = 0;
+ FT_Renderer renderer = library->cur_renderer;
+ FT_ListNode node = library->renderers.head;
-
- if ( !library )
- {
- error = FT_Err_Invalid_Library_Handle;
- goto Exit;
- }
-
- if ( !outline || !params )
- {
- error = FT_Err_Invalid_Argument;
- goto Exit;
- }
-
- /* retrieve the current outline renderer */
- renderer = library->cur_renderer;
- if ( !renderer )
+ params->source = (void*)outline;
+
+ error = FT_Err_Cannot_Render_Glyph;
+ while (renderer)
{
- /* XXXX: should use another error code */
- error = FT_Err_Invalid_Argument;
- goto Exit;
+ error = renderer->raster_render( renderer->raster, params );
+ if (!error || error != FT_Err_Cannot_Render_Glyph) break;
+
+ /* FT_Err_Cannot_Render_Glyph is returned when the render mode */
+ /* is unsupported by the current renderer for this glyph image */
+ /* format.. */
+
+ /* now, look for another renderer that supports the same */
+ /* format.. */
+ renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, &node );
+ update = 1;
}
- params->source = (void*)outline;
-
- error = renderer->raster_render( renderer->raster, params );
-
- Exit:
+ /* if we changed the current renderer for the glyph image format */
+ /* we need to select it as the next current one.. */
+ if (!error && update && renderer)
+ FT_Set_Renderer( library, renderer, 0, 0 );
+
return error;
}
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 6e017ee..01686b4 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -853,7 +853,7 @@
FT_GlyphLoader_Add( gloader );
- for ( n = 0; n < num_subglyphs; n++ )
+ for ( n = 0; n < (FT_Int)num_subglyphs; n++ )
{
FT_Vector pp1, pp2;
FT_Pos x, y;
@@ -915,13 +915,12 @@
if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
{
- FT_Int k = subglyph->arg1;
+ FT_UInt k = subglyph->arg1;
FT_UInt l = subglyph->arg2;
FT_Vector* p1;
FT_Vector* p2;
-
- if ( start_point + k >= num_base_points ||
+ if ( start_point + k >= (FT_UInt)num_base_points ||
l >= (FT_UInt)num_new_points )
{
error = TT_Err_Invalid_Composite;