本文整理汇总了C++中FT_ALLOC函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_ALLOC函数的具体用法?C++ FT_ALLOC怎么用?C++ FT_ALLOC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FT_ALLOC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ftc_sbit_copy_bitmap
static FT_Error
ftc_sbit_copy_bitmap( FTC_SBit sbit,
FT_Bitmap* bitmap,
FT_Memory memory )
{
FT_Error error;
FT_Int pitch = bitmap->pitch;
FT_ULong size;
if ( pitch < 0 )
pitch = -pitch;
size = (FT_ULong)( pitch * bitmap->rows );
if ( !FT_ALLOC( sbit->buffer, size ) )
FT_MEM_COPY( sbit->buffer, bitmap->buffer, size );
return error;
}
示例2: pfr_aux_name_load
/*
* Load a name from the auxiliary data. Since this extracts undocumented
* strings from the font file, we need to be careful here.
*/
static FT_Error
pfr_aux_name_load( FT_Byte* p,
FT_UInt len,
FT_Memory memory,
FT_String* *astring )
{
FT_Error error = FT_Err_Ok;
FT_String* result = NULL;
FT_UInt n, ok;
if ( *astring )
FT_FREE( *astring );
if ( len > 0 && p[len - 1] == 0 )
len--;
/* check that each character is ASCII */
/* for making sure not to load garbage */
ok = ( len > 0 );
for ( n = 0; n < len; n++ )
if ( p[n] < 32 || p[n] > 127 )
{
ok = 0;
break;
}
if ( ok )
{
if ( FT_ALLOC( result, len + 1 ) )
goto Exit;
FT_MEM_COPY( result, p, len );
result[len] = 0;
}
Exit:
*astring = result;
return error;
}
示例3: autofit_module_class_pic_init
FT_Error
autofit_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_UInt ss;
FT_Error error = AF_Err_Ok;
AFModulePIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->autofit = container;
/* initialize pointer table - this is how the module usually expects this data */
for ( ss = 0 ; ss < AF_SCRIPT_CLASSES_REC_COUNT ; ss++ )
{
container->af_script_classes[ss] = &container->af_script_classes_rec[ss];
}
container->af_script_classes[AF_SCRIPT_CLASSES_COUNT-1] = NULL;
/* add call to initialization function when you add new scripts */
ss = 0;
FT_Init_Class_af_dummy_script_class(&container->af_script_classes_rec[ss++]);
#ifdef FT_OPTION_AUTOFIT2
FT_Init_Class_af_latin2_script_class(&container->af_script_classes_rec[ss++]);
#endif
FT_Init_Class_af_latin_script_class(&container->af_script_classes_rec[ss++]);
FT_Init_Class_af_cjk_script_class(&container->af_script_classes_rec[ss++]);
FT_Init_Class_af_indic_script_class(&container->af_script_classes_rec[ss++]);
FT_Init_Class_af_autofitter_service(library, &container->af_autofitter_service);
/*Exit:*/
if(error)
autofit_module_class_pic_free(library);
return error;
}
示例4: FT_LruList_New
FT_LruList_New( FT_LruList_Class clazz,
FT_UInt max_nodes,
FT_Pointer user_data,
FT_Memory memory,
FT_LruList *alist )
{
FT_Error error;
FT_LruList list;
if ( !alist || !clazz )
return FTC_Err_Invalid_Argument;
*alist = NULL;
if ( !FT_ALLOC( list, clazz->list_size ) )
{
/* initialize common fields */
list->clazz = clazz;
list->memory = memory;
list->max_nodes = max_nodes;
list->data = user_data;
if ( clazz->list_init )
{
error = clazz->list_init( list );
if ( error )
{
if ( clazz->list_done )
clazz->list_done( list );
FT_FREE( list );
}
}
*alist = list;
}
return error;
}
示例5: pshinter_module_class_pic_init
FT_Error
pshinter_module_class_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
PSHinterPIC* container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC ( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof(*container) );
pic_container->pshinter = container;
/* add call to initialization function when you add new scripts */
FT_Init_Class_pshinter_interface(library, &container->pshinter_interface);
/*Exit:*/
if(error)
pshinter_module_class_pic_free(library);
return error;
}
示例6: ft_bitmap_copy
static FT_Error
ft_bitmap_copy( FT_Memory memory,
FT_Bitmap* source,
FT_Bitmap* target )
{
FT_Error error;
FT_Int pitch = source->pitch;
FT_ULong size;
*target = *source;
if ( pitch < 0 )
pitch = -pitch;
size = (FT_ULong)( pitch * source->rows );
if ( !FT_ALLOC( target->buffer, size ) )
FT_MEM_COPY( target->buffer, source->buffer, size );
return error;
}
示例7: pfr_extra_item_load_font_id
pfr_extra_item_load_font_id( FT_Byte* p,
FT_Byte* limit,
PFR_PhyFont phy_font )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory = phy_font->memory;
FT_UInt len = (FT_UInt)( limit - p );
if ( phy_font->font_id )
goto Exit;
if ( FT_ALLOC( phy_font->font_id, len + 1 ) )
goto Exit;
/* copy font ID name, and terminate it for safety */
FT_MEM_COPY( phy_font->font_id, p, len );
phy_font->font_id[len] = 0;
Exit:
return error;
}
示例8: af_face_globals_new
af_face_globals_new( FT_Face face,
AF_FaceGlobals *aglobals,
AF_Module module )
{
FT_Error error;
FT_Memory memory;
AF_FaceGlobals globals = NULL;
memory = face->memory;
if ( FT_ALLOC( globals,
sizeof ( *globals ) +
(FT_ULong)face->num_glyphs * sizeof ( FT_Byte ) ) )
goto Exit;
globals->face = face;
globals->glyph_count = face->num_glyphs;
globals->glyph_styles = (FT_Byte*)( globals + 1 );
globals->module = module;
#ifdef FT_CONFIG_OPTION_USE_HARFBUZZ
globals->hb_font = hb_ft_font_create( face, NULL );
#endif
error = af_face_globals_compute_style_coverage( globals );
if ( error )
{
af_face_globals_free( globals );
globals = NULL;
}
else
globals->increase_x_height = AF_PROP_INCREASE_X_HEIGHT_MAX;
Exit:
*aglobals = globals;
return error;
}
示例9: cff_driver_class_pic_init
FT_Error
cff_driver_class_pic_init(FT_Library library)
{
FT_PIC_Container *pic_container = &library->pic_container;
FT_Error error = CFF_Err_Ok;
CffModulePIC *container;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if (FT_ALLOC (container, sizeof(*container)))
return error;
FT_MEM_SET(container, 0, sizeof(*container));
pic_container->cff = container;
/* initialize pointer table - this is how the module usually expects this data */
error = FT_Create_Class_cff_services(library, &container->cff_services);
if (error)
goto Exit;
error = FT_Create_Class_cff_field_handlers(library, &container->cff_field_handlers);
if (error)
goto Exit;
FT_Init_Class_cff_service_ps_info(library, &container->cff_service_ps_info);
FT_Init_Class_cff_service_glyph_dict(library, &container->cff_service_glyph_dict);
FT_Init_Class_cff_service_ps_name(library, &container->cff_service_ps_name);
FT_Init_Class_cff_service_get_cmap_info(library, &container->cff_service_get_cmap_info);
FT_Init_Class_cff_service_cid_info(library, &container->cff_service_cid_info);
FT_Init_Class_cff_cmap_encoding_class_rec(library, &container->cff_cmap_encoding_class_rec);
FT_Init_Class_cff_cmap_unicode_class_rec(library, &container->cff_cmap_unicode_class_rec);
Exit:
if (error)
cff_driver_class_pic_free(library);
return error;
}
示例10: ft_new_glyph
static FT_Error
ft_new_glyph( FT_Library library,
const FT_Glyph_Class* clazz,
FT_Glyph* aglyph )
{
FT_Memory memory = library->memory;
FT_Error error;
FT_Glyph glyph = NULL;
*aglyph = 0;
if ( !FT_ALLOC( glyph, clazz->glyph_size ) )
{
glyph->library = library;
glyph->clazz = clazz;
glyph->format = clazz->glyph_format;
*aglyph = glyph;
}
return error;
}
示例11: ft_base_pic_init
FT_Error
ft_base_pic_init( FT_Library library )
{
FT_PIC_Container* pic_container = &library->pic_container;
FT_Error error = FT_Err_Ok;
BasePIC* container = NULL;
FT_Memory memory = library->memory;
/* allocate pointer, clear and set global container pointer */
if ( FT_ALLOC( container, sizeof ( *container ) ) )
return error;
FT_MEM_SET( container, 0, sizeof ( *container ) );
pic_container->base = container;
/* initialize default modules list and pointers */
error = ft_create_default_module_classes( library );
if ( error )
goto Exit;
/* initialize pointer table - */
/* this is how the module usually expects this data */
FT_Init_Class_ft_outline_glyph_class(
&container->ft_outline_glyph_class );
FT_Init_Class_ft_bitmap_glyph_class(
&container->ft_bitmap_glyph_class );
#ifdef FT_CONFIG_OPTION_MAC_FONTS
FT_Init_Table_ft_raccess_guess_table(
(ft_raccess_guess_rec*)&container->ft_raccess_guess_table );
#endif
Exit:
if ( error )
ft_base_pic_free( library );
return error;
}
示例12: FT_New_Face_From_SFNT
/* Create a new FT_Face from an SFNT resource, specified by res ID. */
static FT_Error
FT_New_Face_From_SFNT( FT_Library library,
short sfnt_id,
FT_Long face_index,
FT_Face *aface )
{
Handle sfnt = NULL;
FT_Byte* sfnt_data;
size_t sfnt_size;
FT_Error error = 0;
FT_Memory memory = library->memory;
sfnt = GetResource( 'sfnt', sfnt_id );
if ( ResError() )
return FT_Err_Invalid_Handle;
sfnt_size = (FT_ULong)GetHandleSize( sfnt );
if ( FT_ALLOC( sfnt_data, (FT_Long)sfnt_size ) )
{
ReleaseResource( sfnt );
return error;
}
HLock( sfnt );
ft_memcpy( sfnt_data, *sfnt, sfnt_size );
HUnlock( sfnt );
ReleaseResource( sfnt );
return open_face_from_buffer( library,
sfnt_data,
sfnt_size,
face_index,
"truetype",
aface );
}
示例13: otv_load_table
static FT_Error
otv_load_table( FT_Face face,
FT_Tag tag,
FT_Byte* volatile* table,
FT_ULong* table_len )
{
FT_Error error;
FT_Memory memory = FT_FACE_MEMORY( face );
error = FT_Load_Sfnt_Table( face, tag, 0, NULL, table_len );
if ( error == OTV_Err_Table_Missing )
return OTV_Err_Ok;
if ( error )
goto Exit;
if ( FT_ALLOC( *table, *table_len ) )
goto Exit;
error = FT_Load_Sfnt_Table( face, tag, 0, *table, table_len );
Exit:
return error;
}
示例14: cff_index_get_name
cff_index_get_name( CFF_Index idx,
FT_UInt element )
{
FT_Memory memory = idx->stream->memory;
FT_Byte* bytes;
FT_ULong byte_len;
FT_Error error;
FT_String* name = 0;
error = cff_index_access_element( idx, element, &bytes, &byte_len );
if ( error )
goto Exit;
if ( !FT_ALLOC( name, byte_len + 1 ) )
{
FT_MEM_COPY( name, bytes, byte_len );
name[byte_len] = 0;
}
cff_index_forget_element( idx, &bytes );
Exit:
return name;
}
示例15: FT_LruList_Lookup
//.........这里部分代码省略.........
{
for (;;)
{
node = *pnode;
if ( node == NULL )
break;
if ( node->key == key )
break;
plast = pnode;
pnode = &(*pnode)->next;
}
}
if ( node )
{
/* move element to top of list */
if ( list->nodes != node )
{
*pnode = node->next;
node->next = list->nodes;
list->nodes = node;
}
result = node;
goto Exit;
}
/* we haven't found the relevant element. We will now try */
/* to create a new one. */
/* */
/* first, check if our list if full, when appropriate */
if ( list->max_nodes > 0 && list->num_nodes >= list->max_nodes )
{
/* this list list is full; we will now flush */
/* the oldest node, if there's one! */
FT_LruNode last = *plast;
if ( last )
{
if ( clazz->node_flush )
{
error = clazz->node_flush( last, key, list->data );
}
else
{
if ( clazz->node_done )
clazz->node_done( last, list->data );
last->key = key;
error = clazz->node_init( last, key, list->data );
}
if ( !error )
{
/* move it to the top of the list */
*plast = NULL;
last->next = list->nodes;
list->nodes = last;
result = last;
goto Exit;
}
/* in case of error during the flush or done/init cycle, */
/* we need to discard the node */
if ( clazz->node_done )
clazz->node_done( last, list->data );
*plast = NULL;
list->num_nodes--;
FT_FREE( last );
goto Exit;
}
}
/* otherwise, simply allocate a new node */
if ( FT_ALLOC( node, clazz->node_size ) )
goto Exit;
node->key = key;
error = clazz->node_init( node, key, list->data );
if ( error )
{
FT_FREE( node );
goto Exit;
}
result = node;
node->next = list->nodes;
list->nodes = node;
list->num_nodes++;
Exit:
*anode = result;
return error;
}