Formatting...

Preprocessor lines now always start the line.

Improved error handling in `base' module.

Fixed a out-of-bounds error in ttgload.
This commit is contained in:
Werner Lemberg 2000-06-29 03:14:25 +00:00
parent 63e3c3b529
commit deb4e98396
31 changed files with 773 additions and 666 deletions

View File

@ -50,19 +50,19 @@
static const FT_Long ft_square_roots[63] =
{
1, 1, 2, 3, 4, 5, 8, 11,
16, 22, 32, 45, 64, 90, 128, 181,
256, 362, 512, 724, 1024, 1448, 2048, 2896,
4096, 5892, 8192, 11585, 16384, 23170, 32768, 46340,
1L, 1L, 2L, 3L, 4L, 5L, 8L, 11L,
16L, 22L, 32L, 45L, 64L, 90L, 128L, 181L,
256L, 362L, 512L, 724L, 1024L, 1448L, 2048L, 2896L,
4096L, 5892L, 8192L, 11585L, 16384L, 23170L, 32768L, 46340L,
65536, 92681, 131072, 185363, 262144, 370727,
524288, 741455, 1048576, 1482910, 2097152, 2965820,
4194304, 5931641, 8388608, 11863283, 16777216, 23726566,
65536L, 92681L, 131072L, 185363L, 262144L, 370727L,
524288L, 741455L, 1048576L, 1482910L, 2097152L, 2965820L,
4194304L, 5931641L, 8388608L, 11863283L, 16777216L, 23726566L,
33554432, 47453132, 67108864, 94906265,
134217728, 189812531, 268435456, 379625062,
536870912, 759250125, 1073741824, 1518500250,
2147483647
33554432L, 47453132L, 67108864L, 94906265L,
134217728L, 189812531L, 268435456L, 379625062L,
536870912L, 759250125L, 1073741824L, 1518500250L,
2147483647L
};
#else
@ -102,8 +102,8 @@
root >>= 1;
mask >>= 2;
}
while ( mask != 0 );
} while ( mask != 0 );
return root;
}
@ -289,8 +289,8 @@
{
s = r;
r = ( r + l / r ) >> 1;
}
while ( r > s || r * r > l );
} while ( r > s || r * r > l );
return r;
}
@ -487,14 +487,14 @@
}
else
{
/* we need more bits, we'll have to do it by hand */
/* we need more bits; we have to do it by hand */
FT_Word32 c;
q = ( a / b ) << 16;
c = a % b;
/* we must compute C*0x10000/B; we simply shift C and B so */
/* we must compute C*0x10000/B: we simply shift C and B so */
/* C becomes smaller than 16 bits */
while ( c >> 16 )
{
@ -759,8 +759,8 @@
r = ( r + FT_Div64by32( l, r ) ) >> 1;
FT_MulTo64( r, r, &l2 );
FT_Sub64 ( l, &l2, &l2 );
}
while ( r > s || (FT_Int32)l2.hi < 0 );
} while ( r > s || (FT_Int32)l2.hi < 0 );
return r;
}

View File

@ -103,7 +103,7 @@
if ( component >= trace_max )
return;
/* if component is `trace_any', then change _all_ levels at once */
/* if component is `trace_any', change _all_ levels at once */
if ( component == trace_any )
{
int n;

View File

@ -152,7 +152,8 @@
cur->offset = registry->cur_offset;
registry->num_extensions++;
registry->cur_offset += ( cur->size + FT_ALIGNMENT-1 ) & -FT_ALIGNMENT;
registry->cur_offset +=
( cur->size + FT_ALIGNMENT - 1 ) & -FT_ALIGNMENT;
FT_TRACE1(( "FT_Register_Extension: `%s' successfully registered\n",
cur->id ));
@ -180,7 +181,7 @@
/* extension interface. */
/* */
/* <Return> */
/* A pointer to the extension block. */
/* A generic pointer to the extension block. */
/* */
FT_EXPORT_FUNC( void* ) FT_Get_Extension(
FT_Face face,
@ -296,7 +297,7 @@
face->extensions = 0;
/* load extensions registry, exit successfully if none is there */
/* load extensions registry; exit successfully if none is there */
registry = (FT_Extension_Registry*)face->driver->extensions;
if ( !registry )

View File

@ -42,6 +42,7 @@
#define FT_COMPONENT trace_glyph
/* a helper function to avoid duplication of code */
static
void ft_prepare_glyph( FT_Glyph glyph,
FT_Face face,
@ -171,6 +172,7 @@
/* now, handle bitmap and outline glyph images */
memory = face->memory;
switch ( face->glyph->format )
{
case ft_glyph_format_bitmap:
@ -318,7 +320,7 @@
FT_OutlineGlyph glyph;
/* test for valid face delayed to FT_Load_Glyph() */
/* test for valid `face' delayed to FT_Load_Glyph() */
if ( !vecglyph )
return FT_Err_Invalid_Argument;
@ -529,7 +531,7 @@
v = d;
}
/* check that we're not trying to normalize zero! */
/* check that we are not trying to normalize zero! */
if ( u == 0 )
return 0;
@ -630,8 +632,8 @@
/* Compute the orientation of path filling. It differs between TrueType */
/* and Type1 formats. We could use the `ft_outline_reverse_fill' flag, */
/* but it's better to re-compute it directly (it seems that this flag */
/* isn't correctly set for some weird composite glyphs for now). */
/* but it is better to re-compute it directly (it seems that this flag */
/* isn't correctly set for some weird composite glyphs currently). */
/* */
/* We do this by computing bounding box points, and computing their */
/* curvature. */
@ -645,6 +647,7 @@
FT_BBox indices;
int n, last;
indices.xMin = -1;
indices.yMin = -1;
indices.xMax = -1;
@ -781,6 +784,7 @@
/* Vectors are nearly parallel */
FT_Pos x, y;
x = distance + cur.x + FT_MulFix( d, u.x + v.x ) / 2;
y = distance + cur.y + FT_MulFix( d, u.y + v.y ) / 2;

View File

@ -84,7 +84,8 @@ const FT_Module_Class* ft_default_modules[] =
FT_Error error;
const FT_Module_Class** cur;
/* test for valid library delayed to FT_Add_Module() */
/* test for valid `library' delayed to FT_Add_Module() */
cur = ft_default_modules;
while ( *cur )
@ -114,7 +115,7 @@ const FT_Module_Class* ft_default_modules[] =
/* library :: A handle to a new library object. */
/* */
/* <Return> */
/* FreeTyoe error code. 0 means success. */
/* FreeType error code. 0 means success. */
/* */
FT_EXPORT_FUNC( FT_Error ) FT_Init_FreeType( FT_Library* library )
{
@ -128,12 +129,11 @@ const FT_Module_Class* ft_default_modules[] =
memory = FT_New_Memory();
if ( !memory )
{
FT_ERROR(( "FT_Init_FreeType:" ));
FT_ERROR(( " cannot find memory manager\n" ));
FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
return FT_Err_Unimplemented_Feature;
}
/* builds a library out of it, then fill it with the set of */
/* build a library out of it, then fill it with the set of */
/* default drivers. */
error = FT_New_Library( memory, library );

View File

@ -201,6 +201,7 @@
}
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@ -224,6 +225,7 @@
/* */
/* <Note> */
/* The function expects a valid `astream' parameter. */
/* */
static
FT_Error ft_new_input_stream( FT_Library library,
FT_Open_Args* args,
@ -315,6 +317,7 @@
#undef FT_COMPONENT
#define FT_COMPONENT trace_objs
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@ -423,7 +426,8 @@
/* re-adjust the `current' outline fields */
static void FT_GlyphLoader_Adjust_Points( FT_GlyphLoader* loader )
static
void FT_GlyphLoader_Adjust_Points( FT_GlyphLoader* loader )
{
FT_Outline* base = &loader->base.outline;
FT_Outline* current = &loader->current.outline;
@ -440,8 +444,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;
@ -458,7 +462,8 @@
/* re-adjust the `current' subglyphs field */
static void FT_GlyphLoader_Adjust_Subglyphs( FT_GlyphLoader* loader )
static
void FT_GlyphLoader_Adjust_Subglyphs( FT_GlyphLoader* loader )
{
FT_GlyphLoad* base = &loader->base;
FT_GlyphLoad* current = &loader->current;
@ -471,6 +476,7 @@
/* Ensure that we can add `n_points' and `n_contours' to our glyph. this */
/* function reallocates its outline tables if necessary. Note that it */
/* DOESN'T change the number of points within the loader! */
/* */
BASE_FUNC( FT_Error ) FT_GlyphLoader_Check_Points(
FT_GlyphLoader* loader,
FT_UInt n_points,
@ -530,6 +536,7 @@
/* Ensure that we can add `n_subglyphs' to our glyph. this function */
/* reallocates its subglyphs table if necessary. Note that it DOES */
/* NOT change the number of subglyphs within the loader! */
/* */
BASE_FUNC( FT_Error ) FT_GlyphLoader_Check_Subglyphs(
FT_GlyphLoader* loader,
FT_UInt n_subs )
@ -599,8 +606,7 @@
}
BASE_FUNC( FT_Error ) FT_GlyphLoader_Copy_Points(
FT_GlyphLoader* target,
BASE_FUNC( FT_Error ) FT_GlyphLoader_Copy_Points( FT_GlyphLoader* target,
FT_GlyphLoader* source )
{
FT_Error error;
@ -649,7 +655,9 @@
/*************************************************************************/
/*************************************************************************/
static FT_Error ft_glyphslot_init( FT_GlyphSlot slot )
static
FT_Error ft_glyphslot_init( FT_GlyphSlot slot )
{
FT_Driver driver = slot->face->driver;
FT_Driver_Class* clazz = driver->clazz;
@ -667,9 +675,11 @@
}
static void ft_glyphslot_clear( FT_GlyphSlot slot )
static
void ft_glyphslot_clear( FT_GlyphSlot slot )
{
/* clear all public fields in the glyph slot */
MEM_Set( &slot->metrics, 0, sizeof ( slot->metrics ) );
MEM_Set( &slot->outline, 0, sizeof ( slot->outline ) );
MEM_Set( &slot->bitmap, 0, sizeof ( slot->bitmap ) );
@ -688,7 +698,8 @@
}
static void ft_glyphslot_done( FT_GlyphSlot slot )
static
void ft_glyphslot_done( FT_GlyphSlot slot )
{
FT_Driver driver = slot->face->driver;
FT_Driver_Class* clazz = driver->clazz;
@ -741,11 +752,11 @@
FT_GlyphSlot slot;
*aslot = 0;
if ( !face || !aslot || !face->driver )
return FT_Err_Invalid_Argument;
*aslot = 0;
driver = face->driver;
clazz = driver->clazz;
memory = driver->root.memory;
@ -814,10 +825,6 @@
}
/* forward declaration */
static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot );
/*************************************************************************/
/* */
/* <Function> */
@ -852,8 +859,8 @@
if ( !matrix )
{
face->transform_matrix.xx = 0x10000L;
face->transform_matrix.xy = 0L;
face->transform_matrix.yx = 0L;
face->transform_matrix.xy = 0;
face->transform_matrix.yx = 0;
face->transform_matrix.yy = 0x10000L;
matrix = &face->transform_matrix;
}
@ -883,6 +890,7 @@
static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot );
/*************************************************************************/
/* */
/* <Function> */
@ -1092,14 +1100,15 @@
}
static void Destroy_Driver( FT_Driver driver )
static
void Destroy_Driver( FT_Driver driver )
{
FT_List_Finalize( &driver->faces_list,
(FT_List_Destructor)destroy_face,
driver->root.memory,
driver );
/* see if we need to drop the driver's glyph loader */
/* check whether we need to drop the driver's glyph loader */
if ( FT_DRIVER_USES_OUTLINES( driver ) )
FT_GlyphLoader_Done( driver->glyph_loader );
}
@ -1130,7 +1139,7 @@
clazz = driver->clazz;
memory = driver->root.memory;
/* allocate the face object, and perform basic initialization */
/* allocate the face object and perform basic initialization */
if ( ALLOC( face, clazz->face_object_size ) )
goto Fail;
@ -1341,12 +1350,13 @@
/* create input stream */
error = ft_new_input_stream( library, args, &stream );
if ( error ) goto Exit;
if ( error )
goto Exit;
memory = library->memory;
/* If the font driver is specified in the `args' structure, use */
/* it. Otherwise, we'll scan the list of registered drivers. */
/* it. Otherwise, we scan the list of registered drivers. */
if ( args->flags & ft_open_driver && args->driver )
{
driver = FT_DRIVER( args->driver );
@ -1390,6 +1400,7 @@
FT_Int num_params = 0;
FT_Parameter* params = 0;
driver = FT_DRIVER( cur[0] );
if ( args->flags & ft_open_params )
@ -1418,7 +1429,7 @@
Success:
FT_TRACE4(( "FT_New_Face: New face object, adding to list\n" ));
/* set the EXTERNAL_STREAM bit for FT_Done_Face */
/* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
if ( args->flags & ft_open_stream && args->stream )
face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
@ -1437,8 +1448,10 @@
FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
error = FT_New_GlyphSlot( face, &slot );
if ( error ) goto Fail;
if ( error )
goto Fail;
face->glyph = slot;
}
@ -1449,8 +1462,10 @@
FT_TRACE4(( "FT_Open_Face: Creating size object\n" ));
error = FT_New_Size( face, &size );
if ( error ) goto Fail;
if ( error )
goto Fail;
face->size = size;
}
@ -1472,6 +1487,7 @@
Exit:
FT_TRACE4(( "FT_Open_Face: Return %d\n", error ));
return error;
}
@ -1667,11 +1683,11 @@
FT_ListNode node = 0;
*asize = 0;
if ( !face || !asize || !face->driver )
return FT_Err_Invalid_Handle;
*asize = 0;
driver = face->driver;
clazz = driver->clazz;
memory = face->memory;
@ -1764,10 +1780,12 @@
}
static void ft_recompute_scaled_metrics( FT_Face face,
static
void ft_recompute_scaled_metrics( FT_Face face,
FT_Size_Metrics* metrics )
{
/* Compute root ascender, descender, test height, and max_advance */
metrics->ascender = ( FT_MulFix( face->ascender,
metrics->y_scale ) + 32 ) & -64;
@ -1853,8 +1871,10 @@
memory = driver->root.memory;
/* default processing -- this can be overridden by the driver */
if ( char_width < 1 * 64 ) char_width = 1 * 64;
if ( char_height < 1 * 64 ) char_height = 1 * 64;
if ( char_width < 1 * 64 )
char_width = 1 * 64;
if ( char_height < 1 * 64 )
char_height = 1 * 64;
/* Compute pixel sizes in 26.6 units */
dim_x = ( ( ( char_width * horz_resolution ) / 72 ) + 32 ) & -64;
@ -1932,8 +1952,10 @@
else if ( pixel_height == 0 )
pixel_height = pixel_width;
if ( pixel_width < 1 ) pixel_width = 1;
if ( pixel_height < 1 ) pixel_height = 1;
if ( pixel_width < 1 )
pixel_width = 1;
if ( pixel_height < 1 )
pixel_height = 1;
metrics->x_ppem = pixel_width;
metrics->y_ppem = pixel_height;
@ -2067,6 +2089,7 @@
return 0;
}
}
return FT_Err_Invalid_Argument;
}
@ -2088,8 +2111,8 @@
/* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* This function will return an error when the charmap is not part */
/* of the face (i.e., if it is not listed in the face->charmaps[] */
/* This function will return an error if the charmap is not part of */
/* the face (i.e., if it is not listed in the face->charmaps[] */
/* table). */
/* */
FT_EXPORT_FUNC( FT_Error ) FT_Set_Charmap( FT_Face face,
@ -2218,10 +2241,15 @@
FT_Glyph_Format format,
FT_ListNode* node )
{
FT_ListNode cur = library->renderers.head;
FT_ListNode cur;
FT_Renderer result = 0;
if ( !library )
goto Exit;
cur = library->renderers.head;
if ( node )
{
if ( *node )
@ -2245,11 +2273,13 @@
cur = cur->next;
}
Exit:
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 );
@ -2263,22 +2293,26 @@
}
static void ft_set_current_renderer( FT_Library library )
static
void ft_set_current_renderer( FT_Library library )
{
FT_Renderer renderer;
renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, 0 );
library->cur_renderer = renderer;
}
static FT_Error ft_add_renderer( FT_Module module )
static
FT_Error ft_add_renderer( FT_Module module )
{
FT_Library library = module->library;
FT_Memory memory = library->memory;
FT_Error error;
FT_ListNode node;
if ( ALLOC( node, sizeof ( *node ) ) )
goto Exit;
@ -2318,7 +2352,8 @@
}
static void ft_remove_renderer( FT_Module module )
static
void ft_remove_renderer( FT_Module module )
{
FT_Library library = module->library;
FT_Memory memory = library->memory;
@ -2370,6 +2405,8 @@
FT_EXPORT_FUNC( FT_Renderer ) FT_Get_Renderer( FT_Library library,
FT_Glyph_Format format )
{
/* test for valid `library' delayed to FT_Lookup_Renderer() */
return FT_Lookup_Renderer( library, format, 0 );
}
@ -2409,6 +2446,12 @@
FT_Error error = FT_Err_Ok;
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !renderer )
return FT_Err_Invalid_Argument;
node = FT_List_Find( &library->renderers, renderer );
if ( !node )
{
@ -2439,38 +2482,6 @@
}
/*************************************************************************
*
* <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,
@ -2480,7 +2491,7 @@
FT_Renderer renderer;
/* if it's already a bitmap, no need to do anything */
/* 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 */
@ -2491,6 +2502,7 @@
FT_ListNode node = 0;
FT_Bool update = 0;
/* small shortcut for the very common case */
if ( slot->format == ft_glyph_format_outline )
{
@ -2504,20 +2516,21 @@
while ( renderer )
{
error = renderer->render( renderer, slot, render_mode, 0 );
if (!error || error != FT_Err_Cannot_Render_Glyph) break;
if ( !error || error != FT_Err_Cannot_Render_Glyph )
break;
/* FT_Err_Cannot_Render_Glyph is returned when the render mode */
/* FT_Err_Cannot_Render_Glyph is returned if the render mode */
/* is unsupported by the current renderer for this glyph image */
/* format.. */
/* format. */
/* now, look for another renderer that supports the same */
/* format.. */
/* 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.. */
/* we need to select it as the next current one */
if ( !error && update && renderer )
FT_Set_Renderer( library, renderer, 0, 0 );
}
@ -2527,16 +2540,49 @@
}
/*************************************************************************/
/* */
/* <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 )
{
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 );
}
@ -2628,7 +2674,10 @@
#define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \
FREETYPE_MINOR )
if ( !library || !clazz )
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !clazz )
return FT_Err_Invalid_Argument;
/* check freetype version */
@ -2665,13 +2714,13 @@
if ( ALLOC( module,clazz->module_size ) )
goto Exit;
/* base initialisation */
/* base initialization */
module->library = library;
module->memory = memory;
module->clazz = (FT_Module_Class*)clazz;
/* if the module is a renderer - this must be performed before */
/* the normal module initialization. */
/* check whether the module is a renderer - this must be performed */
/* before the normal module initialization */
if ( FT_MODULE_IS_RENDERER( module ) )
{
/* add to the renderers list */
@ -2757,10 +2806,16 @@
const char* module_name )
{
FT_Module result = 0;
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
FT_Module* cur;
FT_Module* limit;
if ( !library || !module_name )
return result;
cur = library->modules;
limit = cur + library->num_modules;
for ( ; cur < limit; cur++ )
if ( strcmp( cur[0]->clazz->module_name, module_name ) == 0 )
{
@ -2800,6 +2855,8 @@
FT_Module module;
/* test for valid `library' delayed to FT_Get_Module() */
module = FT_Get_Module( library, mod_name );
return module ? module->clazz->module_interface : 0;
@ -2829,7 +2886,11 @@
FT_Module module )
{
/* try to find the module from the table, then remove it from there */
if ( library && module )
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( module )
{
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;

View File

@ -174,7 +174,6 @@
}
case FT_Curve_Tag_Conic: /* consume conic arcs */
{
v_control.x = SCALED( point->x );
v_control.y = SCALED( point->y );
@ -216,7 +215,6 @@
error = interface->conic_to( &v_control, &v_start, user );
goto Close;
}
default: /* FT_Curve_Tag_Cubic */
{
@ -549,6 +547,7 @@
char* q = outline->tags + last;
char swap;
while ( p < q )
{
swap = *p;
@ -606,8 +605,18 @@
{
FT_Error error;
FT_Bool update = 0;
FT_Renderer renderer = library->cur_renderer;
FT_ListNode node = library->renderers.head;
FT_Renderer renderer;
FT_ListNode node;
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !params )
return FT_Err_Invalid_Argument;
renderer = library->cur_renderer;
node = library->renderers.head;
params->source = (void*)outline;
@ -615,20 +624,22 @@
while ( renderer )
{
error = renderer->raster_render( renderer->raster, params );
if (!error || error != FT_Err_Cannot_Render_Glyph) break;
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.. */
/* format */
/* now, look for another renderer that supports the same */
/* format.. */
renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, &node );
/* 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.. */
/* we need to select it as the next current one */
if ( !error && update && renderer )
FT_Set_Renderer( library, renderer, 0, 0 );
@ -675,7 +686,7 @@
if ( !bitmap )
return FT_Err_Invalid_Argument;
/* other checks are delayed to FT_Outline_Render */
/* other checks are delayed to FT_Outline_Render() */
params.target = bitmap;
params.flags = 0;
@ -713,6 +724,9 @@
FT_Pos xz, yz;
if ( !vector || !matrix )
return;
xz = FT_MulFix( vector->x, matrix->xx ) +
FT_MulFix( vector->y, matrix->xy );

View File

@ -645,19 +645,16 @@
*(FT_UShort*)p = (FT_UShort)value;
break;
/* A slight note regarding the following: */
/* */
/* SIZEOF_INT is defined in <freetype/config/ftconfig.h> */
/* and gives the size in bytes of the "int" type on the */
/* current platform.. */
/* and gives the size in bytes of the `int' type on the */
/* current platform. */
/* */
/* Only on 16-bit systems can the value of SIZEOF_INT be */
/* less than 4. In this case SIZEOF_LONG is always 4 */
/* Only on 16-bit systems the value of SIZEOF_INT can be */
/* less than 4. In this case SIZEOF_LONG is always 4. */
/* */
/* On a 64-bit system, SIZEOF_LONG can be 8, which is */
/* handled by the default case.. */
/* handled by the default case. */
/* */
#if SIZEOF_INT == 4
case 4:
*(FT_UInt*)p = (FT_UInt)value;

View File

@ -44,8 +44,9 @@
/*************************************************************************/
/* */
/* It is not necessary to do any error checking here. This will be done */
/* by the higher level routines like FT_Alloc() or FT_Realloc(). */
/* It is not necessary to do any error checking for the */
/* allocation-related functions. This will be done by the higher level */
/* routines like FT_Alloc() or FT_Realloc(). */
/* */
/*************************************************************************/
@ -234,6 +235,9 @@
FILE* file;
if ( !stream )
return FT_Err_Invalid_Stream_Handle;
file = fopen( filepathname, "rb" );
if ( !file )
{

View File

@ -359,10 +359,13 @@
CFF_Font* cff = (CFF_Font*)decoder->builder.face->extra.data;
CFF_SubFont* sub = &cff->top_font;
/* manage CID fonts */
if ( cff->num_subfonts >= 1 )
{
FT_Byte fd_index = CFF_Get_FD( &cff->fd_select, glyph_index );
sub = cff->subfonts[fd_index];
}
@ -375,7 +378,6 @@
}
/* check that there is enough room for `count' more points */
static
FT_Error check_points( T2_Builder* builder,
@ -528,6 +530,7 @@
FT_Fixed seed;
FT_Fixed* stack;
/* set default width */
decoder->num_hints = 0;
decoder->read_width = 1;
@ -1088,6 +1091,8 @@
case t2_op_rlinecurve:
{
FT_Int num_lines = ( num_args - 6 ) / 2;
FT_TRACE4(( " rlinecurve" ));
if ( num_args < 8 || ( num_args - 6 ) & 1 )
@ -1109,7 +1114,7 @@
num_lines--;
}
/* then, the curve */
/* then the curve */
x += args[0];
y += args[1];
add_point( builder, x, y, 0 );
@ -1138,6 +1143,7 @@
goto Memory_Error;
args = stack;
/* first, add the curves */
while ( num_curves > 0 )
{
@ -1153,6 +1159,7 @@
args += 6;
num_curves--;
}
/* then the final line */
x += args[0];
y += args[1];
@ -1549,15 +1556,15 @@
return error;
Syntax_Error:
FT_TRACE4(( "** Syntax Error **" ));
FT_TRACE4(( "T2_Parse_CharStrings: syntax error!" ));
return T2_Err_Invalid_File_Format;
Stack_Underflow:
FT_TRACE4(( "** Stack underflow **" ));
FT_TRACE4(( "T2_Parse_CharStrings: stack underflow!" ));
return T2_Err_Too_Few_Arguments;
Stack_Overflow:
FT_TRACE4(( "** Stack overflow**" ));
FT_TRACE4(( "T2_Parse_CharStrings: stack overflow!" ));
return T2_Err_Stack_Overflow;
Memory_Error:

View File

@ -318,14 +318,15 @@
#endif /* 0 */
/**********************************************************************/
/**********************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** FD Select table support ***/
/*** ***/
/*** ***/
/**********************************************************************/
/**********************************************************************/
/*************************************************************************/
/*************************************************************************/
static
void CFF_Done_FD_Select( CFF_FD_Select* select,
@ -350,12 +351,14 @@
FT_Byte format;
FT_UInt num_ranges;
/* read format */
if ( FILE_Seek( offset ) || READ_Byte( format ) )
goto Exit;
select->format = format;
select->cache_count = 0; /* clear cache */
switch ( format )
{
case 0: /* format 0, that's simple */
@ -364,7 +367,6 @@
goto Load_Data;
}
case 3: /* format 3, a tad more complex */
{
if ( READ_UShort( num_ranges ) )
@ -379,9 +381,10 @@
break;
default: /* humm.. that's wrong */
default: /* humm... that's wrong */
error = FT_Err_Invalid_File_Format;
}
Exit:
return error;
}
@ -393,6 +396,7 @@
{
FT_Byte fd = 0;
switch ( select->format )
{
case 0:
@ -414,6 +418,7 @@
FT_Byte fd2;
FT_UInt first, limit;
first = NEXT_UShort( p );
do
{
@ -434,26 +439,26 @@
break;
}
first = limit;
}
while (p < p_limit);
} while ( p < p_limit );
}
break;
default:
;
}
return fd;
}
/**********************************************************************/
/**********************************************************************/
/*************************************************************************/
/*************************************************************************/
/*** ***/
/*** CFF font support ***/
/*** ***/
/*** ***/
/**********************************************************************/
/**********************************************************************/
/*************************************************************************/
/*************************************************************************/
static
FT_Error CFF_Load_SubFont( CFF_SubFont* font,
@ -469,6 +474,7 @@
CFF_Font_Dict* top = &font->font_dict;
CFF_Private* priv = &font->private_dict;
T2_Parser_Init( &parser, T2CODE_TOPDICT, &font->font_dict );
/* set defaults */
@ -552,7 +558,6 @@
}
LOCAL_FUNC
FT_Error T2_Load_CFF_Font( FT_Stream stream,
FT_Int face_index,
@ -634,13 +639,15 @@
CFF_SubFont* sub;
FT_UInt index;
/* this is a CID-keyed font, we must now allocate a table of */
/* sub-fonts, then load each of them separately.. */
/* sub-fonts, then load each of them separately */
if ( FILE_Seek( base_offset + dict->cid_fd_array_offset ) )
goto Exit;
error = t2_new_cff_index( &fd_index, stream, 0 );
if (error) goto Exit;
if ( error )
goto Exit;
if ( fd_index.count > CFF_MAX_CID_FONTS )
{
@ -661,8 +668,10 @@
for ( index = 0; index < fd_index.count; index++ )
{
sub = font->subfonts[index];
error = CFF_Load_SubFont( sub, &fd_index, index, stream, base_offset );
if (error) goto Fail_CID;
error = CFF_Load_SubFont( sub, &fd_index, index,
stream, base_offset );
if ( error )
goto Fail_CID;
}
/* now load the FD Select array */
@ -713,14 +722,13 @@
}
LOCAL_FUNC
void T2_Done_CFF_Font( CFF_Font* font )
{
FT_Memory memory = font->memory;
FT_UInt index;
t2_done_cff_index( &font->global_subrs_index );
t2_done_cff_index( &font->string_index );
t2_done_cff_index( &font->font_dict_index );

View File

@ -478,7 +478,8 @@
/* and look for it in our current list. */
FT_UInt code;
FT_UInt num_args = (FT_UInt)(parser->top - parser->stack);
FT_UInt num_args = (FT_UInt)
( parser->top - parser->stack );
const T2_Field_Handler* field;
@ -516,28 +517,35 @@
case t2_kind_fixed:
val = t2_parse_fixed( parser->stack );
/* A slight note regarding the following: */
/* */
/* SIZEOF_INT is defined in <freetype/config/ftconfig.h> */
/* and gives the size in bytes of the "int" type on the */
/* current platform.. */
/* and gives the size in bytes of the `int' type on the */
/* current platform. */
/* */
/* Only on 16-bit systems can the value of SIZEOF_INT be */
/* less than 4. In this case SIZEOF_LONG is always 4 */
/* Only on 16-bit systems the value of SIZEOF_INT can be */
/* less than 4. In this case SIZEOF_LONG is always 4. */
/* */
/* On a 64-bit system, SIZEOF_LONG can be 8, which is */
/* handled by the default case.. */
/* handled by the default case. */
/* */
Store_Number:
switch ( field->size )
{
case 1: *(FT_Byte*)q = (FT_Byte)val; break;
case 2: *(FT_Short*)q = (FT_Short)val; break;
case 1:
*(FT_Byte*)q = (FT_Byte)val;
break;
case 2:
*(FT_Short*)q = (FT_Short)val;
break;
#if SIZEOF_INT == 4
case 4: *(FT_Int*)q = (FT_Int)val; break;
case 4:
*(FT_Int*)q = (FT_Int)val;
break;
#endif
default: *(FT_Long*)q = val;
default:
*(FT_Long*)q = val;
}
break;

View File

@ -202,6 +202,7 @@
{
CID_GlyphSlot glyph = builder->glyph;
if ( glyph )
glyph->root.outline = *builder->base;
}

View File

@ -201,7 +201,7 @@
{
FT_Byte* start; /* first character of token in input stream */
FT_Byte* limit; /* first character after the token */
CID_Token_Type type; /* type of token.. */
CID_Token_Type type; /* type of token */
} CID_Token_Rec;

View File

@ -248,6 +248,7 @@
UNUSED( num_params );
UNUSED( params );
/* Load tables */
if ( LOAD_( header ) ||
LOAD_( max_profile ) ||

View File

@ -920,6 +920,7 @@
FT_Vector* p1;
FT_Vector* p2;
if ( start_point + k >= (FT_UInt)num_base_points ||
l >= (FT_UInt)num_new_points )
{
@ -1023,8 +1024,8 @@
pp1[0] = loader->pp1;
pp1[1] = loader->pp2;
pts->tags[num_points ] = 0;
pts->tags[num_points + 1] = 0;
pts->tags[num_points + 2] = 0;
/* if hinting, round the phantom points */
if ( IS_HINTED( loader->load_flags ) )