📄 ftcsbits.c
字号:
error = ftc_sbit_node_load( snode, cache->manager, FTC_SBIT_FAMILY( FTC_QUERY( gquery )->family ), gquery->gindex, NULL ); if ( error ) ftc_glyph_node_done( FTC_GLYPH_NODE( snode ), cache ); return error; } FT_CALLBACK_DEF( FT_ULong ) ftc_sbit_node_weight( FTC_SBitNode snode ) { FTC_GlyphNode gnode = FTC_GLYPH_NODE( snode ); FT_UInt count = gnode->item_count; FTC_SBit sbit = snode->sbits; FT_Int pitch; FT_ULong size; /* the node itself */ size = sizeof ( *snode ); /* the sbit records */ size += FTC_GLYPH_NODE( snode )->item_count * sizeof ( FTC_SBitRec ); for ( ; count > 0; count--, sbit++ ) { if ( sbit->buffer ) { pitch = sbit->pitch; if ( pitch < 0 ) pitch = -pitch; /* add the size of a given glyph image */ size += pitch * sbit->height; } } return size; } FT_CALLBACK_DEF( FT_Bool ) ftc_sbit_node_compare( FTC_SBitNode snode, FTC_SBitQuery squery, FTC_Cache cache ) { FTC_GlyphQuery gquery = FTC_GLYPH_QUERY( squery ); FTC_GlyphNode gnode = FTC_GLYPH_NODE( snode ); FT_Bool result; result = ftc_glyph_node_compare( gnode, gquery ); if ( result ) { /* check if we need to load the glyph bitmap now */ FT_UInt gindex = gquery->gindex; FTC_SBit sbit = snode->sbits + ( gindex - gnode->item_start ); if ( sbit->buffer == NULL && sbit->width != 255 ) { FT_ULong size; /* yes, it's safe to ignore errors here */ ftc_sbit_node_load( snode, cache->manager, FTC_SBIT_FAMILY( FTC_QUERY( squery )->family ), gindex, &size ); cache->manager->cur_weight += size; } } return result; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** SBITS FAMILIES *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_CALLBACK_DEF( FT_Error ) ftc_sbit_family_init( FTC_SBitFamily sfam, FTC_SBitQuery squery, FTC_Cache cache ) { FTC_Manager manager = cache->manager; FT_Error error; FT_Face face; sfam->desc = squery->desc; /* we need to compute "cquery.item_total" now */ error = FTC_Manager_Lookup_Face( manager, squery->desc.font.face_id, &face ); if ( !error ) { error = ftc_glyph_family_init( FTC_GLYPH_FAMILY( sfam ), FTC_IMAGE_DESC_HASH( &sfam->desc ), FTC_SBIT_ITEMS_PER_NODE, face->num_glyphs, FTC_GLYPH_QUERY( squery ), cache ); } return error; } FT_CALLBACK_DEF( FT_Bool ) ftc_sbit_family_compare( FTC_SBitFamily sfam, FTC_SBitQuery squery ) { FT_Bool result; /* we need to set the "cquery.cset" field or our query for */ /* faster glyph comparisons in ftc_sbit_node_compare */ /* */ result = FT_BOOL( FTC_IMAGE_DESC_COMPARE( &sfam->desc, &squery->desc ) ); if ( result ) FTC_GLYPH_FAMILY_FOUND( sfam, squery ); return result; } /*************************************************************************/ /*************************************************************************/ /***** *****/ /***** SBITS CACHE *****/ /***** *****/ /*************************************************************************/ /*************************************************************************/ FT_CALLBACK_TABLE_DEF const FTC_Cache_ClassRec ftc_sbit_cache_class = { sizeof ( FTC_CacheRec ), (FTC_Cache_InitFunc) ftc_cache_init, (FTC_Cache_ClearFunc)ftc_cache_clear, (FTC_Cache_DoneFunc) ftc_cache_done, sizeof ( FTC_SBitFamilyRec ), (FTC_Family_InitFunc) ftc_sbit_family_init, (FTC_Family_CompareFunc)ftc_sbit_family_compare, (FTC_Family_DoneFunc) ftc_glyph_family_done, sizeof ( FTC_SBitNodeRec ), (FTC_Node_InitFunc) ftc_sbit_node_init, (FTC_Node_WeightFunc) ftc_sbit_node_weight, (FTC_Node_CompareFunc)ftc_sbit_node_compare, (FTC_Node_DoneFunc) ftc_sbit_node_done }; /* documentation is in ftcsbits.h */ FT_EXPORT_DEF( FT_Error ) FTC_SBitCache_New( FTC_Manager manager, FTC_SBitCache *acache ) { return FTC_Manager_Register_Cache( manager, &ftc_sbit_cache_class, (FTC_Cache*)acache ); } /* documentation is in ftcsbits.h */#ifdef FTC_CACHE_USE_INLINE#define GEN_CACHE_FAMILY_COMPARE( f, q, c ) \ ftc_sbit_family_compare( (FTC_SBitFamily)(f), (FTC_SBitQuery)(q) )#define GEN_CACHE_NODE_COMPARE( n, q, c ) \ ftc_sbit_node_compare( (FTC_SBitNode)(n), (FTC_SBitQuery)(q), c )#define GEN_CACHE_LOOKUP ftc_sbit_cache_lookup#include "ftccache.i"#else /* !FTC_CACHE_USE_INLINE */#define ftc_sbit_cache_lookup ftc_cache_lookup#endif /* !FTC_CACHE_USE_INLINE */ FT_EXPORT_DEF( FT_Error ) FTC_SBitCache_Lookup( FTC_SBitCache cache, FTC_ImageDesc* desc, FT_UInt gindex, FTC_SBit *ansbit, FTC_Node *anode ) { FT_Error error; FTC_SBitQueryRec squery; FTC_SBitNode node; /* other argument checks delayed to ftc_cache_lookup */ if ( !ansbit ) return FTC_Err_Invalid_Argument; *ansbit = NULL; if ( anode ) *anode = NULL; squery.gquery.gindex = gindex; squery.desc = *desc; error = ftc_sbit_cache_lookup( FTC_CACHE( cache ), FTC_QUERY( &squery ), (FTC_Node*)&node ); if ( !error ) { *ansbit = node->sbits + ( gindex - FTC_GLYPH_NODE( node )->item_start ); if ( anode ) { *anode = FTC_NODE( node ); FTC_NODE( node )->ref_count++; } } return error; } /* backwards-compatibility functions */ FT_EXPORT_DEF( FT_Error ) FTC_SBit_Cache_New( FTC_Manager manager, FTC_SBit_Cache *acache ) { return FTC_SBitCache_New( manager, (FTC_SBitCache*)acache ); } FT_EXPORT_DEF( FT_Error ) FTC_SBit_Cache_Lookup( FTC_SBit_Cache cache, FTC_Image_Desc* desc, FT_UInt gindex, FTC_SBit *ansbit ) { FTC_ImageDesc desc0; if ( !desc ) return FTC_Err_Invalid_Argument; desc0.font = desc->font; desc0.type = (FT_UInt32)desc->image_type; return FTC_SBitCache_Lookup( (FTC_SBitCache)cache, &desc0, gindex, ansbit, NULL ); }/* END */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -