project
stringclasses 633
values | commit_id
stringlengths 7
81
| target
int64 0
1
| func
stringlengths 5
484k
| cwe
stringclasses 131
values | big_vul_idx
float64 0
189k
⌀ | idx
int64 0
522k
| hash
stringlengths 34
39
| size
float64 1
24k
⌀ | message
stringlengths 0
11.5k
⌀ | dataset
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
Destroy_Module( FT_Module module )
{
FT_Memory memory = module->memory;
FT_Module_Class* clazz = module->clazz;
FT_Library library = module->library;
/* finalize client-data - before anything else */
if ( module->generic.finalizer )
module->generic.finalizer( module );
if ( library && library->auto_hinter == module )
library->auto_hinter = 0;
/* if the module is a renderer */
if ( FT_MODULE_IS_RENDERER( module ) )
ft_remove_renderer( module );
/* if the module is a font driver, add some steps */
if ( FT_MODULE_IS_DRIVER( module ) )
Destroy_Driver( FT_DRIVER( module ) );
/* finalize the module object */
if ( clazz->module_done )
clazz->module_done( module );
/* discard it */
FT_FREE( module );
}
|
CWE-119
| 10,223 | 16,908 |
267685272087748936415523506693028543853
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Activate_Size( FT_Size size )
{
FT_Face face;
if ( size == NULL )
return FT_Err_Invalid_Argument;
face = size->face;
if ( face == NULL || face->driver == NULL )
return FT_Err_Invalid_Argument;
/* we don't need anything more complex than that; all size objects */
/* are already listed by the face */
face->size = size;
return FT_Err_Ok;
}
|
CWE-119
| 10,224 | 16,909 |
111857523646822957971921623980225465546
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Add_Module( FT_Library library,
const FT_Module_Class* clazz )
{
FT_Error error;
FT_Memory memory;
FT_Module module;
FT_UInt nn;
#define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) | \
FREETYPE_MINOR )
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( !clazz )
return FT_Err_Invalid_Argument;
/* check freetype version */
if ( clazz->module_requires > FREETYPE_VER_FIXED )
return FT_Err_Invalid_Version;
/* look for a module with the same name in the library's table */
for ( nn = 0; nn < library->num_modules; nn++ )
{
module = library->modules[nn];
if ( ft_strcmp( module->clazz->module_name, clazz->module_name ) == 0 )
{
/* this installed module has the same name, compare their versions */
if ( clazz->module_version <= module->clazz->module_version )
return FT_Err_Lower_Module_Version;
/* remove the module from our list, then exit the loop to replace */
/* it by our new version.. */
FT_Remove_Module( library, module );
break;
}
}
memory = library->memory;
error = FT_Err_Ok;
if ( library->num_modules >= FT_MAX_MODULES )
{
error = FT_Err_Too_Many_Drivers;
goto Exit;
}
/* allocate module object */
if ( FT_ALLOC( module, clazz->module_size ) )
goto Exit;
/* base initialization */
module->library = library;
module->memory = memory;
module->clazz = (FT_Module_Class*)clazz;
/* 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 */
error = ft_add_renderer( module );
if ( error )
goto Fail;
}
/* is the module a auto-hinter? */
if ( FT_MODULE_IS_HINTER( module ) )
library->auto_hinter = module;
/* if the module is a font driver */
if ( FT_MODULE_IS_DRIVER( module ) )
{
/* allocate glyph loader if needed */
FT_Driver driver = FT_DRIVER( module );
driver->clazz = (FT_Driver_Class)module->clazz;
if ( FT_DRIVER_USES_OUTLINES( driver ) )
{
error = FT_GlyphLoader_New( memory, &driver->glyph_loader );
if ( error )
goto Fail;
}
}
if ( clazz->module_init )
{
error = clazz->module_init( module );
if ( error )
goto Fail;
}
/* add module to the library's table */
library->modules[library->num_modules++] = module;
Exit:
return error;
Fail:
if ( FT_MODULE_IS_DRIVER( module ) )
{
FT_Driver driver = FT_DRIVER( module );
if ( FT_DRIVER_USES_OUTLINES( driver ) )
FT_GlyphLoader_Done( driver->glyph_loader );
}
if ( FT_MODULE_IS_RENDERER( module ) )
{
FT_Renderer renderer = FT_RENDERER( module );
if ( renderer->raster )
renderer->clazz->raster_class->raster_done( renderer->raster );
}
FT_FREE( module );
goto Exit;
}
|
CWE-119
| 10,225 | 16,910 |
51153112392561581779396480981162999943
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Attach_File( FT_Face face,
const char* filepathname )
{
FT_Open_Args open;
/* test for valid `face' delayed to FT_Attach_Stream() */
if ( !filepathname )
return FT_Err_Invalid_Argument;
open.stream = NULL;
open.flags = FT_OPEN_PATHNAME;
open.pathname = (char*)filepathname;
return FT_Attach_Stream( face, &open );
}
|
CWE-119
| 10,226 | 16,911 |
75966508346506819653790830749115468753
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Attach_Stream( FT_Face face,
FT_Open_Args* parameters )
{
FT_Stream stream;
FT_Error error;
FT_Driver driver;
FT_Driver_Class clazz;
/* test for valid `parameters' delayed to FT_Stream_New() */
if ( !face )
return FT_Err_Invalid_Face_Handle;
driver = face->driver;
if ( !driver )
return FT_Err_Invalid_Driver_Handle;
error = FT_Stream_New( driver->root.library, parameters, &stream );
if ( error )
goto Exit;
/* we implement FT_Attach_Stream in each driver through the */
/* `attach_file' interface */
error = FT_Err_Unimplemented_Feature;
clazz = driver->clazz;
if ( clazz->attach_file )
error = clazz->attach_file( face, stream );
/* close the attached stream */
FT_Stream_Free( stream,
(FT_Bool)( parameters->stream &&
( parameters->flags & FT_OPEN_STREAM ) ) );
Exit:
return error;
}
|
CWE-119
| 10,227 | 16,912 |
183581392006509022104739799147922032919
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_CMap_Done( FT_CMap cmap )
{
if ( cmap )
{
FT_Face face = cmap->charmap.face;
FT_Memory memory = FT_FACE_MEMORY( face );
FT_Error error;
FT_Int i, j;
for ( i = 0; i < face->num_charmaps; i++ )
{
if ( (FT_CMap)face->charmaps[i] == cmap )
{
FT_CharMap last_charmap = face->charmaps[face->num_charmaps - 1];
if ( FT_RENEW_ARRAY( face->charmaps,
face->num_charmaps,
face->num_charmaps - 1 ) )
return;
/* remove it from our list of charmaps */
for ( j = i + 1; j < face->num_charmaps; j++ )
{
if ( j == face->num_charmaps - 1 )
face->charmaps[j - 1] = last_charmap;
else
face->charmaps[j - 1] = face->charmaps[j];
}
face->num_charmaps--;
if ( (FT_CMap)face->charmap == cmap )
face->charmap = NULL;
ft_cmap_done_internal( cmap );
break;
}
}
}
}
|
CWE-119
| 10,228 | 16,913 |
50836940226643470430221146004274462305
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_CMap_New( FT_CMap_Class clazz,
FT_Pointer init_data,
FT_CharMap charmap,
FT_CMap *acmap )
{
FT_Error error = FT_Err_Ok;
FT_Face face;
FT_Memory memory;
FT_CMap cmap;
if ( clazz == NULL || charmap == NULL || charmap->face == NULL )
return FT_Err_Invalid_Argument;
face = charmap->face;
memory = FT_FACE_MEMORY( face );
if ( !FT_ALLOC( cmap, clazz->size ) )
{
cmap->charmap = *charmap;
cmap->clazz = clazz;
if ( clazz->init )
{
error = clazz->init( cmap, init_data );
if ( error )
goto Fail;
}
/* add it to our list of charmaps */
if ( FT_RENEW_ARRAY( face->charmaps,
face->num_charmaps,
face->num_charmaps + 1 ) )
goto Fail;
face->charmaps[face->num_charmaps++] = (FT_CharMap)cmap;
}
Exit:
if ( acmap )
*acmap = cmap;
return error;
Fail:
ft_cmap_done_internal( cmap );
cmap = NULL;
goto Exit;
}
|
CWE-119
| 10,229 | 16,914 |
295120020779088562641349712412638987780
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Done_Face( FT_Face face )
{
FT_Error error;
FT_Driver driver;
FT_Memory memory;
FT_ListNode node;
error = FT_Err_Invalid_Face_Handle;
if ( face && face->driver )
{
driver = face->driver;
memory = driver->root.memory;
/* find face in driver's list */
node = FT_List_Find( &driver->faces_list, face );
if ( node )
{
/* remove face object from the driver's list */
FT_List_Remove( &driver->faces_list, node );
FT_FREE( node );
/* now destroy the object proper */
destroy_face( memory, face, driver );
error = FT_Err_Ok;
}
}
return error;
}
|
CWE-119
| 10,230 | 16,915 |
83343645119735729127834910685060992681
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Done_Library( FT_Library library )
{
FT_Memory memory;
if ( !library )
return FT_Err_Invalid_Library_Handle;
memory = library->memory;
/* Discard client-data */
if ( library->generic.finalizer )
library->generic.finalizer( library );
/* Close all faces in the library. If we don't do
* this, we can have some subtle memory leaks.
* Example:
*
* - the cff font driver uses the pshinter module in cff_size_done
* - if the pshinter module is destroyed before the cff font driver,
* opened FT_Face objects managed by the driver are not properly
* destroyed, resulting in a memory leak
*/
{
FT_UInt n;
for ( n = 0; n < library->num_modules; n++ )
{
FT_Module module = library->modules[n];
FT_List faces;
if ( ( module->clazz->module_flags & FT_MODULE_FONT_DRIVER ) == 0 )
continue;
faces = &FT_DRIVER(module)->faces_list;
while ( faces->head )
{
FT_Done_Face( FT_FACE( faces->head->data ) );
if ( faces->head )
FT_TRACE0(( "FT_Done_Library: failed to free some faces\n" ));
}
}
}
/* Close all other modules in the library */
#if 1
/* XXX Modules are removed in the reversed order so that */
/* type42 module is removed before truetype module. This */
/* avoids double free in some occasions. It is a hack. */
while ( library->num_modules > 0 )
FT_Remove_Module( library,
library->modules[library->num_modules - 1] );
#else
{
FT_UInt n;
for ( n = 0; n < library->num_modules; n++ )
{
FT_Module module = library->modules[n];
if ( module )
{
Destroy_Module( module );
library->modules[n] = 0;
}
}
}
#endif
/* Destroy raster objects */
FT_FREE( library->raster_pool );
library->raster_pool_size = 0;
#ifdef FT_CONFIG_OPTION_PIC
/* Destroy pic container contents */
ft_pic_container_destroy( library );
#endif
FT_FREE( library );
return FT_Err_Ok;
}
|
CWE-119
| 10,231 | 16,916 |
111931851942677122794704215306652590228
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Face_GetCharVariantIndex( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector )
{
FT_UInt result = 0;
if ( face && face->charmap &&
face->charmap->encoding == FT_ENCODING_UNICODE )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
FT_CMap ucmap = FT_CMAP( face->charmap );
if ( charmap != NULL )
{
FT_CMap vcmap = FT_CMAP( charmap );
if ( charcode > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Get_Char_Index: too large charcode" ));
FT_TRACE1(( " 0x%x is truncated\n", charcode ));
}
if ( variantSelector > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" ));
FT_TRACE1(( " 0x%x is truncated\n", variantSelector ));
}
result = vcmap->clazz->char_var_index( vcmap, ucmap,
(FT_UInt32)charcode,
(FT_UInt32)variantSelector );
}
}
return result;
}
|
CWE-119
| 10,232 | 16,917 |
64404405854836178947719118253436819106
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Face_GetCharVariantIsDefault( FT_Face face,
FT_ULong charcode,
FT_ULong variantSelector )
{
FT_Int result = -1;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
{
FT_CMap vcmap = FT_CMAP( charmap );
if ( charcode > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Get_Char_Index: too large charcode" ));
FT_TRACE1(( " 0x%x is truncated\n", charcode ));
}
if ( variantSelector > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" ));
FT_TRACE1(( " 0x%x is truncated\n", variantSelector ));
}
result = vcmap->clazz->char_var_default( vcmap,
(FT_UInt32)charcode,
(FT_UInt32)variantSelector );
}
}
return result;
}
|
CWE-119
| 10,233 | 16,918 |
275588250150286973560822956852076205608
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Face_GetCharsOfVariant( FT_Face face,
FT_ULong variantSelector )
{
FT_UInt32 *result = NULL;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
if ( variantSelector > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Get_Char_Index: too large variantSelector" ));
FT_TRACE1(( " 0x%x is truncated\n", variantSelector ));
}
result = vcmap->clazz->variantchar_list( vcmap, memory,
(FT_UInt32)variantSelector );
}
}
return result;
}
|
CWE-119
| 10,234 | 16,919 |
117344924290139907854396580216019371910
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Face_GetVariantSelectors( FT_Face face )
{
FT_UInt32 *result = NULL;
if ( face )
{
FT_CharMap charmap = find_variant_selector_charmap( face );
if ( charmap != NULL )
{
FT_CMap vcmap = FT_CMAP( charmap );
FT_Memory memory = FT_FACE_MEMORY( face );
result = vcmap->clazz->variant_list( vcmap, memory );
}
}
return result;
}
|
CWE-119
| 10,235 | 16,920 |
150586754018346500460495186334855953241
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_CMap_Language_ID( FT_CharMap charmap )
{
FT_Service_TTCMaps service;
FT_Face face;
TT_CMapInfo cmap_info;
if ( !charmap || !charmap->face )
return 0;
face = charmap->face;
FT_FACE_FIND_SERVICE( face, service, TT_CMAP );
if ( service == NULL )
return 0;
if ( service->get_cmap_info( charmap, &cmap_info ))
return 0;
return cmap_info.language;
}
|
CWE-119
| 10,237 | 16,921 |
37200294448175616749617504717369999165
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_Char_Index( FT_Face face,
FT_ULong charcode )
{
FT_UInt result = 0;
if ( face && face->charmap )
{
FT_CMap cmap = FT_CMAP( face->charmap );
if ( charcode > 0xFFFFFFFFUL )
{
FT_TRACE1(( "FT_Get_Char_Index: too large charcode" ));
FT_TRACE1(( " 0x%x is truncated\n", charcode ));
}
result = cmap->clazz->char_index( cmap, (FT_UInt32)charcode );
}
return result;
}
|
CWE-119
| 10,238 | 16,922 |
250852244457090112689598240129667088057
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_Charmap_Index( FT_CharMap charmap )
{
FT_Int i;
if ( !charmap || !charmap->face )
return -1;
for ( i = 0; i < charmap->face->num_charmaps; i++ )
if ( charmap->face->charmaps[i] == charmap )
break;
FT_ASSERT( i < charmap->face->num_charmaps );
return i;
}
|
CWE-119
| 10,239 | 16,923 |
135556997230097378699562045790388798805
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_First_Char( FT_Face face,
FT_UInt *agindex )
{
FT_ULong result = 0;
FT_UInt gindex = 0;
if ( face && face->charmap && face->num_glyphs )
{
gindex = FT_Get_Char_Index( face, 0 );
if ( gindex == 0 || gindex >= (FT_UInt)face->num_glyphs )
result = FT_Get_Next_Char( face, 0, &gindex );
}
if ( agindex )
*agindex = gindex;
return result;
}
|
CWE-119
| 10,240 | 16,924 |
94860495684710128077645606754467353017
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_Kerning( FT_Face face,
FT_UInt left_glyph,
FT_UInt right_glyph,
FT_UInt kern_mode,
FT_Vector *akerning )
{
FT_Error error = FT_Err_Ok;
FT_Driver driver;
if ( !face )
return FT_Err_Invalid_Face_Handle;
if ( !akerning )
return FT_Err_Invalid_Argument;
driver = face->driver;
akerning->x = 0;
akerning->y = 0;
if ( driver->clazz->get_kerning )
{
error = driver->clazz->get_kerning( face,
left_glyph,
right_glyph,
akerning );
if ( !error )
{
if ( kern_mode != FT_KERNING_UNSCALED )
{
akerning->x = FT_MulFix( akerning->x, face->size->metrics.x_scale );
akerning->y = FT_MulFix( akerning->y, face->size->metrics.y_scale );
if ( kern_mode != FT_KERNING_UNFITTED )
{
/* we scale down kerning values for small ppem values */
/* to avoid that rounding makes them too big. */
/* `25' has been determined heuristically. */
if ( face->size->metrics.x_ppem < 25 )
akerning->x = FT_MulDiv( akerning->x,
face->size->metrics.x_ppem, 25 );
if ( face->size->metrics.y_ppem < 25 )
akerning->y = FT_MulDiv( akerning->y,
face->size->metrics.y_ppem, 25 );
akerning->x = FT_PIX_ROUND( akerning->x );
akerning->y = FT_PIX_ROUND( akerning->y );
}
}
}
}
return error;
}
|
CWE-119
| 10,241 | 16,925 |
90877790786642961076912187314199635853
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_Module( FT_Library library,
const char* module_name )
{
FT_Module result = 0;
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 ( ft_strcmp( cur[0]->clazz->module_name, module_name ) == 0 )
{
result = cur[0];
break;
}
return result;
}
|
CWE-119
| 10,242 | 16,926 |
189831338823309611329827331886353782503
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_Module_Interface( FT_Library library,
const char* mod_name )
{
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;
}
|
CWE-119
| 10,243 | 16,927 |
154247570582429571155665131340942057412
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_Name_Index( FT_Face face,
FT_String* glyph_name )
{
FT_UInt result = 0;
if ( face && FT_HAS_GLYPH_NAMES( face ) )
{
FT_Service_GlyphDict service;
FT_FACE_LOOKUP_SERVICE( face,
service,
GLYPH_DICT );
if ( service && service->name_index )
result = service->name_index( face, glyph_name );
}
return result;
}
|
CWE-119
| 10,244 | 16,928 |
247840993301607841266237313245286506961
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_Postscript_Name( FT_Face face )
{
const char* result = NULL;
if ( !face )
goto Exit;
if ( !result )
{
FT_Service_PsFontName service;
FT_FACE_LOOKUP_SERVICE( face,
service,
POSTSCRIPT_FONT_NAME );
if ( service && service->get_ps_font_name )
result = service->get_ps_font_name( face );
}
Exit:
return result;
}
|
CWE-119
| 10,246 | 16,929 |
175425568108816421966295918708579839912
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
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 );
}
|
CWE-119
| 10,247 | 16,930 |
154327940569130513927284410050478379735
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_Sfnt_Table( FT_Face face,
FT_Sfnt_Tag tag )
{
void* table = 0;
FT_Service_SFNT_Table service;
if ( face && FT_IS_SFNT( face ) )
{
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service != NULL )
table = service->get_table( face, tag );
}
return table;
}
|
CWE-119
| 10,248 | 16,931 |
24475752390687699901333018745869894819
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_SubGlyph_Info( FT_GlyphSlot glyph,
FT_UInt sub_index,
FT_Int *p_index,
FT_UInt *p_flags,
FT_Int *p_arg1,
FT_Int *p_arg2,
FT_Matrix *p_transform )
{
FT_Error error = FT_Err_Invalid_Argument;
if ( glyph &&
glyph->subglyphs &&
glyph->format == FT_GLYPH_FORMAT_COMPOSITE &&
sub_index < glyph->num_subglyphs )
{
FT_SubGlyph subg = glyph->subglyphs + sub_index;
*p_index = subg->index;
*p_flags = subg->flags;
*p_arg1 = subg->arg1;
*p_arg2 = subg->arg2;
*p_transform = subg->transform;
}
return error;
}
|
CWE-119
| 10,249 | 16,932 |
338973108884348808543283455035347831195
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Get_Track_Kerning( FT_Face face,
FT_Fixed point_size,
FT_Int degree,
FT_Fixed* akerning )
{
FT_Service_Kerning service;
FT_Error error = FT_Err_Ok;
if ( !face )
return FT_Err_Invalid_Face_Handle;
if ( !akerning )
return FT_Err_Invalid_Argument;
FT_FACE_FIND_SERVICE( face, service, KERNING );
if ( !service )
return FT_Err_Unimplemented_Feature;
error = service->get_track( face,
point_size,
degree,
akerning );
return error;
}
|
CWE-119
| 10,250 | 16,933 |
307095497844328325327745861723201378790
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Library_Version( FT_Library library,
FT_Int *amajor,
FT_Int *aminor,
FT_Int *apatch )
{
FT_Int major = 0;
FT_Int minor = 0;
FT_Int patch = 0;
if ( library )
{
major = library->version_major;
minor = library->version_minor;
patch = library->version_patch;
}
if ( amajor )
*amajor = major;
if ( aminor )
*aminor = minor;
if ( apatch )
*apatch = patch;
}
|
CWE-119
| 10,251 | 16,934 |
277827923999515488613105359422850226660
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Load_Sfnt_Table( FT_Face face,
FT_ULong tag,
FT_Long offset,
FT_Byte* buffer,
FT_ULong* length )
{
FT_Service_SFNT_Table service;
if ( !face || !FT_IS_SFNT( face ) )
return FT_Err_Invalid_Face_Handle;
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service == NULL )
return FT_Err_Unimplemented_Feature;
return service->load_table( face, tag, offset, buffer, length );
}
|
CWE-119
| 10,252 | 16,935 |
165686658451248672556952055617633299233
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Lookup_Renderer( FT_Library library,
FT_Glyph_Format format,
FT_ListNode* node )
{
FT_ListNode cur;
FT_Renderer result = 0;
if ( !library )
goto Exit;
cur = library->renderers.head;
if ( node )
{
if ( *node )
cur = (*node)->next;
*node = 0;
}
while ( cur )
{
FT_Renderer renderer = FT_RENDERER( cur->data );
if ( renderer->glyph_format == format )
{
if ( node )
*node = cur;
result = renderer;
break;
}
cur = cur->next;
}
Exit:
return result;
}
|
CWE-119
| 10,253 | 16,936 |
303652953797404113558489740546876226465
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Match_Size( FT_Face face,
FT_Size_Request req,
FT_Bool ignore_width,
FT_ULong* size_index )
{
FT_Int i;
FT_Long w, h;
if ( !FT_HAS_FIXED_SIZES( face ) )
return FT_Err_Invalid_Face_Handle;
/* FT_Bitmap_Size doesn't provide enough info... */
if ( req->type != FT_SIZE_REQUEST_TYPE_NOMINAL )
return FT_Err_Unimplemented_Feature;
w = FT_REQUEST_WIDTH ( req );
h = FT_REQUEST_HEIGHT( req );
if ( req->width && !req->height )
h = w;
else if ( !req->width && req->height )
w = h;
w = FT_PIX_ROUND( w );
h = FT_PIX_ROUND( h );
for ( i = 0; i < face->num_fixed_sizes; i++ )
{
FT_Bitmap_Size* bsize = face->available_sizes + i;
if ( h != FT_PIX_ROUND( bsize->y_ppem ) )
continue;
if ( w == FT_PIX_ROUND( bsize->x_ppem ) || ignore_width )
{
if ( size_index )
*size_index = (FT_ULong)i;
return FT_Err_Ok;
}
}
return FT_Err_Invalid_Pixel_Size;
}
|
CWE-119
| 10,254 | 16,937 |
257171194998408814180364045456466278574
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_New_Library( FT_Memory memory,
FT_Library *alibrary )
{
FT_Library library = 0;
FT_Error error;
if ( !memory )
return FT_Err_Invalid_Argument;
#ifdef FT_DEBUG_LEVEL_ERROR
/* init debugging support */
ft_debug_init();
#endif
/* first of all, allocate the library object */
if ( FT_NEW( library ) )
return error;
library->memory = memory;
#ifdef FT_CONFIG_OPTION_PIC
/* initialize position independent code containers */
error = ft_pic_container_init( library );
if ( error )
goto Fail;
#endif
/* allocate the render pool */
library->raster_pool_size = FT_RENDER_POOL_SIZE;
#if FT_RENDER_POOL_SIZE > 0
if ( FT_ALLOC( library->raster_pool, FT_RENDER_POOL_SIZE ) )
goto Fail;
#endif
library->version_major = FREETYPE_MAJOR;
library->version_minor = FREETYPE_MINOR;
library->version_patch = FREETYPE_PATCH;
/* That's ok now */
*alibrary = library;
return FT_Err_Ok;
Fail:
#ifdef FT_CONFIG_OPTION_PIC
ft_pic_container_destroy( library );
#endif
FT_FREE( library );
return error;
}
|
CWE-119
| 10,256 | 16,938 |
257639077604464994117906009672584681668
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_New_Memory_Face( FT_Library library,
const FT_Byte* file_base,
FT_Long file_size,
FT_Long face_index,
FT_Face *aface )
{
FT_Open_Args args;
/* test for valid `library' and `face' delayed to FT_Open_Face() */
if ( !file_base )
return FT_Err_Invalid_Argument;
args.flags = FT_OPEN_MEMORY;
args.memory_base = file_base;
args.memory_size = file_size;
args.stream = NULL;
return FT_Open_Face( library, &args, face_index, aface );
}
|
CWE-119
| 10,257 | 16,939 |
262132965597654431215634269897774062201
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_New_Size( FT_Face face,
FT_Size *asize )
{
FT_Error error;
FT_Memory memory;
FT_Driver driver;
FT_Driver_Class clazz;
FT_Size size = 0;
FT_ListNode node = 0;
if ( !face )
return FT_Err_Invalid_Face_Handle;
if ( !asize )
return FT_Err_Invalid_Size_Handle;
if ( !face->driver )
return FT_Err_Invalid_Driver_Handle;
*asize = 0;
driver = face->driver;
clazz = driver->clazz;
memory = face->memory;
/* Allocate new size object and perform basic initialisation */
if ( FT_ALLOC( size, clazz->size_object_size ) || FT_NEW( node ) )
goto Exit;
size->face = face;
/* for now, do not use any internal fields in size objects */
size->internal = 0;
if ( clazz->init_size )
error = clazz->init_size( size );
/* in case of success, add to the face's list */
if ( !error )
{
*asize = size;
node->data = size;
FT_List_Add( &face->sizes_list, node );
}
Exit:
if ( error )
{
FT_FREE( node );
FT_FREE( size );
}
return error;
}
|
CWE-119
| 10,258 | 16,940 |
176075560283927700777534032516777610724
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Open_Face( FT_Library library,
const FT_Open_Args* args,
FT_Long face_index,
FT_Face *aface )
{
FT_Error error;
FT_Driver driver;
FT_Memory memory;
FT_Stream stream = 0;
FT_Face face = 0;
FT_ListNode node = 0;
FT_Bool external_stream;
FT_Module* cur;
FT_Module* limit;
/* test for valid `library' delayed to */
/* FT_Stream_New() */
if ( ( !aface && face_index >= 0 ) || !args )
return FT_Err_Invalid_Argument;
external_stream = FT_BOOL( ( args->flags & FT_OPEN_STREAM ) &&
args->stream );
/* create input stream */
error = FT_Stream_New( library, args, &stream );
if ( error )
goto Fail3;
memory = library->memory;
/* If the font driver is specified in the `args' structure, use */
/* it. Otherwise, we scan the list of registered drivers. */
if ( ( args->flags & FT_OPEN_DRIVER ) && args->driver )
{
driver = FT_DRIVER( args->driver );
/* not all modules are drivers, so check... */
if ( FT_MODULE_IS_DRIVER( driver ) )
{
FT_Int num_params = 0;
FT_Parameter* params = 0;
if ( args->flags & FT_OPEN_PARAMS )
{
num_params = args->num_params;
params = args->params;
}
error = open_face( driver, stream, face_index,
num_params, params, &face );
if ( !error )
goto Success;
}
else
error = FT_Err_Invalid_Handle;
FT_Stream_Free( stream, external_stream );
goto Fail;
}
else
{
/* check each font driver for an appropriate format */
cur = library->modules;
limit = cur + library->num_modules;
for ( ; cur < limit; cur++ )
{
/* not all modules are font drivers, so check... */
if ( FT_MODULE_IS_DRIVER( cur[0] ) )
{
FT_Int num_params = 0;
FT_Parameter* params = 0;
driver = FT_DRIVER( cur[0] );
if ( args->flags & FT_OPEN_PARAMS )
{
num_params = args->num_params;
params = args->params;
}
error = open_face( driver, stream, face_index,
num_params, params, &face );
if ( !error )
goto Success;
#ifdef FT_CONFIG_OPTION_MAC_FONTS
if ( ft_strcmp( cur[0]->clazz->module_name, "truetype" ) == 0 &&
FT_ERROR_BASE( error ) == FT_Err_Table_Missing )
{
/* TrueType but essential tables are missing */
if ( FT_Stream_Seek( stream, 0 ) )
break;
error = open_face_PS_from_sfnt_stream( library,
stream,
face_index,
num_params,
params,
aface );
if ( !error )
{
FT_Stream_Free( stream, external_stream );
return error;
}
}
#endif
if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format )
goto Fail3;
}
}
Fail3:
/* If we are on the mac, and we get an FT_Err_Invalid_Stream_Operation */
/* it may be because we have an empty data fork, so we need to check */
/* the resource fork. */
if ( FT_ERROR_BASE( error ) != FT_Err_Cannot_Open_Stream &&
FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format &&
FT_ERROR_BASE( error ) != FT_Err_Invalid_Stream_Operation )
goto Fail2;
#if !defined( FT_MACINTOSH ) && defined( FT_CONFIG_OPTION_MAC_FONTS )
error = load_mac_face( library, stream, face_index, aface, args );
if ( !error )
{
/* We don't want to go to Success here. We've already done that. */
/* On the other hand, if we succeeded we still need to close this */
/* stream (we opened a different stream which extracted the */
/* interesting information out of this stream here. That stream */
/* will still be open and the face will point to it). */
FT_Stream_Free( stream, external_stream );
return error;
}
if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format )
goto Fail2;
#endif /* !FT_MACINTOSH && FT_CONFIG_OPTION_MAC_FONTS */
/* no driver is able to handle this format */
error = FT_Err_Unknown_File_Format;
Fail2:
FT_Stream_Free( stream, external_stream );
goto Fail;
}
Success:
FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" ));
/* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */
if ( external_stream )
face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
/* add the face object to its driver's list */
if ( FT_NEW( node ) )
goto Fail;
node->data = face;
/* don't assume driver is the same as face->driver, so use */
/* face->driver instead. */
FT_List_Add( &face->driver->faces_list, node );
/* now allocate a glyph slot object for the face */
FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" ));
if ( face_index >= 0 )
{
error = FT_New_GlyphSlot( face, NULL );
if ( error )
goto Fail;
/* finally, allocate a size object for the face */
{
FT_Size size;
FT_TRACE4(( "FT_Open_Face: Creating size object\n" ));
error = FT_New_Size( face, &size );
if ( error )
goto Fail;
face->size = size;
}
}
/* some checks */
if ( FT_IS_SCALABLE( face ) )
{
if ( face->height < 0 )
face->height = (FT_Short)-face->height;
if ( !FT_HAS_VERTICAL( face ) )
face->max_advance_height = (FT_Short)face->height;
}
if ( FT_HAS_FIXED_SIZES( face ) )
{
FT_Int i;
for ( i = 0; i < face->num_fixed_sizes; i++ )
{
FT_Bitmap_Size* bsize = face->available_sizes + i;
if ( bsize->height < 0 )
bsize->height = (FT_Short)-bsize->height;
if ( bsize->x_ppem < 0 )
bsize->x_ppem = (FT_Short)-bsize->x_ppem;
if ( bsize->y_ppem < 0 )
bsize->y_ppem = -bsize->y_ppem;
}
}
/* initialize internal face data */
{
FT_Face_Internal internal = face->internal;
internal->transform_matrix.xx = 0x10000L;
internal->transform_matrix.xy = 0;
internal->transform_matrix.yx = 0;
internal->transform_matrix.yy = 0x10000L;
internal->transform_delta.x = 0;
internal->transform_delta.y = 0;
}
if ( aface )
*aface = face;
else
FT_Done_Face( face );
goto Exit;
Fail:
FT_Done_Face( face );
Exit:
FT_TRACE4(( "FT_Open_Face: Return %d\n", error ));
return error;
}
|
CWE-119
| 10,259 | 16,941 |
273245254141554235215450630174968549911
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Remove_Module( FT_Library library,
FT_Module module )
{
/* try to find the module from the table, then remove it from there */
if ( !library )
return FT_Err_Invalid_Library_Handle;
if ( module )
{
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
for ( ; cur < limit; cur++ )
{
if ( cur[0] == module )
{
/* remove it from the table */
library->num_modules--;
limit--;
while ( cur < limit )
{
cur[0] = cur[1];
cur++;
}
limit[0] = 0;
/* destroy the module */
Destroy_Module( module );
return FT_Err_Ok;
}
}
}
return FT_Err_Invalid_Driver_Handle;
}
|
CWE-119
| 10,260 | 16,942 |
308979820183446506923631494434582192796
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Render_Glyph( FT_GlyphSlot slot,
FT_Render_Mode render_mode )
{
FT_Library library;
if ( !slot || !slot->face )
return FT_Err_Invalid_Argument;
library = FT_FACE_LIBRARY( slot->face );
return FT_Render_Glyph_Internal( library, slot, render_mode );
}
|
CWE-119
| 10,261 | 16,943 |
296668467811529231021245972421468018773
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Render_Glyph_Internal( FT_Library library,
FT_GlyphSlot slot,
FT_Render_Mode render_mode )
{
FT_Error error = FT_Err_Ok;
FT_Renderer renderer;
/* 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;
default:
{
FT_ListNode node = 0;
FT_Bool update = 0;
/* small shortcut for the very common case */
if ( slot->format == FT_GLYPH_FORMAT_OUTLINE )
{
renderer = library->cur_renderer;
node = library->renderers.head;
}
else
renderer = FT_Lookup_Renderer( library, slot->format, &node );
error = FT_Err_Unimplemented_Feature;
while ( renderer )
{
error = renderer->render( renderer, slot, render_mode, NULL );
if ( !error ||
FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph )
break;
/* FT_Err_Cannot_Render_Glyph is returned if 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 );
}
}
return error;
}
|
CWE-119
| 10,262 | 16,944 |
306978565671891282184685464000992525041
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Request_Size( FT_Face face,
FT_Size_Request req )
{
FT_Driver_Class clazz;
FT_ULong strike_index;
if ( !face )
return FT_Err_Invalid_Face_Handle;
if ( !req || req->width < 0 || req->height < 0 ||
req->type >= FT_SIZE_REQUEST_TYPE_MAX )
return FT_Err_Invalid_Argument;
clazz = face->driver->clazz;
if ( clazz->request_size )
return clazz->request_size( face->size, req );
/*
* The reason that a driver doesn't have `request_size' defined is
* either that the scaling here suffices or that the supported formats
* are bitmap-only and size matching is not implemented.
*
* In the latter case, a simple size matching is done.
*/
if ( !FT_IS_SCALABLE( face ) && FT_HAS_FIXED_SIZES( face ) )
{
FT_Error error;
error = FT_Match_Size( face, req, 0, &strike_index );
if ( error )
return error;
FT_TRACE3(( "FT_Request_Size: bitmap strike %lu matched\n",
strike_index ));
return FT_Select_Size( face, (FT_Int)strike_index );
}
FT_Request_Metrics( face, req );
return FT_Err_Ok;
}
|
CWE-119
| 10,263 | 16,945 |
337161367517149691921788182810981375842
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Select_Charmap( FT_Face face,
FT_Encoding encoding )
{
FT_CharMap* cur;
FT_CharMap* limit;
if ( !face )
return FT_Err_Invalid_Face_Handle;
if ( encoding == FT_ENCODING_NONE )
return FT_Err_Invalid_Argument;
/* FT_ENCODING_UNICODE is special. We try to find the `best' Unicode */
/* charmap available, i.e., one with UCS-4 characters, if possible. */
/* */
/* This is done by find_unicode_charmap() above, to share code. */
if ( encoding == FT_ENCODING_UNICODE )
return find_unicode_charmap( face );
cur = face->charmaps;
if ( !cur )
return FT_Err_Invalid_CharMap_Handle;
limit = cur + face->num_charmaps;
for ( ; cur < limit; cur++ )
{
if ( cur[0]->encoding == encoding )
{
face->charmap = cur[0];
return 0;
}
}
return FT_Err_Invalid_Argument;
}
|
CWE-119
| 10,264 | 16,946 |
302596655134398674999260613371947867055
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Select_Metrics( FT_Face face,
FT_ULong strike_index )
{
FT_Size_Metrics* metrics;
FT_Bitmap_Size* bsize;
metrics = &face->size->metrics;
bsize = face->available_sizes + strike_index;
metrics->x_ppem = (FT_UShort)( ( bsize->x_ppem + 32 ) >> 6 );
metrics->y_ppem = (FT_UShort)( ( bsize->y_ppem + 32 ) >> 6 );
if ( FT_IS_SCALABLE( face ) )
{
metrics->x_scale = FT_DivFix( bsize->x_ppem,
face->units_per_EM );
metrics->y_scale = FT_DivFix( bsize->y_ppem,
face->units_per_EM );
ft_recompute_scaled_metrics( face, metrics );
}
else
{
metrics->x_scale = 1L << 16;
metrics->y_scale = 1L << 16;
metrics->ascender = bsize->y_ppem;
metrics->descender = 0;
metrics->height = bsize->height << 6;
metrics->max_advance = bsize->x_ppem;
}
}
|
CWE-119
| 10,265 | 16,947 |
240738904139523310509364469348408864594
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Select_Size( FT_Face face,
FT_Int strike_index )
{
FT_Driver_Class clazz;
if ( !face || !FT_HAS_FIXED_SIZES( face ) )
return FT_Err_Invalid_Face_Handle;
if ( strike_index < 0 || strike_index >= face->num_fixed_sizes )
return FT_Err_Invalid_Argument;
clazz = face->driver->clazz;
if ( clazz->select_size )
return clazz->select_size( face->size, (FT_ULong)strike_index );
FT_Select_Metrics( face, (FT_ULong)strike_index );
return FT_Err_Ok;
}
|
CWE-119
| 10,266 | 16,948 |
336910071881906141433058311031096305000
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Set_Char_Size( FT_Face face,
FT_F26Dot6 char_width,
FT_F26Dot6 char_height,
FT_UInt horz_resolution,
FT_UInt vert_resolution )
{
FT_Size_RequestRec req;
if ( !char_width )
char_width = char_height;
else if ( !char_height )
char_height = char_width;
if ( !horz_resolution )
horz_resolution = vert_resolution;
else if ( !vert_resolution )
vert_resolution = horz_resolution;
if ( char_width < 1 * 64 )
char_width = 1 * 64;
if ( char_height < 1 * 64 )
char_height = 1 * 64;
if ( !horz_resolution )
horz_resolution = vert_resolution = 72;
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = char_width;
req.height = char_height;
req.horiResolution = horz_resolution;
req.vertResolution = vert_resolution;
return FT_Request_Size( face, &req );
}
|
CWE-119
| 10,267 | 16,949 |
67807585680395436142238443389467995072
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Set_Charmap( FT_Face face,
FT_CharMap charmap )
{
FT_CharMap* cur;
FT_CharMap* limit;
if ( !face )
return FT_Err_Invalid_Face_Handle;
cur = face->charmaps;
if ( !cur )
return FT_Err_Invalid_CharMap_Handle;
if ( FT_Get_CMap_Format( charmap ) == 14 )
return FT_Err_Invalid_Argument;
limit = cur + face->num_charmaps;
for ( ; cur < limit; cur++ )
{
if ( cur[0] == charmap )
{
face->charmap = cur[0];
return 0;
}
}
return FT_Err_Invalid_Argument;
}
|
CWE-119
| 10,268 | 16,950 |
28811251026148087801135833230058036612
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Set_Debug_Hook( FT_Library library,
FT_UInt hook_index,
FT_DebugHook_Func debug_hook )
{
if ( library && debug_hook &&
hook_index <
( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) )
library->debug_hooks[hook_index] = debug_hook;
}
|
CWE-119
| 10,269 | 16,951 |
139163630972631197553362683332387065214
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Set_Pixel_Sizes( FT_Face face,
FT_UInt pixel_width,
FT_UInt pixel_height )
{
FT_Size_RequestRec req;
if ( pixel_width == 0 )
pixel_width = pixel_height;
else if ( pixel_height == 0 )
pixel_height = pixel_width;
if ( pixel_width < 1 )
pixel_width = 1;
if ( pixel_height < 1 )
pixel_height = 1;
/* use `>=' to avoid potential compiler warning on 16bit platforms */
if ( pixel_width >= 0xFFFFU )
pixel_width = 0xFFFFU;
if ( pixel_height >= 0xFFFFU )
pixel_height = 0xFFFFU;
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = pixel_width << 6;
req.height = pixel_height << 6;
req.horiResolution = 0;
req.vertResolution = 0;
return FT_Request_Size( face, &req );
}
|
CWE-119
| 10,270 | 16,952 |
60649479645925516409532911965359183660
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Set_Renderer( FT_Library library,
FT_Renderer renderer,
FT_UInt num_params,
FT_Parameter* parameters )
{
FT_ListNode node;
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 )
{
error = FT_Err_Invalid_Argument;
goto Exit;
}
FT_List_Up( &library->renderers, node );
if ( renderer->glyph_format == FT_GLYPH_FORMAT_OUTLINE )
library->cur_renderer = renderer;
if ( num_params > 0 )
{
FT_Renderer_SetModeFunc set_mode = renderer->clazz->set_mode;
for ( ; num_params > 0; num_params-- )
{
error = set_mode( renderer, parameters->tag, parameters->data );
if ( error )
break;
}
}
Exit:
return error;
}
|
CWE-119
| 10,271 | 16,953 |
215589387701807689847682631079915820216
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
FT_Sfnt_Table_Info( FT_Face face,
FT_UInt table_index,
FT_ULong *tag,
FT_ULong *length )
{
FT_Service_SFNT_Table service;
FT_ULong offset;
if ( !face || !FT_IS_SFNT( face ) )
return FT_Err_Invalid_Face_Handle;
FT_FACE_FIND_SERVICE( face, service, SFNT_TABLE );
if ( service == NULL )
return FT_Err_Unimplemented_Feature;
return service->table_info( face, table_index, tag, &offset, length );
}
|
CWE-119
| 10,272 | 16,954 |
168390477476319345586507691457536988847
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
IsMacBinary( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Face *aface )
{
unsigned char header[128];
FT_Error error;
FT_Long dlen, offset;
if ( NULL == stream )
return FT_Err_Invalid_Stream_Operation;
error = FT_Stream_Seek( stream, 0 );
if ( error )
goto Exit;
error = FT_Stream_Read( stream, (FT_Byte*)header, 128 );
if ( error )
goto Exit;
if ( header[ 0] != 0 ||
header[74] != 0 ||
header[82] != 0 ||
header[ 1] == 0 ||
header[ 1] > 33 ||
header[63] != 0 ||
header[2 + header[1]] != 0 )
return FT_Err_Unknown_File_Format;
dlen = ( header[0x53] << 24 ) |
( header[0x54] << 16 ) |
( header[0x55] << 8 ) |
header[0x56];
#if 0
rlen = ( header[0x57] << 24 ) |
( header[0x58] << 16 ) |
( header[0x59] << 8 ) |
header[0x5a];
#endif /* 0 */
offset = 128 + ( ( dlen + 127 ) & ~127 );
return IsMacResource( library, stream, offset, face_index, aface );
Exit:
return error;
}
|
CWE-119
| 10,273 | 16,955 |
23977310350916873267271707182396717799
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
IsMacResource( FT_Library library,
FT_Stream stream,
FT_Long resource_offset,
FT_Long face_index,
FT_Face *aface )
{
FT_Memory memory = library->memory;
FT_Error error;
FT_Long map_offset, rdara_pos;
FT_Long *data_offsets;
FT_Long count;
error = FT_Raccess_Get_HeaderInfo( library, stream, resource_offset,
&map_offset, &rdara_pos );
if ( error )
return error;
error = FT_Raccess_Get_DataOffsets( library, stream,
map_offset, rdara_pos,
TTAG_POST,
&data_offsets, &count );
if ( !error )
{
error = Mac_Read_POST_Resource( library, stream, data_offsets, count,
face_index, aface );
FT_FREE( data_offsets );
/* POST exists in an LWFN providing a single face */
if ( !error )
(*aface)->num_faces = 1;
return error;
}
error = FT_Raccess_Get_DataOffsets( library, stream,
map_offset, rdara_pos,
TTAG_sfnt,
&data_offsets, &count );
if ( !error )
{
FT_Long face_index_internal = face_index % count;
error = Mac_Read_sfnt_Resource( library, stream, data_offsets, count,
face_index_internal, aface );
FT_FREE( data_offsets );
if ( !error )
(*aface)->num_faces = count;
}
return error;
}
|
CWE-119
| 10,274 | 16,956 |
38049621751917040321955086663323408335
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
Mac_Read_sfnt_Resource( FT_Library library,
FT_Stream stream,
FT_Long *offsets,
FT_Long resource_cnt,
FT_Long face_index,
FT_Face *aface )
{
FT_Memory memory = library->memory;
FT_Byte* sfnt_data;
FT_Error error;
FT_Long flag_offset;
FT_Long rlen;
int is_cff;
FT_Long face_index_in_resource = 0;
if ( face_index == -1 )
face_index = 0;
if ( face_index >= resource_cnt )
return FT_Err_Cannot_Open_Resource;
flag_offset = offsets[face_index];
error = FT_Stream_Seek( stream, flag_offset );
if ( error )
goto Exit;
if ( FT_READ_LONG( rlen ) )
goto Exit;
if ( rlen == -1 )
return FT_Err_Cannot_Open_Resource;
error = open_face_PS_from_sfnt_stream( library,
stream,
face_index,
0, NULL,
aface );
if ( !error )
goto Exit;
/* rewind sfnt stream before open_face_PS_from_sfnt_stream() */
if ( FT_Stream_Seek( stream, flag_offset + 4 ) )
goto Exit;
if ( FT_ALLOC( sfnt_data, (FT_Long)rlen ) )
return error;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_data, rlen );
if ( error )
goto Exit;
is_cff = rlen > 4 && !ft_memcmp( sfnt_data, "OTTO", 4 );
error = open_face_from_buffer( library,
sfnt_data,
rlen,
face_index_in_resource,
is_cff ? "cff" : "truetype",
aface );
Exit:
return error;
}
|
CWE-119
| 10,275 | 16,957 |
274812937675230296637873008993265648268
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_add_renderer( FT_Module module )
{
FT_Library library = module->library;
FT_Memory memory = library->memory;
FT_Error error;
FT_ListNode node;
if ( FT_NEW( node ) )
goto Exit;
{
FT_Renderer render = FT_RENDERER( module );
FT_Renderer_Class* clazz = (FT_Renderer_Class*)module->clazz;
render->clazz = clazz;
render->glyph_format = clazz->glyph_format;
/* allocate raster object if needed */
if ( clazz->glyph_format == FT_GLYPH_FORMAT_OUTLINE &&
clazz->raster_class->raster_new )
{
error = clazz->raster_class->raster_new( memory, &render->raster );
if ( error )
goto Fail;
render->raster_render = clazz->raster_class->raster_render;
render->render = clazz->render_glyph;
}
/* add to list */
node->data = module;
FT_List_Add( &library->renderers, node );
ft_set_current_renderer( library );
}
Fail:
if ( error )
FT_FREE( node );
Exit:
return error;
}
|
CWE-119
| 10,276 | 16,958 |
314490712491282108870182559933522665901
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_cmap_done_internal( FT_CMap cmap )
{
FT_CMap_Class clazz = cmap->clazz;
FT_Face face = cmap->charmap.face;
FT_Memory memory = FT_FACE_MEMORY(face);
if ( clazz->done )
clazz->done( cmap );
FT_FREE( cmap );
}
|
CWE-119
| 10,277 | 16,959 |
131752195973374078262222419793965084263
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_lookup_PS_in_sfnt_stream( FT_Stream stream,
FT_Long face_index,
FT_ULong* offset,
FT_ULong* length,
FT_Bool* is_sfnt_cid )
{
FT_Error error;
FT_UShort numTables;
FT_Long pstable_index;
FT_ULong tag;
int i;
*offset = 0;
*length = 0;
*is_sfnt_cid = FALSE;
/* TODO: support for sfnt-wrapped PS/CID in TTC format */
/* version check for 'typ1' (should be ignored?) */
if ( FT_READ_ULONG( tag ) )
return error;
if ( tag != TTAG_typ1 )
return FT_Err_Unknown_File_Format;
if ( FT_READ_USHORT( numTables ) )
return error;
if ( FT_STREAM_SKIP( 2 * 3 ) ) /* skip binary search header */
return error;
pstable_index = -1;
*is_sfnt_cid = FALSE;
for ( i = 0; i < numTables; i++ )
{
if ( FT_READ_ULONG( tag ) || FT_STREAM_SKIP( 4 ) ||
FT_READ_ULONG( *offset ) || FT_READ_ULONG( *length ) )
return error;
if ( tag == TTAG_CID )
{
pstable_index++;
*offset += 22;
*length -= 22;
*is_sfnt_cid = TRUE;
if ( face_index < 0 )
return FT_Err_Ok;
}
else if ( tag == TTAG_TYP1 )
{
pstable_index++;
*offset += 24;
*length -= 24;
*is_sfnt_cid = FALSE;
if ( face_index < 0 )
return FT_Err_Ok;
}
if ( face_index >= 0 && pstable_index == face_index )
return FT_Err_Ok;
}
return FT_Err_Table_Missing;
}
|
CWE-119
| 10,278 | 16,960 |
150548737700322553629145101491969458184
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_lookup_glyph_renderer( FT_GlyphSlot slot )
{
FT_Face face = slot->face;
FT_Library library = FT_FACE_LIBRARY( face );
FT_Renderer result = library->cur_renderer;
if ( !result || result->glyph_format != slot->format )
result = FT_Lookup_Renderer( library, slot->format, 0 );
return result;
}
|
CWE-119
| 10,279 | 16,961 |
163074725000500005058056972675617490320
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_module_get_service( FT_Module module,
const char* service_id )
{
FT_Pointer result = NULL;
if ( module )
{
FT_ASSERT( module->clazz && module->clazz->get_interface );
/* first, look for the service in the module
*/
if ( module->clazz->get_interface )
result = module->clazz->get_interface( module, service_id );
if ( result == NULL )
{
/* we didn't find it, look in all other modules then
*/
FT_Library library = module->library;
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
for ( ; cur < limit; cur++ )
{
if ( cur[0] != module )
{
FT_ASSERT( cur[0]->clazz );
if ( cur[0]->clazz->get_interface )
{
result = cur[0]->clazz->get_interface( cur[0], service_id );
if ( result != NULL )
break;
}
}
}
}
}
return result;
}
|
CWE-119
| 10,280 | 16,962 |
20359845309225506776521183249979845193
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_recompute_scaled_metrics( FT_Face face,
FT_Size_Metrics* metrics )
{
/* Compute root ascender, descender, test height, and max_advance */
#ifdef GRID_FIT_METRICS
metrics->ascender = FT_PIX_CEIL( FT_MulFix( face->ascender,
metrics->y_scale ) );
metrics->descender = FT_PIX_FLOOR( FT_MulFix( face->descender,
metrics->y_scale ) );
metrics->height = FT_PIX_ROUND( FT_MulFix( face->height,
metrics->y_scale ) );
metrics->max_advance = FT_PIX_ROUND( FT_MulFix( face->max_advance_width,
metrics->x_scale ) );
#else /* !GRID_FIT_METRICS */
metrics->ascender = FT_MulFix( face->ascender,
metrics->y_scale );
metrics->descender = FT_MulFix( face->descender,
metrics->y_scale );
metrics->height = FT_MulFix( face->height,
metrics->y_scale );
metrics->max_advance = FT_MulFix( face->max_advance_width,
metrics->x_scale );
#endif /* !GRID_FIT_METRICS */
}
|
CWE-119
| 10,281 | 16,963 |
82241043344103992518248656038648911118
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_remove_renderer( FT_Module module )
{
FT_Library library = module->library;
FT_Memory memory = library->memory;
FT_ListNode node;
node = FT_List_Find( &library->renderers, module );
if ( node )
{
FT_Renderer render = FT_RENDERER( module );
/* release raster object, if any */
if ( render->raster )
render->clazz->raster_class->raster_done( render->raster );
/* remove from list */
FT_List_Remove( &library->renderers, node );
FT_FREE( node );
ft_set_current_renderer( library );
}
}
|
CWE-119
| 10,282 | 16,964 |
108355168919050007790020345060470888278
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_set_current_renderer( FT_Library library )
{
FT_Renderer renderer;
renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE, 0 );
library->cur_renderer = renderer;
}
|
CWE-119
| 10,283 | 16,965 |
311101043352516069515963274887280681695
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_stub_set_char_sizes( FT_Size size,
FT_F26Dot6 width,
FT_F26Dot6 height,
FT_UInt horz_res,
FT_UInt vert_res )
{
FT_Size_RequestRec req;
FT_Driver driver = size->face->driver;
if ( driver->clazz->request_size )
{
req.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
req.width = width;
req.height = height;
if ( horz_res == 0 )
horz_res = vert_res;
if ( vert_res == 0 )
vert_res = horz_res;
if ( horz_res == 0 )
horz_res = vert_res = 72;
req.horiResolution = horz_res;
req.vertResolution = vert_res;
return driver->clazz->request_size( size, &req );
}
return 0;
}
|
CWE-119
| 10,284 | 16,966 |
13343587357202226068504140268552008723
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
ft_synthesize_vertical_metrics( FT_Glyph_Metrics* metrics,
FT_Pos advance )
{
FT_Pos height = metrics->height;
/* compensate for glyph with bbox above/below the baseline */
if ( metrics->horiBearingY < 0 )
{
if ( height < metrics->horiBearingY )
height = metrics->horiBearingY;
}
else if ( metrics->horiBearingY > 0 )
height -= metrics->horiBearingY;
/* the factor 1.2 is a heuristical value */
if ( !advance )
advance = height * 12 / 10;
metrics->vertBearingX = metrics->horiBearingX - metrics->horiAdvance / 2;
metrics->vertBearingY = ( advance - height ) / 2;
metrics->vertAdvance = advance;
}
|
CWE-119
| 10,286 | 16,967 |
332374179903688513076995426543071226335
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
load_mac_face( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Face *aface,
const FT_Open_Args *args )
{
FT_Error error;
FT_UNUSED( args );
error = IsMacBinary( library, stream, face_index, aface );
if ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format )
{
#undef FT_COMPONENT
#define FT_COMPONENT trace_raccess
FT_TRACE3(( "Try as dfont: %s ...", args->pathname ));
error = IsMacResource( library, stream, 0, face_index, aface );
FT_TRACE3(( "%s\n", error ? "failed" : "successful" ));
#undef FT_COMPONENT
#define FT_COMPONENT trace_objs
}
if ( ( FT_ERROR_BASE( error ) == FT_Err_Unknown_File_Format ||
FT_ERROR_BASE( error ) == FT_Err_Invalid_Stream_Operation ) &&
( args->flags & FT_OPEN_PATHNAME ) )
error = load_face_in_embedded_rfork( library, stream,
face_index, aface, args );
return error;
}
|
CWE-119
| 10,288 | 16,968 |
28478640478053720794825528167692450397
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
memory_stream_close( FT_Stream stream )
{
FT_Memory memory = stream->memory;
FT_FREE( stream->base );
stream->size = 0;
stream->base = 0;
stream->close = 0;
}
|
CWE-119
| 10,289 | 16,969 |
142470101635125700853981351367191897193
| null | null | null |
savannah
|
b2ea64bcc6c385a8e8318f9c759450a07df58b6d
| 0 |
open_face_PS_from_sfnt_stream( FT_Library library,
FT_Stream stream,
FT_Long face_index,
FT_Int num_params,
FT_Parameter *params,
FT_Face *aface )
{
FT_Error error;
FT_Memory memory = library->memory;
FT_ULong offset, length;
FT_Long pos;
FT_Bool is_sfnt_cid;
FT_Byte* sfnt_ps;
FT_UNUSED( num_params );
FT_UNUSED( params );
pos = FT_Stream_Pos( stream );
error = ft_lookup_PS_in_sfnt_stream( stream,
face_index,
&offset,
&length,
&is_sfnt_cid );
if ( error )
goto Exit;
if ( FT_Stream_Seek( stream, pos + offset ) )
goto Exit;
if ( FT_ALLOC( sfnt_ps, (FT_Long)length ) )
goto Exit;
error = FT_Stream_Read( stream, (FT_Byte *)sfnt_ps, length );
if ( error )
goto Exit;
error = open_face_from_buffer( library,
sfnt_ps,
length,
face_index < 0 ? face_index : 0,
is_sfnt_cid ? "cid" : "type1",
aface );
Exit:
{
FT_Error error1;
if ( error == FT_Err_Unknown_File_Format )
{
error1 = FT_Stream_Seek( stream, pos );
if ( error1 )
return error1;
}
return error;
}
}
|
CWE-119
| 10,291 | 16,970 |
109456001245190491453969600800448973722
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
FT_Message( const char* fmt,
... )
{
va_list ap;
va_start( ap, fmt );
vfprintf( stderr, fmt, ap );
va_end( ap );
}
|
CWE-189
| 10,292 | 16,971 |
49785951218404596330175137599302486266
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
FT_Outline_Decompose( const FT_Outline* outline,
const FT_Outline_Funcs* func_interface,
void* user )
{
#undef SCALED
#define SCALED( x ) ( ( (x) << shift ) - delta )
FT_Vector v_last;
FT_Vector v_control;
FT_Vector v_start;
FT_Vector* point;
FT_Vector* limit;
char* tags;
int error;
int n; /* index of contour in outline */
int first; /* index of first point in contour */
char tag; /* current point's state */
int shift;
TPos delta;
if ( !outline || !func_interface )
return ErrRaster_Invalid_Argument;
shift = func_interface->shift;
delta = func_interface->delta;
first = 0;
for ( n = 0; n < outline->n_contours; n++ )
{
int last; /* index of last point in contour */
FT_TRACE5(( "FT_Outline_Decompose: Outline %d\n", n ));
last = outline->contours[n];
if ( last < 0 )
goto Invalid_Outline;
limit = outline->points + last;
v_start = outline->points[first];
v_start.x = SCALED( v_start.x );
v_start.y = SCALED( v_start.y );
v_last = outline->points[last];
v_last.x = SCALED( v_last.x );
v_last.y = SCALED( v_last.y );
v_control = v_start;
point = outline->points + first;
tags = outline->tags + first;
tag = FT_CURVE_TAG( tags[0] );
/* A contour cannot start with a cubic control point! */
if ( tag == FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
/* check first point to determine origin */
if ( tag == FT_CURVE_TAG_CONIC )
{
/* first point is conic control. Yes, this happens. */
if ( FT_CURVE_TAG( outline->tags[last] ) == FT_CURVE_TAG_ON )
{
/* start at last point if it is on the curve */
v_start = v_last;
limit--;
}
else
{
/* if both first and last points are conic, */
/* start at their middle and record its position */
/* for closure */
v_start.x = ( v_start.x + v_last.x ) / 2;
v_start.y = ( v_start.y + v_last.y ) / 2;
v_last = v_start;
}
point--;
tags--;
}
FT_TRACE5(( " move to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
error = func_interface->move_to( &v_start, user );
if ( error )
goto Exit;
while ( point < limit )
{
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
switch ( tag )
{
case FT_CURVE_TAG_ON: /* emit a single line_to */
{
FT_Vector vec;
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
FT_TRACE5(( " line to (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0 ));
error = func_interface->line_to( &vec, user );
if ( error )
goto Exit;
continue;
}
case FT_CURVE_TAG_CONIC: /* consume conic arcs */
v_control.x = SCALED( point->x );
v_control.y = SCALED( point->y );
Do_Conic:
if ( point < limit )
{
FT_Vector vec;
FT_Vector v_middle;
point++;
tags++;
tag = FT_CURVE_TAG( tags[0] );
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
if ( tag == FT_CURVE_TAG_ON )
{
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
error = func_interface->conic_to( &v_control, &vec, user );
if ( error )
goto Exit;
continue;
}
if ( tag != FT_CURVE_TAG_CONIC )
goto Invalid_Outline;
v_middle.x = ( v_control.x + vec.x ) / 2;
v_middle.y = ( v_control.y + vec.y ) / 2;
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
v_middle.x / 64.0, v_middle.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
error = func_interface->conic_to( &v_control, &v_middle, user );
if ( error )
goto Exit;
v_control = vec;
goto Do_Conic;
}
FT_TRACE5(( " conic to (%.2f, %.2f)"
" with control (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0,
v_control.x / 64.0, v_control.y / 64.0 ));
error = func_interface->conic_to( &v_control, &v_start, user );
goto Close;
default: /* FT_CURVE_TAG_CUBIC */
{
FT_Vector vec1, vec2;
if ( point + 1 > limit ||
FT_CURVE_TAG( tags[1] ) != FT_CURVE_TAG_CUBIC )
goto Invalid_Outline;
point += 2;
tags += 2;
vec1.x = SCALED( point[-2].x );
vec1.y = SCALED( point[-2].y );
vec2.x = SCALED( point[-1].x );
vec2.y = SCALED( point[-1].y );
if ( point <= limit )
{
FT_Vector vec;
vec.x = SCALED( point->x );
vec.y = SCALED( point->y );
FT_TRACE5(( " cubic to (%.2f, %.2f)"
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
vec.x / 64.0, vec.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
if ( error )
goto Exit;
continue;
}
FT_TRACE5(( " cubic to (%.2f, %.2f)"
" with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0,
vec1.x / 64.0, vec1.y / 64.0,
vec2.x / 64.0, vec2.y / 64.0 ));
error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
goto Close;
}
}
}
/* close the contour with a line segment */
FT_TRACE5(( " line to (%.2f, %.2f)\n",
v_start.x / 64.0, v_start.y / 64.0 ));
error = func_interface->line_to( &v_start, user );
Close:
if ( error )
goto Exit;
first = last + 1;
}
FT_TRACE5(( "FT_Outline_Decompose: Done\n", n ));
return 0;
Exit:
FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error ));
return error;
Invalid_Outline:
return ErrRaster_Invalid_Outline;
}
|
CWE-189
| 10,293 | 16,972 |
102633661073278132991724404071985298572
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_conic_to( const FT_Vector* control,
const FT_Vector* to,
PWorker worker )
{
gray_render_conic( RAS_VAR_ control, to );
return 0;
}
|
CWE-189
| 10,295 | 16,973 |
75287315014081745368268519480503524474
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_convert_glyph( RAS_ARG )
{
TBand bands[40];
TBand* volatile band;
int volatile n, num_bands;
TPos volatile min, max, max_y;
FT_BBox* clip;
/* Set up state in the raster object */
gray_compute_cbox( RAS_VAR );
/* clip to target bitmap, exit if nothing to do */
clip = &ras.clip_box;
if ( ras.max_ex <= clip->xMin || ras.min_ex >= clip->xMax ||
ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax )
return 0;
if ( ras.min_ex < clip->xMin ) ras.min_ex = clip->xMin;
if ( ras.min_ey < clip->yMin ) ras.min_ey = clip->yMin;
if ( ras.max_ex > clip->xMax ) ras.max_ex = clip->xMax;
if ( ras.max_ey > clip->yMax ) ras.max_ey = clip->yMax;
ras.count_ex = ras.max_ex - ras.min_ex;
ras.count_ey = ras.max_ey - ras.min_ey;
/* simple heuristic used to speed up the bezier decomposition -- see */
/* the code in gray_render_conic() and gray_render_cubic() for more */
/* details */
ras.conic_level = 32;
ras.cubic_level = 16;
{
int level = 0;
if ( ras.count_ex > 24 || ras.count_ey > 24 )
level++;
if ( ras.count_ex > 120 || ras.count_ey > 120 )
level++;
ras.conic_level <<= level;
ras.cubic_level <<= level;
}
/* set up vertical bands */
num_bands = (int)( ( ras.max_ey - ras.min_ey ) / ras.band_size );
if ( num_bands == 0 )
num_bands = 1;
if ( num_bands >= 39 )
num_bands = 39;
ras.band_shoot = 0;
min = ras.min_ey;
max_y = ras.max_ey;
for ( n = 0; n < num_bands; n++, min = max )
{
max = min + ras.band_size;
if ( n == num_bands - 1 || max > max_y )
max = max_y;
bands[0].min = min;
bands[0].max = max;
band = bands;
while ( band >= bands )
{
TPos bottom, top, middle;
int error;
{
PCell cells_max;
int yindex;
long cell_start, cell_end, cell_mod;
ras.ycells = (PCell*)ras.buffer;
ras.ycount = band->max - band->min;
cell_start = sizeof ( PCell ) * ras.ycount;
cell_mod = cell_start % sizeof ( TCell );
if ( cell_mod > 0 )
cell_start += sizeof ( TCell ) - cell_mod;
cell_end = ras.buffer_size;
cell_end -= cell_end % sizeof( TCell );
cells_max = (PCell)( (char*)ras.buffer + cell_end );
ras.cells = (PCell)( (char*)ras.buffer + cell_start );
if ( ras.cells >= cells_max )
goto ReduceBands;
ras.max_cells = cells_max - ras.cells;
if ( ras.max_cells < 2 )
goto ReduceBands;
for ( yindex = 0; yindex < ras.ycount; yindex++ )
ras.ycells[yindex] = NULL;
}
ras.num_cells = 0;
ras.invalid = 1;
ras.min_ey = band->min;
ras.max_ey = band->max;
ras.count_ey = band->max - band->min;
error = gray_convert_glyph_inner( RAS_VAR );
if ( !error )
{
gray_sweep( RAS_VAR_ &ras.target );
band--;
continue;
}
else if ( error != ErrRaster_Memory_Overflow )
return 1;
ReduceBands:
/* render pool overflow; we will reduce the render band by half */
bottom = band->min;
top = band->max;
middle = bottom + ( ( top - bottom ) >> 1 );
/* This is too complex for a single scanline; there must */
/* be some problems. */
if ( middle == bottom )
{
#ifdef FT_DEBUG_LEVEL_TRACE
FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
#endif
return 1;
}
if ( bottom-top >= ras.band_size )
ras.band_shoot++;
band[1].min = bottom;
band[1].max = middle;
band[0].min = middle;
band[0].max = top;
band++;
}
}
if ( ras.band_shoot > 8 && ras.band_size > 16 )
ras.band_size = ras.band_size / 2;
return 0;
}
|
CWE-189
| 10,296 | 16,974 |
41753048001871192252808781963339633289
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_convert_glyph_inner( RAS_ARG )
{
volatile int error = 0;
#ifdef FT_CONFIG_OPTION_PIC
FT_Outline_Funcs func_interface;
Init_Class_func_interface(&func_interface);
#endif
if ( ft_setjmp( ras.jump_buffer ) == 0 )
{
error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
gray_record_cell( RAS_VAR );
}
else
error = ErrRaster_Memory_Overflow;
return error;
}
|
CWE-189
| 10,297 | 16,975 |
122862298085666985932955848352971168782
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_cubic_to( const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to,
PWorker worker )
{
gray_render_cubic( RAS_VAR_ control1, control2, to );
return 0;
}
|
CWE-189
| 10,298 | 16,976 |
94289859453881552837066022955784834435
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_dump_cells( RAS_ARG )
{
int yindex;
for ( yindex = 0; yindex < ras.ycount; yindex++ )
{
PCell cell;
printf( "%3d:", yindex );
for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next )
printf( " (%3ld, c:%4ld, a:%6d)", cell->x, cell->cover, cell->area );
printf( "\n" );
}
}
|
CWE-189
| 10,299 | 16,977 |
2871164861872853643385812045628690090
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_find_cell( RAS_ARG )
{
PCell *pcell, cell;
TPos x = ras.ex;
if ( x > ras.count_ex )
x = ras.count_ex;
pcell = &ras.ycells[ras.ey];
for (;;)
{
cell = *pcell;
if ( cell == NULL || cell->x > x )
break;
if ( cell->x == x )
goto Exit;
pcell = &cell->next;
}
if ( ras.num_cells >= ras.max_cells )
ft_longjmp( ras.jump_buffer, 1 );
cell = ras.cells + ras.num_cells++;
cell->x = x;
cell->area = 0;
cell->cover = 0;
cell->next = *pcell;
*pcell = cell;
Exit:
return cell;
}
|
CWE-189
| 10,300 | 16,978 |
145420740608905007674136077386583036002
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_hline( RAS_ARG_ TCoord x,
TCoord y,
TPos area,
TCoord acount )
{
FT_Span* span;
int count;
int coverage;
/* compute the coverage line's coverage, depending on the */
/* outline fill rule */
/* */
/* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */
/* */
coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) );
/* use range 0..256 */
if ( coverage < 0 )
coverage = -coverage;
if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL )
{
coverage &= 511;
if ( coverage > 256 )
coverage = 512 - coverage;
else if ( coverage == 256 )
coverage = 255;
}
else
{
/* normal non-zero winding rule */
if ( coverage >= 256 )
coverage = 255;
}
y += (TCoord)ras.min_ey;
x += (TCoord)ras.min_ex;
/* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */
if ( x >= 32767 )
x = 32767;
/* FT_Span.y is an integer, so limit our coordinates appropriately */
if ( y >= FT_INT_MAX )
y = FT_INT_MAX;
if ( coverage )
{
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count - 1;
if ( count > 0 &&
ras.span_y == y &&
(int)span->x + span->len == (int)x &&
span->coverage == coverage )
{
span->len = (unsigned short)( span->len + acount );
return;
}
if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS )
{
if ( ras.render_span && count > 0 )
ras.render_span( ras.span_y, count, ras.gray_spans,
ras.render_span_data );
#ifdef FT_DEBUG_LEVEL_TRACE
if ( count > 0 )
{
int n;
FT_TRACE7(( "y = %3d ", ras.span_y ));
span = ras.gray_spans;
for ( n = 0; n < count; n++, span++ )
FT_TRACE7(( "[%d..%d]:%02x ",
span->x, span->x + span->len - 1, span->coverage ));
FT_TRACE7(( "\n" ));
}
#endif /* FT_DEBUG_LEVEL_TRACE */
ras.num_gray_spans = 0;
ras.span_y = (int)y;
count = 0;
span = ras.gray_spans;
}
else
span++;
/* add a gray span to the current list */
span->x = (short)x;
span->len = (unsigned short)acount;
span->coverage = (unsigned char)coverage;
ras.num_gray_spans++;
}
}
|
CWE-189
| 10,301 | 16,979 |
35563689171399360991125936405859128651
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_init_cells( RAS_ARG_ void* buffer,
long byte_size )
{
ras.buffer = buffer;
ras.buffer_size = byte_size;
ras.ycells = (PCell*) buffer;
ras.cells = NULL;
ras.max_cells = 0;
ras.num_cells = 0;
ras.area = 0;
ras.cover = 0;
ras.invalid = 1;
}
|
CWE-189
| 10,302 | 16,980 |
239273514965116296731755380171947097275
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_line_to( const FT_Vector* to,
PWorker worker )
{
gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) );
return 0;
}
|
CWE-189
| 10,303 | 16,981 |
119623350900108215604486131646369306866
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_move_to( const FT_Vector* to,
PWorker worker )
{
TPos x, y;
/* record current cell, if any */
gray_record_cell( RAS_VAR );
/* start to a new position */
x = UPSCALE( to->x );
y = UPSCALE( to->y );
gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) );
worker->x = x;
worker->y = y;
return 0;
}
|
CWE-189
| 10,304 | 16,982 |
173947327146547521529798266726454966671
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_raster_new( void* memory,
FT_Raster* araster )
{
static TRaster the_raster;
FT_UNUSED( memory );
*araster = (FT_Raster)&the_raster;
FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) );
return 0;
}
|
CWE-189
| 10,307 | 16,983 |
297645738127884613705239909102328593501
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_raster_new( FT_Memory memory,
FT_Raster* araster )
{
FT_Error error;
PRaster raster;
*araster = 0;
if ( !FT_ALLOC( raster, sizeof ( TRaster ) ) )
{
raster->memory = memory;
*araster = (FT_Raster)raster;
}
return error;
}
|
CWE-189
| 10,308 | 16,984 |
299800754575837094874810519013208353393
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_raster_render( PRaster raster,
const FT_Raster_Params* params )
{
const FT_Outline* outline = (const FT_Outline*)params->source;
const FT_Bitmap* target_map = params->target;
PWorker worker;
if ( !raster || !raster->buffer || !raster->buffer_size )
return ErrRaster_Invalid_Argument;
if ( !outline )
return ErrRaster_Invalid_Outline;
/* return immediately if the outline is empty */
if ( outline->n_points == 0 || outline->n_contours <= 0 )
return 0;
if ( !outline->contours || !outline->points )
return ErrRaster_Invalid_Outline;
if ( outline->n_points !=
outline->contours[outline->n_contours - 1] + 1 )
return ErrRaster_Invalid_Outline;
worker = raster->worker;
/* if direct mode is not set, we must have a target bitmap */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
if ( !target_map )
return ErrRaster_Invalid_Argument;
/* nothing to do */
if ( !target_map->width || !target_map->rows )
return 0;
if ( !target_map->buffer )
return ErrRaster_Invalid_Argument;
}
/* this version does not support monochrome rendering */
if ( !( params->flags & FT_RASTER_FLAG_AA ) )
return ErrRaster_Invalid_Mode;
/* compute clipping box */
if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) )
{
/* compute clip box from target pixmap */
ras.clip_box.xMin = 0;
ras.clip_box.yMin = 0;
ras.clip_box.xMax = target_map->width;
ras.clip_box.yMax = target_map->rows;
}
else if ( params->flags & FT_RASTER_FLAG_CLIP )
ras.clip_box = params->clip_box;
else
{
ras.clip_box.xMin = -32768L;
ras.clip_box.yMin = -32768L;
ras.clip_box.xMax = 32767L;
ras.clip_box.yMax = 32767L;
}
gray_init_cells( RAS_VAR_ raster->buffer, raster->buffer_size );
ras.outline = *outline;
ras.num_cells = 0;
ras.invalid = 1;
ras.band_size = raster->band_size;
ras.num_gray_spans = 0;
if ( params->flags & FT_RASTER_FLAG_DIRECT )
{
ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
ras.render_span_data = params->user;
}
else
{
ras.target = *target_map;
ras.render_span = (FT_Raster_Span_Func)gray_render_span;
ras.render_span_data = &ras;
}
return gray_convert_glyph( RAS_VAR );
}
|
CWE-189
| 10,309 | 16,985 |
118829098009149336015808763673771853882
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_raster_reset( FT_Raster raster,
char* pool_base,
long pool_size )
{
PRaster rast = (PRaster)raster;
if ( raster )
{
if ( pool_base && pool_size >= (long)sizeof ( TWorker ) + 2048 )
{
PWorker worker = (PWorker)pool_base;
rast->worker = worker;
rast->buffer = pool_base +
( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) &
~( sizeof ( TCell ) - 1 ) );
rast->buffer_size = (long)( ( pool_base + pool_size ) -
(char*)rast->buffer ) &
~( sizeof ( TCell ) - 1 );
rast->band_size = (int)( rast->buffer_size /
( sizeof ( TCell ) * 8 ) );
}
else
{
rast->buffer = NULL;
rast->buffer_size = 0;
rast->worker = NULL;
}
}
}
|
CWE-189
| 10,310 | 16,986 |
166677168093679875391745421404970702000
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_record_cell( RAS_ARG )
{
if ( !ras.invalid && ( ras.area | ras.cover ) )
{
PCell cell = gray_find_cell( RAS_VAR );
cell->area += ras.area;
cell->cover += ras.cover;
}
}
|
CWE-189
| 10,311 | 16,987 |
20576697853990023977520665896403871137
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_render_conic( RAS_ARG_ const FT_Vector* control,
const FT_Vector* to )
{
TPos dx, dy;
int top, level;
int* levels;
FT_Vector* arc;
dx = DOWNSCALE( ras.x ) + to->x - ( control->x << 1 );
if ( dx < 0 )
dx = -dx;
dy = DOWNSCALE( ras.y ) + to->y - ( control->y << 1 );
if ( dy < 0 )
dy = -dy;
if ( dx < dy )
dx = dy;
level = 1;
dx = dx / ras.conic_level;
while ( dx > 0 )
{
dx >>= 2;
level++;
}
/* a shortcut to speed things up */
if ( level <= 1 )
{
/* we compute the mid-point directly in order to avoid */
/* calling gray_split_conic() */
TPos to_x, to_y, mid_x, mid_y;
to_x = UPSCALE( to->x );
to_y = UPSCALE( to->y );
mid_x = ( ras.x + to_x + 2 * UPSCALE( control->x ) ) / 4;
mid_y = ( ras.y + to_y + 2 * UPSCALE( control->y ) ) / 4;
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
return;
}
arc = ras.bez_stack;
levels = ras.lev_stack;
top = 0;
levels[0] = level;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control->x );
arc[1].y = UPSCALE( control->y );
arc[2].x = ras.x;
arc[2].y = ras.y;
while ( top >= 0 )
{
level = levels[top];
if ( level > 1 )
{
/* check that the arc crosses the current band */
TPos min, max, y;
min = max = arc[0].y;
y = arc[1].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[2].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey )
goto Draw;
gray_split_conic( arc );
arc += 2;
top++;
levels[top] = levels[top - 1] = level - 1;
continue;
}
Draw:
{
TPos to_x, to_y, mid_x, mid_y;
to_x = arc[0].x;
to_y = arc[0].y;
mid_x = ( ras.x + to_x + 2 * arc[1].x ) / 4;
mid_y = ( ras.y + to_y + 2 * arc[1].y ) / 4;
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
top--;
arc -= 2;
}
}
return;
}
|
CWE-189
| 10,312 | 16,988 |
83266872402215819531910110159978342588
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_render_cubic( RAS_ARG_ const FT_Vector* control1,
const FT_Vector* control2,
const FT_Vector* to )
{
int top, level;
int* levels;
FT_Vector* arc;
int mid_x = ( DOWNSCALE( ras.x ) + to->x +
3 * (control1->x + control2->x ) ) / 8;
int mid_y = ( DOWNSCALE( ras.y ) + to->y +
3 * (control1->y + control2->y ) ) / 8;
TPos dx = DOWNSCALE( ras.x ) + to->x - ( mid_x << 1 );
TPos dy = DOWNSCALE( ras.y ) + to->y - ( mid_y << 1 );
if ( dx < 0 )
dx = -dx;
if ( dy < 0 )
dy = -dy;
if ( dx < dy )
dx = dy;
level = 1;
dx /= ras.cubic_level;
while ( dx > 0 )
{
dx >>= 2;
level++;
}
if ( level <= 1 )
{
TPos to_x, to_y;
to_x = UPSCALE( to->x );
to_y = UPSCALE( to->y );
/* Recalculation of midpoint is needed only if */
/* UPSCALE and DOWNSCALE have any effect. */
#if ( PIXEL_BITS != 6 )
mid_x = ( ras.x + to_x +
3 * UPSCALE( control1->x + control2->x ) ) / 8;
mid_y = ( ras.y + to_y +
3 * UPSCALE( control1->y + control2->y ) ) / 8;
#endif
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
return;
}
arc = ras.bez_stack;
arc[0].x = UPSCALE( to->x );
arc[0].y = UPSCALE( to->y );
arc[1].x = UPSCALE( control2->x );
arc[1].y = UPSCALE( control2->y );
arc[2].x = UPSCALE( control1->x );
arc[2].y = UPSCALE( control1->y );
arc[3].x = ras.x;
arc[3].y = ras.y;
levels = ras.lev_stack;
top = 0;
levels[0] = level;
while ( top >= 0 )
{
level = levels[top];
if ( level > 1 )
{
/* check that the arc crosses the current band */
TPos min, max, y;
min = max = arc[0].y;
y = arc[1].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[2].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
y = arc[3].y;
if ( y < min ) min = y;
if ( y > max ) max = y;
if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < 0 )
goto Draw;
gray_split_cubic( arc );
arc += 3;
top ++;
levels[top] = levels[top - 1] = level - 1;
continue;
}
Draw:
{
TPos to_x, to_y;
to_x = arc[0].x;
to_y = arc[0].y;
mid_x = ( ras.x + to_x + 3 * ( arc[1].x + arc[2].x ) ) / 8;
mid_y = ( ras.y + to_y + 3 * ( arc[1].y + arc[2].y ) ) / 8;
gray_render_line( RAS_VAR_ mid_x, mid_y );
gray_render_line( RAS_VAR_ to_x, to_y );
top --;
arc -= 3;
}
}
return;
}
|
CWE-189
| 10,313 | 16,989 |
66123956180331084375217651873935018127
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_render_line( RAS_ARG_ TPos to_x,
TPos to_y )
{
TCoord ey1, ey2, fy1, fy2, mod;
TPos dx, dy, x, x2;
long p, first;
int delta, rem, lift, incr;
ey1 = TRUNC( ras.last_ey );
ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
fy1 = (TCoord)( ras.y - ras.last_ey );
fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) );
dx = to_x - ras.x;
dy = to_y - ras.y;
/* XXX: we should do something about the trivial case where dx == 0, */
/* as it happens very often! */
/* perform vertical clipping */
{
TCoord min, max;
min = ey1;
max = ey2;
if ( ey1 > ey2 )
{
min = ey2;
max = ey1;
}
if ( min >= ras.max_ey || max < ras.min_ey )
goto End;
}
/* everything is on a single scanline */
if ( ey1 == ey2 )
{
gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, to_x, fy2 );
goto End;
}
/* vertical line - avoid calling gray_render_scanline */
incr = 1;
if ( dx == 0 )
{
TCoord ex = TRUNC( ras.x );
TCoord two_fx = (TCoord)( ( ras.x - SUBPIXELS( ex ) ) << 1 );
TArea area;
first = ONE_PIXEL;
if ( dy < 0 )
{
first = 0;
incr = -1;
}
delta = (int)( first - fy1 );
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
ey1 += incr;
gray_set_cell( RAS_VAR_ ex, ey1 );
delta = (int)( first + first - ONE_PIXEL );
area = (TArea)two_fx * delta;
while ( ey1 != ey2 )
{
ras.area += area;
ras.cover += delta;
ey1 += incr;
gray_set_cell( RAS_VAR_ ex, ey1 );
}
delta = (int)( fy2 - ONE_PIXEL + first );
ras.area += (TArea)two_fx * delta;
ras.cover += delta;
goto End;
}
/* ok, we have to render several scanlines */
p = ( ONE_PIXEL - fy1 ) * dx;
first = ONE_PIXEL;
incr = 1;
if ( dy < 0 )
{
p = fy1 * dx;
first = 0;
incr = -1;
dy = -dy;
}
delta = (int)( p / dy );
mod = (int)( p % dy );
if ( mod < 0 )
{
delta--;
mod += (TCoord)dy;
}
x = ras.x + delta;
gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first );
ey1 += incr;
gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
if ( ey1 != ey2 )
{
p = ONE_PIXEL * dx;
lift = (int)( p / dy );
rem = (int)( p % dy );
if ( rem < 0 )
{
lift--;
rem += (int)dy;
}
mod -= (int)dy;
while ( ey1 != ey2 )
{
delta = lift;
mod += rem;
if ( mod >= 0 )
{
mod -= (int)dy;
delta++;
}
x2 = x + delta;
gray_render_scanline( RAS_VAR_ ey1, x,
(TCoord)( ONE_PIXEL - first ), x2,
(TCoord)first );
x = x2;
ey1 += incr;
gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
}
}
gray_render_scanline( RAS_VAR_ ey1, x,
(TCoord)( ONE_PIXEL - first ), to_x,
fy2 );
End:
ras.x = to_x;
ras.y = to_y;
ras.last_ey = SUBPIXELS( ey2 );
}
|
CWE-189
| 10,314 | 16,990 |
184348291460218322158022098904660983245
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_render_scanline( RAS_ARG_ TCoord ey,
TPos x1,
TCoord y1,
TPos x2,
TCoord y2 )
{
TCoord ex1, ex2, fx1, fx2, delta, mod, lift, rem;
long p, first, dx;
int incr;
dx = x2 - x1;
ex1 = TRUNC( x1 );
ex2 = TRUNC( x2 );
fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) );
fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) );
/* trivial case. Happens often */
if ( y1 == y2 )
{
gray_set_cell( RAS_VAR_ ex2, ey );
return;
}
/* everything is located in a single cell. That is easy! */
/* */
if ( ex1 == ex2 )
{
delta = y2 - y1;
ras.area += (TArea)(( fx1 + fx2 ) * delta);
ras.cover += delta;
return;
}
/* ok, we'll have to render a run of adjacent cells on the same */
/* scanline... */
/* */
p = ( ONE_PIXEL - fx1 ) * ( y2 - y1 );
first = ONE_PIXEL;
incr = 1;
if ( dx < 0 )
{
p = fx1 * ( y2 - y1 );
first = 0;
incr = -1;
dx = -dx;
}
delta = (TCoord)( p / dx );
mod = (TCoord)( p % dx );
if ( mod < 0 )
{
delta--;
mod += (TCoord)dx;
}
ras.area += (TArea)(( fx1 + first ) * delta);
ras.cover += delta;
ex1 += incr;
gray_set_cell( RAS_VAR_ ex1, ey );
y1 += delta;
if ( ex1 != ex2 )
{
p = ONE_PIXEL * ( y2 - y1 + delta );
lift = (TCoord)( p / dx );
rem = (TCoord)( p % dx );
if ( rem < 0 )
{
lift--;
rem += (TCoord)dx;
}
mod -= (int)dx;
while ( ex1 != ex2 )
{
delta = lift;
mod += rem;
if ( mod >= 0 )
{
mod -= (TCoord)dx;
delta++;
}
ras.area += (TArea)(ONE_PIXEL * delta);
ras.cover += delta;
y1 += delta;
ex1 += incr;
gray_set_cell( RAS_VAR_ ex1, ey );
}
}
delta = y2 - y1;
ras.area += (TArea)(( fx2 + ONE_PIXEL - first ) * delta);
ras.cover += delta;
}
|
CWE-189
| 10,315 | 16,991 |
172658267333934752168815133736231024542
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_set_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
/* Move the cell pointer to a new position. We set the `invalid' */
/* flag to indicate that the cell isn't part of those we're interested */
/* in during the render phase. This means that: */
/* */
/* . the new vertical position must be within min_ey..max_ey-1. */
/* . the new horizontal position must be strictly less than max_ex */
/* */
/* Note that if a cell is to the left of the clipping region, it is */
/* actually set to the (min_ex-1) horizontal position. */
/* All cells that are on the left of the clipping region go to the */
/* min_ex - 1 horizontal position. */
ey -= ras.min_ey;
if ( ex > ras.max_ex )
ex = ras.max_ex;
ex -= ras.min_ex;
if ( ex < 0 )
ex = -1;
/* are we moving to a different cell ? */
if ( ex != ras.ex || ey != ras.ey )
{
/* record the current one if it is valid */
if ( !ras.invalid )
gray_record_cell( RAS_VAR );
ras.area = 0;
ras.cover = 0;
}
ras.ex = ex;
ras.ey = ey;
ras.invalid = ( (unsigned)ey >= (unsigned)ras.count_ey ||
ex >= ras.count_ex );
}
|
CWE-189
| 10,316 | 16,992 |
104821551084954581656918652014758981521
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_start_cell( RAS_ARG_ TCoord ex,
TCoord ey )
{
if ( ex > ras.max_ex )
ex = (TCoord)( ras.max_ex );
if ( ex < ras.min_ex )
ex = (TCoord)( ras.min_ex - 1 );
ras.area = 0;
ras.cover = 0;
ras.ex = ex - ras.min_ex;
ras.ey = ey - ras.min_ey;
ras.last_ey = SUBPIXELS( ey );
ras.invalid = 0;
gray_set_cell( RAS_VAR_ ex, ey );
}
|
CWE-189
| 10,319 | 16,993 |
327038470218758006992946692927471026875
| null | null | null |
savannah
|
6305b869d86ff415a33576df6d43729673c66eee
| 0 |
gray_sweep( RAS_ARG_ const FT_Bitmap* target )
{
int yindex;
FT_UNUSED( target );
if ( ras.num_cells == 0 )
return;
ras.num_gray_spans = 0;
FT_TRACE7(( "gray_sweep: start\n" ));
for ( yindex = 0; yindex < ras.ycount; yindex++ )
{
PCell cell = ras.ycells[yindex];
TCoord cover = 0;
TCoord x = 0;
for ( ; cell != NULL; cell = cell->next )
{
TPos area;
if ( cell->x > x && cover != 0 )
gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ),
cell->x - x );
cover += cell->cover;
area = cover * ( ONE_PIXEL * 2 ) - cell->area;
if ( area != 0 && cell->x >= 0 )
gray_hline( RAS_VAR_ cell->x, yindex, area, 1 );
x = cell->x + 1;
}
if ( cover != 0 )
gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ),
ras.count_ex - x );
}
if ( ras.render_span && ras.num_gray_spans > 0 )
ras.render_span( ras.span_y, ras.num_gray_spans,
ras.gray_spans, ras.render_span_data );
FT_TRACE7(( "gray_sweep: end\n" ));
}
|
CWE-189
| 10,320 | 16,994 |
161396047997321517419117864778537729541
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
ps_hints_apply( PS_Hints ps_hints,
FT_Outline* outline,
PSH_Globals globals,
FT_Render_Mode hint_mode )
{
PSH_GlyphRec glyphrec;
PSH_Glyph glyph = &glyphrec;
FT_Error error;
#ifdef DEBUG_HINTER
FT_Memory memory;
#endif
FT_Int dimension;
/* something to do? */
if ( outline->n_points == 0 || outline->n_contours == 0 )
return PSH_Err_Ok;
#ifdef DEBUG_HINTER
memory = globals->memory;
if ( ps_debug_glyph )
{
psh_glyph_done( ps_debug_glyph );
FT_FREE( ps_debug_glyph );
}
if ( FT_NEW( glyph ) )
return error;
ps_debug_glyph = glyph;
#endif /* DEBUG_HINTER */
error = psh_glyph_init( glyph, outline, ps_hints, globals );
if ( error )
goto Exit;
/* try to optimize the y_scale so that the top of non-capital letters
* is aligned on a pixel boundary whenever possible
*/
{
PSH_Dimension dim_x = &glyph->globals->dimension[0];
PSH_Dimension dim_y = &glyph->globals->dimension[1];
FT_Fixed x_scale = dim_x->scale_mult;
FT_Fixed y_scale = dim_y->scale_mult;
FT_Fixed old_x_scale = x_scale;
FT_Fixed old_y_scale = y_scale;
FT_Fixed scaled;
FT_Fixed fitted;
FT_Bool rescale = FALSE;
scaled = FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale );
fitted = FT_PIX_ROUND( scaled );
if ( fitted != 0 && scaled != fitted )
{
rescale = TRUE;
y_scale = FT_MulDiv( y_scale, fitted, scaled );
if ( fitted < scaled )
x_scale -= x_scale / 50;
psh_globals_set_scale( glyph->globals, x_scale, y_scale, 0, 0 );
}
glyph->do_horz_hints = 1;
glyph->do_vert_hints = 1;
glyph->do_horz_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD );
glyph->do_vert_snapping = FT_BOOL( hint_mode == FT_RENDER_MODE_MONO ||
hint_mode == FT_RENDER_MODE_LCD_V );
glyph->do_stem_adjust = FT_BOOL( hint_mode != FT_RENDER_MODE_LIGHT );
for ( dimension = 0; dimension < 2; dimension++ )
{
/* load outline coordinates into glyph */
psh_glyph_load_points( glyph, dimension );
/* compute local extrema */
psh_glyph_compute_extrema( glyph );
/* compute aligned stem/hints positions */
psh_hint_table_align_hints( &glyph->hint_tables[dimension],
glyph->globals,
dimension,
glyph );
/* find strong points, align them, then interpolate others */
psh_glyph_find_strong_points( glyph, dimension );
if ( dimension == 1 )
psh_glyph_find_blue_points( &globals->blues, glyph );
psh_glyph_interpolate_strong_points( glyph, dimension );
psh_glyph_interpolate_normal_points( glyph, dimension );
psh_glyph_interpolate_other_points( glyph, dimension );
/* save hinted coordinates back to outline */
psh_glyph_save_points( glyph, dimension );
if ( rescale )
psh_globals_set_scale( glyph->globals,
old_x_scale, old_y_scale, 0, 0 );
}
}
Exit:
#ifndef DEBUG_HINTER
psh_glyph_done( glyph );
#endif
return error;
}
|
CWE-399
| 10,321 | 16,995 |
166302436009324698555250820676647669393
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
ps_simple_scale( PSH_Hint_Table table,
FT_Fixed scale,
FT_Fixed delta,
FT_Int dimension )
{
PSH_Hint hint;
FT_UInt count;
for ( count = 0; count < table->max_hints; count++ )
{
hint = table->hints + count;
hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
hint->cur_len = FT_MulFix( hint->org_len, scale );
if ( ps_debug_hint_func )
ps_debug_hint_func( hint, dimension );
}
}
|
CWE-399
| 10,322 | 16,996 |
286109088810605453413718322403131056173
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_compute_dir( FT_Pos dx,
FT_Pos dy )
{
FT_Pos ax, ay;
int result = PSH_DIR_NONE;
ax = ( dx >= 0 ) ? dx : -dx;
ay = ( dy >= 0 ) ? dy : -dy;
if ( ay * 12 < ax )
{
/* |dy| <<< |dx| means a near-horizontal segment */
result = ( dx >= 0 ) ? PSH_DIR_RIGHT : PSH_DIR_LEFT;
}
else if ( ax * 12 < ay )
{
/* |dx| <<< |dy| means a near-vertical segment */
result = ( dy >= 0 ) ? PSH_DIR_UP : PSH_DIR_DOWN;
}
return result;
}
|
CWE-399
| 10,323 | 16,997 |
257212498149541608476710470955703443756
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_corner_is_flat( FT_Pos x_in,
FT_Pos y_in,
FT_Pos x_out,
FT_Pos y_out )
{
FT_Pos ax = x_in;
FT_Pos ay = y_in;
FT_Pos d_in, d_out, d_corner;
if ( ax < 0 )
ax = -ax;
if ( ay < 0 )
ay = -ay;
d_in = ax + ay;
ax = x_out;
if ( ax < 0 )
ax = -ax;
ay = y_out;
if ( ay < 0 )
ay = -ay;
d_out = ax + ay;
ax = x_out + x_in;
if ( ax < 0 )
ax = -ax;
ay = y_out + y_in;
if ( ay < 0 )
ay = -ay;
d_corner = ax + ay;
return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
}
|
CWE-399
| 10,324 | 16,998 |
151549954976976335902613331595334716977
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_corner_orientation( FT_Pos in_x,
FT_Pos in_y,
FT_Pos out_x,
FT_Pos out_y )
{
FT_Int result;
/* deal with the trivial cases quickly */
if ( in_y == 0 )
{
if ( in_x >= 0 )
result = out_y;
else
result = -out_y;
}
else if ( in_x == 0 )
{
if ( in_y >= 0 )
result = -out_x;
else
result = out_x;
}
else if ( out_y == 0 )
{
if ( out_x >= 0 )
result = in_y;
else
result = -in_y;
}
else if ( out_x == 0 )
{
if ( out_y >= 0 )
result = -in_x;
else
result = in_x;
}
else /* general case */
{
long long delta = (long long)in_x * out_y - (long long)in_y * out_x;
if ( delta == 0 )
result = 0;
else
result = 1 - 2 * ( delta < 0 );
}
return result;
}
|
CWE-399
| 10,325 | 16,999 |
45681548466172354562636218998490594352
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_dimension_quantize_len( PSH_Dimension dim,
FT_Pos len,
FT_Bool do_snapping )
{
if ( len <= 64 )
len = 64;
else
{
FT_Pos delta = len - dim->stdw.widths[0].cur;
if ( delta < 0 )
delta = -delta;
if ( delta < 40 )
{
len = dim->stdw.widths[0].cur;
if ( len < 48 )
len = 48;
}
if ( len < 3 * 64 )
{
delta = ( len & 63 );
len &= -64;
if ( delta < 10 )
len += delta;
else if ( delta < 32 )
len += 10;
else if ( delta < 54 )
len += 54;
else
len += delta;
}
else
len = FT_PIX_ROUND( len );
}
if ( do_snapping )
len = FT_PIX_ROUND( len );
return len;
}
|
CWE-399
| 10,326 | 17,000 |
52495903358478327300836003803266609277
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_glyph_compute_inflections( PSH_Glyph glyph )
{
FT_UInt n;
for ( n = 0; n < glyph->num_contours; n++ )
{
PSH_Point first, start, end, before, after;
FT_Pos in_x, in_y, out_x, out_y;
FT_Int orient_prev, orient_cur;
FT_Int finished = 0;
/* we need at least 4 points to create an inflection point */
if ( glyph->contours[n].count < 4 )
continue;
/* compute first segment in contour */
first = glyph->contours[n].start;
start = end = first;
do
{
end = end->next;
if ( end == first )
goto Skip;
in_x = end->org_u - start->org_u;
in_y = end->org_v - start->org_v;
} while ( in_x == 0 && in_y == 0 );
/* extend the segment start whenever possible */
before = start;
do
{
do
{
start = before;
before = before->prev;
if ( before == first )
goto Skip;
out_x = start->org_u - before->org_u;
out_y = start->org_v - before->org_v;
} while ( out_x == 0 && out_y == 0 );
orient_prev = psh_corner_orientation( in_x, in_y, out_x, out_y );
} while ( orient_prev == 0 );
first = start;
in_x = out_x;
in_y = out_y;
/* now, process all segments in the contour */
do
{
/* first, extend current segment's end whenever possible */
after = end;
do
{
do
{
end = after;
after = after->next;
if ( after == first )
finished = 1;
out_x = after->org_u - end->org_u;
out_y = after->org_v - end->org_v;
} while ( out_x == 0 && out_y == 0 );
orient_cur = psh_corner_orientation( in_x, in_y, out_x, out_y );
} while ( orient_cur == 0 );
if ( ( orient_cur ^ orient_prev ) < 0 )
{
do
{
psh_point_set_inflex( start );
start = start->next;
}
while ( start != end );
psh_point_set_inflex( start );
}
start = end;
end = after;
orient_prev = orient_cur;
in_x = out_x;
in_y = out_y;
} while ( !finished );
Skip:
;
}
}
|
CWE-399
| 10,328 | 17,001 |
213885705785004780780422853180887174004
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_glyph_done( PSH_Glyph glyph )
{
FT_Memory memory = glyph->memory;
psh_hint_table_done( &glyph->hint_tables[1], memory );
psh_hint_table_done( &glyph->hint_tables[0], memory );
FT_FREE( glyph->points );
FT_FREE( glyph->contours );
glyph->num_points = 0;
glyph->num_contours = 0;
glyph->memory = 0;
}
|
CWE-399
| 10,329 | 17,002 |
284643432983515085926974880526470399358
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_glyph_find_blue_points( PSH_Blues blues,
PSH_Glyph glyph )
{
PSH_Blue_Table table;
PSH_Blue_Zone zone;
FT_UInt glyph_count = glyph->num_points;
FT_UInt blue_count;
PSH_Point point = glyph->points;
for ( ; glyph_count > 0; glyph_count--, point++ )
{
FT_Pos y;
/* check tangents */
if ( !PSH_DIR_COMPARE( point->dir_in, PSH_DIR_HORIZONTAL ) &&
!PSH_DIR_COMPARE( point->dir_out, PSH_DIR_HORIZONTAL ) )
continue;
/* skip strong points */
if ( psh_point_is_strong( point ) )
continue;
y = point->org_u;
/* look up top zones */
table = &blues->normal_top;
blue_count = table->count;
zone = table->zones;
for ( ; blue_count > 0; blue_count--, zone++ )
{
FT_Pos delta = y - zone->org_bottom;
if ( delta < -blues->blue_fuzz )
break;
if ( y <= zone->org_top + blues->blue_fuzz )
if ( blues->no_overshoots || delta <= blues->blue_threshold )
{
point->cur_u = zone->cur_bottom;
psh_point_set_strong( point );
psh_point_set_fitted( point );
}
}
/* look up bottom zones */
table = &blues->normal_bottom;
blue_count = table->count;
zone = table->zones + blue_count - 1;
for ( ; blue_count > 0; blue_count--, zone-- )
{
FT_Pos delta = zone->org_top - y;
if ( delta < -blues->blue_fuzz )
break;
if ( y >= zone->org_bottom - blues->blue_fuzz )
if ( blues->no_overshoots || delta < blues->blue_threshold )
{
point->cur_u = zone->cur_top;
psh_point_set_strong( point );
psh_point_set_fitted( point );
}
}
}
}
|
CWE-399
| 10,330 | 17,003 |
204398549386325942817902062627463718393
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_glyph_interpolate_normal_points( PSH_Glyph glyph,
FT_Int dimension )
{
#if 1
/* first technique: a point is strong if it is a local extremum */
PSH_Dimension dim = &glyph->globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Memory memory = glyph->memory;
PSH_Point* strongs = NULL;
PSH_Point strongs_0[PSH_MAX_STRONG_INTERNAL];
FT_UInt num_strongs = 0;
PSH_Point points = glyph->points;
PSH_Point points_end = points + glyph->num_points;
PSH_Point point;
/* first count the number of strong points */
for ( point = points; point < points_end; point++ )
{
if ( psh_point_is_strong( point ) )
num_strongs++;
}
if ( num_strongs == 0 ) /* nothing to do here */
return;
/* allocate an array to store a list of points, */
/* stored in increasing org_u order */
if ( num_strongs <= PSH_MAX_STRONG_INTERNAL )
strongs = strongs_0;
else
{
FT_Error error;
if ( FT_NEW_ARRAY( strongs, num_strongs ) )
return;
}
num_strongs = 0;
for ( point = points; point < points_end; point++ )
{
PSH_Point* insert;
if ( !psh_point_is_strong( point ) )
continue;
for ( insert = strongs + num_strongs; insert > strongs; insert-- )
{
if ( insert[-1]->org_u <= point->org_u )
break;
insert[0] = insert[-1];
}
insert[0] = point;
num_strongs++;
}
/* now try to interpolate all normal points */
for ( point = points; point < points_end; point++ )
{
if ( psh_point_is_strong( point ) )
continue;
/* sometimes, some local extrema are smooth points */
if ( psh_point_is_smooth( point ) )
{
if ( point->dir_in == PSH_DIR_NONE ||
point->dir_in != point->dir_out )
continue;
if ( !psh_point_is_extremum( point ) &&
!psh_point_is_inflex( point ) )
continue;
point->flags &= ~PSH_POINT_SMOOTH;
}
/* find best enclosing point coordinates then interpolate */
{
PSH_Point before, after;
FT_UInt nn;
for ( nn = 0; nn < num_strongs; nn++ )
if ( strongs[nn]->org_u > point->org_u )
break;
if ( nn == 0 ) /* point before the first strong point */
{
after = strongs[0];
point->cur_u = after->cur_u +
FT_MulFix( point->org_u - after->org_u,
scale );
}
else
{
before = strongs[nn - 1];
for ( nn = num_strongs; nn > 0; nn-- )
if ( strongs[nn - 1]->org_u < point->org_u )
break;
if ( nn == num_strongs ) /* point is after last strong point */
{
before = strongs[nn - 1];
point->cur_u = before->cur_u +
FT_MulFix( point->org_u - before->org_u,
scale );
}
else
{
FT_Pos u;
after = strongs[nn];
/* now interpolate point between before and after */
u = point->org_u;
if ( u == before->org_u )
point->cur_u = before->cur_u;
else if ( u == after->org_u )
point->cur_u = after->cur_u;
else
point->cur_u = before->cur_u +
FT_MulDiv( u - before->org_u,
after->cur_u - before->cur_u,
after->org_u - before->org_u );
}
}
psh_point_set_fitted( point );
}
}
if ( strongs != strongs_0 )
FT_FREE( strongs );
#endif /* 1 */
}
|
CWE-399
| 10,332 | 17,004 |
103607518043955106054205060146090543323
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_glyph_interpolate_other_points( PSH_Glyph glyph,
FT_Int dimension )
{
PSH_Dimension dim = &glyph->globals->dimension[dimension];
FT_Fixed scale = dim->scale_mult;
FT_Fixed delta = dim->scale_delta;
PSH_Contour contour = glyph->contours;
FT_UInt num_contours = glyph->num_contours;
for ( ; num_contours > 0; num_contours--, contour++ )
{
PSH_Point start = contour->start;
PSH_Point first, next, point;
FT_UInt fit_count;
/* count the number of strong points in this contour */
next = start + contour->count;
fit_count = 0;
first = 0;
for ( point = start; point < next; point++ )
if ( psh_point_is_fitted( point ) )
{
if ( !first )
first = point;
fit_count++;
}
/* if there are less than 2 fitted points in the contour, we */
/* simply scale and eventually translate the contour points */
if ( fit_count < 2 )
{
if ( fit_count == 1 )
delta = first->cur_u - FT_MulFix( first->org_u, scale );
for ( point = start; point < next; point++ )
if ( point != first )
point->cur_u = FT_MulFix( point->org_u, scale ) + delta;
goto Next_Contour;
}
/* there are more than 2 strong points in this contour; we */
/* need to interpolate weak points between them */
start = first;
do
{
point = first;
/* skip consecutive fitted points */
for (;;)
{
next = first->next;
if ( next == start )
goto Next_Contour;
if ( !psh_point_is_fitted( next ) )
break;
first = next;
}
/* find next fitted point after unfitted one */
for (;;)
{
next = next->next;
if ( psh_point_is_fitted( next ) )
break;
}
/* now interpolate between them */
{
FT_Pos org_a, org_ab, cur_a, cur_ab;
FT_Pos org_c, org_ac, cur_c;
FT_Fixed scale_ab;
if ( first->org_u <= next->org_u )
{
org_a = first->org_u;
cur_a = first->cur_u;
org_ab = next->org_u - org_a;
cur_ab = next->cur_u - cur_a;
}
else
{
org_a = next->org_u;
cur_a = next->cur_u;
org_ab = first->org_u - org_a;
cur_ab = first->cur_u - cur_a;
}
scale_ab = 0x10000L;
if ( org_ab > 0 )
scale_ab = FT_DivFix( cur_ab, org_ab );
point = first->next;
do
{
org_c = point->org_u;
org_ac = org_c - org_a;
if ( org_ac <= 0 )
{
/* on the left of the interpolation zone */
cur_c = cur_a + FT_MulFix( org_ac, scale );
}
else if ( org_ac >= org_ab )
{
/* on the right on the interpolation zone */
cur_c = cur_a + cur_ab + FT_MulFix( org_ac - org_ab, scale );
}
else
{
/* within the interpolation zone */
cur_c = cur_a + FT_MulFix( org_ac, scale_ab );
}
point->cur_u = cur_c;
point = point->next;
} while ( point != next );
}
/* keep going until all points in the contours have been processed */
first = next;
} while ( first != start );
Next_Contour:
;
}
}
|
CWE-399
| 10,333 | 17,005 |
110589556226835294590650212128016358128
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_glyph_load_points( PSH_Glyph glyph,
FT_Int dimension )
{
FT_Vector* vec = glyph->outline->points;
PSH_Point point = glyph->points;
FT_UInt count = glyph->num_points;
for ( ; count > 0; count--, point++, vec++ )
{
point->flags2 = 0;
point->hint = NULL;
if ( dimension == 0 )
{
point->org_u = vec->x;
point->org_v = vec->y;
}
else
{
point->org_u = vec->y;
point->org_v = vec->x;
}
#ifdef DEBUG_HINTER
point->org_x = vec->x;
point->org_y = vec->y;
#endif
}
}
|
CWE-399
| 10,334 | 17,006 |
208535546266237740749088750194381195836
| null | null | null |
savannah
|
8d22746c9e5af80ff4304aef440986403a5072e2
| 0 |
psh_glyph_save_points( PSH_Glyph glyph,
FT_Int dimension )
{
FT_UInt n;
PSH_Point point = glyph->points;
FT_Vector* vec = glyph->outline->points;
char* tags = glyph->outline->tags;
for ( n = 0; n < glyph->num_points; n++ )
{
if ( dimension == 0 )
vec[n].x = point->cur_u;
else
vec[n].y = point->cur_u;
if ( psh_point_is_strong( point ) )
tags[n] |= (char)( ( dimension == 0 ) ? 32 : 64 );
#ifdef DEBUG_HINTER
if ( dimension == 0 )
{
point->cur_x = point->cur_u;
point->flags_x = point->flags2 | point->flags;
}
else
{
point->cur_y = point->cur_u;
point->flags_y = point->flags2 | point->flags;
}
#endif
point++;
}
}
|
CWE-399
| 10,335 | 17,007 |
41309653504658266367482374080633768194
| null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.