various cleanups to reduce compiler warnings

This commit is contained in:
David Turner 2000-06-27 23:31:53 +00:00
parent 7ed5a057cf
commit 74abee8e2e
3 changed files with 131 additions and 95 deletions

View File

@ -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_Error error;
FT_Memory memory = loader->memory; FT_Memory memory = loader->memory;
@ -881,6 +881,8 @@
} }
static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot );
/*************************************************************************/ /*************************************************************************/
/* */ /* */
/* <Function> */ /* <Function> */
@ -926,7 +928,7 @@
if ( !face || !face->size || !face->glyph ) if ( !face || !face->size || !face->glyph )
return FT_Err_Invalid_Face_Handle; 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; return FT_Err_Invalid_Argument;
slot = face->glyph; slot = face->glyph;
@ -1388,7 +1390,6 @@
FT_Int num_params = 0; FT_Int num_params = 0;
FT_Parameter* params = 0; FT_Parameter* params = 0;
driver = FT_DRIVER( cur[0] ); driver = FT_DRIVER( cur[0] );
if ( args->flags & ft_open_params ) if ( args->flags & ft_open_params )
@ -2213,16 +2214,20 @@
/*************************************************************************/ /*************************************************************************/
/* lookup a renderer by glyph format in the library's list */ /* lookup a renderer by glyph format in the library's list */
static FT_Renderer ft_lookup_renderer( FT_Library library, BASE_FUNC(FT_Renderer) FT_Lookup_Renderer( FT_Library library,
FT_Glyph_Format format, FT_Glyph_Format format,
FT_ListNode* node ) FT_ListNode *node )
{ {
FT_ListNode cur = library->renderers.head; FT_ListNode cur = library->renderers.head;
FT_Renderer result = 0; FT_Renderer result = 0;
if ( node ) if (node)
{
if (*node)
cur = (*node)->next;
*node = 0; *node = 0;
}
while ( cur ) while ( cur )
{ {
@ -2237,13 +2242,14 @@
result = renderer; result = renderer;
break; break;
} }
cur = cur->next;
} }
return result; 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_Face face = slot->face;
FT_Library library = FT_FACE_LIBRARY( face ); FT_Library library = FT_FACE_LIBRARY( face );
@ -2261,7 +2267,7 @@
{ {
FT_Renderer renderer; 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; library->cur_renderer = renderer;
} }
@ -2364,7 +2370,7 @@
FT_EXPORT_FUNC( FT_Renderer ) FT_Get_Renderer( FT_Library library, FT_EXPORT_FUNC( FT_Renderer ) FT_Get_Renderer( FT_Library library,
FT_Glyph_Format format ) 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; error = FT_Err_Invalid_Argument;
goto Exit; goto Exit;
} }
FT_List_Up( &library->renderers, node ); FT_List_Up( &library->renderers, node );
if ( renderer->glyph_format == ft_glyph_format_outline ) if ( renderer->glyph_format == ft_glyph_format_outline )
@ -2433,75 +2439,108 @@
} }
/*************************************************************************/ <<<<<<< ftobjs.c
/* */ /*************************************************************************
/* <Function> */ *
/* FT_Render_Glyph */ * <Function>
/* */ * FT_Render_Glyph
/* <Description> */ *
/* Converts a given glyph image to a bitmap. It does so by */ * <Description>
/* inspecting the glyph image format, find the relevant renderer, and */ * Converts a given glyph image to a bitmap. It does so by inspecting
/* invoke it. */ * the glyph image format, find the relevant renderer, and invoke it
/* */ *
/* <Input> */ * <Input>
/* slot :: A handle to the glyph slot containing the image to */ * slot :: handle to the glyph slot containing the image to
/* convert. */ * convert
/* */ *
/* render_mode :: A set of bit flags indicating which kind of bitmap */ * render_mode :: a set of bit flags indicating which kind of bitmap
/* to render. For now, only */ * to render. For now, only 'ft_render_mode_anti_alias'
/* `ft_render_mode_anti_alias' is supported by the */ * is supported by the available renderers, but others
/* available renderers, but others could appear later */ * could appear later (e.g. LCD or TV optimised)
/* (e.g. optimized for TV or LCD). */ *
/* */ * <Return>
/* <Return> */ * Error code. 0 means success.
/* FreeType error code. 0 means success. */ *
/* */ * <Note>
/* <Note> */ * in case of success, the renderer will be used to convert glyph
/* In case of success, the renderer will be used to convert glyph */ * images in the renderer's known format into bitmaps.
/* images in the renderer's known format into bitmaps. */ *
/* */ * This doesn't change the current renderer for other formats..
/* This doesn't change the current renderer for other formats. */ *
/* */ * The slot's native image should be considered lost after the
/* The slot's native image should be considered lost after the */ * conversion..
/* conversion. */ *
/* */ *************************************************************************/
FT_EXPORT_FUNC( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot,
FT_UInt render_mode ) 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_Error error = FT_Err_Ok;
FT_Renderer renderer; FT_Renderer renderer;
if ( slot ) /* if it's already a bitmap, no need to do anything */
switch (slot->format)
{ {
FT_Face face = slot->face; case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */
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 */
break; break;
default: default:
{
FT_ListNode node = 0;
FT_Bool update = 0;
/* small shortcut for the very common case */ /* 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; renderer = library->cur_renderer;
node = library->renderers.head;
}
else else
renderer = ft_lookup_renderer( library, slot->format, 0 ); renderer = FT_Lookup_Renderer( library, slot->format, &node );
error = FT_Err_Unimplemented_Feature; error = FT_Err_Unimplemented_Feature;
if ( renderer ) while (renderer)
error = renderer->render( renderer, slot, render_mode ); {
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; 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_EXPORT_FUNC( FT_Error ) FT_Done_Library( FT_Library library )
{ {
FT_Memory memory; FT_Memory memory;
FT_Int n; FT_UInt n;
if ( !library ) if ( !library )

View File

@ -604,36 +604,34 @@
FT_Outline* outline, FT_Outline* outline,
FT_Raster_Params* params ) FT_Raster_Params* params )
{ {
FT_Error error; FT_Error error;
FT_Renderer renderer; 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 )
{
/* XXXX: should use another error code */
error = FT_Err_Invalid_Argument;
goto Exit;
}
params->source = (void*)outline; params->source = (void*)outline;
error = renderer->raster_render( renderer->raster, params ); error = FT_Err_Cannot_Render_Glyph;
while (renderer)
{
error = renderer->raster_render( renderer->raster, params );
if (!error || error != FT_Err_Cannot_Render_Glyph) break;
Exit: /* 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;
}
/* 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; return error;
} }

View File

@ -853,7 +853,7 @@
FT_GlyphLoader_Add( gloader ); 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_Vector pp1, pp2;
FT_Pos x, y; FT_Pos x, y;
@ -915,13 +915,12 @@
if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) ) if ( !( subglyph->flags & ARGS_ARE_XY_VALUES ) )
{ {
FT_Int k = subglyph->arg1; FT_UInt k = subglyph->arg1;
FT_UInt l = subglyph->arg2; FT_UInt l = subglyph->arg2;
FT_Vector* p1; FT_Vector* p1;
FT_Vector* p2; FT_Vector* p2;
if ( start_point + k >= (FT_UInt)num_base_points ||
if ( start_point + k >= num_base_points ||
l >= (FT_UInt)num_new_points ) l >= (FT_UInt)num_new_points )
{ {
error = TT_Err_Invalid_Composite; error = TT_Err_Invalid_Composite;