|
|
|
@ -32,17 +32,17 @@ |
|
|
|
|
#define FTC_SBIT_ITEMS_PER_NODE 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct FTC_SBitNodeRec_* FTC_SBitNode; |
|
|
|
|
typedef struct FTC_SBitNodeRec_* FTC_SBitNode; |
|
|
|
|
|
|
|
|
|
typedef struct FTC_SBitNodeRec_ |
|
|
|
|
typedef struct FTC_SBitNodeRec_ |
|
|
|
|
{ |
|
|
|
|
FTC_GlyphNodeRec gnode; |
|
|
|
|
FTC_SBitRec sbits[ FTC_SBIT_ITEMS_PER_NODE ]; |
|
|
|
|
FTC_GlyphNodeRec gnode; |
|
|
|
|
FTC_SBitRec sbits[FTC_SBIT_ITEMS_PER_NODE]; |
|
|
|
|
|
|
|
|
|
} FTC_SBitNodeRec; |
|
|
|
|
|
|
|
|
|
#define FTC_SBIT_NODE(x) ((FTC_SBitNode)(x)) |
|
|
|
|
|
|
|
|
|
#define FTC_SBIT_NODE( x ) ( (FTC_SBitNode)( x ) ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct FTC_SBitQueryRec_ |
|
|
|
@ -52,23 +52,23 @@ |
|
|
|
|
|
|
|
|
|
} FTC_SBitQueryRec, *FTC_SBitQuery; |
|
|
|
|
|
|
|
|
|
#define FTC_SBIT_QUERY(x) ((FTC_SBitQuery)(x)) |
|
|
|
|
|
|
|
|
|
#define FTC_SBIT_QUERY( x ) ( (FTC_SBitQuery)( x ) ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct FTC_SBitFamilyRec_* FTC_SBitFamily; |
|
|
|
|
|
|
|
|
|
/* sbit family structure */ |
|
|
|
|
/* sbit family structure */ |
|
|
|
|
typedef struct FTC_SBitFamilyRec_ |
|
|
|
|
{ |
|
|
|
|
FTC_GlyphFamilyRec gfam; |
|
|
|
|
FTC_ImageDesc desc; |
|
|
|
|
|
|
|
|
|
} FTC_SBitFamilyRec; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define FTC_SBIT_FAMILY( x ) ( (FTC_SBitFamily)(x) ) |
|
|
|
|
#define FTC_SBIT_FAMILY_MEMORY( x ) FTC_GLYPH_FAMILY_MEMORY( &(x)->cset ) |
|
|
|
|
|
|
|
|
|
#define FTC_SBIT_FAMILY( x ) ( (FTC_SBitFamily)( x ) ) |
|
|
|
|
#define FTC_SBIT_FAMILY_MEMORY( x ) FTC_GLYPH_FAMILY_MEMORY( &( x )->cset ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
@ -102,54 +102,54 @@ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_DEF( void ) |
|
|
|
|
ftc_sbit_node_done( FTC_SBitNode snode, |
|
|
|
|
FTC_Cache cache ) |
|
|
|
|
{ |
|
|
|
|
FTC_SBit sbit = snode->sbits; |
|
|
|
|
FT_UInt count = FTC_GLYPH_NODE(snode)->item_count; |
|
|
|
|
FT_UInt count = FTC_GLYPH_NODE( snode )->item_count; |
|
|
|
|
FT_Memory memory = cache->memory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( ; count > 0; sbit++, count-- ) |
|
|
|
|
FREE( sbit->buffer ); |
|
|
|
|
|
|
|
|
|
ftc_glyph_node_done( FTC_GLYPH_NODE(snode), cache ); |
|
|
|
|
ftc_glyph_node_done( FTC_GLYPH_NODE( snode ), cache ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error |
|
|
|
|
ftc_sbit_node_load( FTC_SBitNode snode, |
|
|
|
|
FTC_Manager manager, |
|
|
|
|
FTC_SBitFamily sfam, |
|
|
|
|
FT_UInt gindex, |
|
|
|
|
FT_ULong *asize ) |
|
|
|
|
ftc_sbit_node_load( FTC_SBitNode snode, |
|
|
|
|
FTC_Manager manager, |
|
|
|
|
FTC_SBitFamily sfam, |
|
|
|
|
FT_UInt gindex, |
|
|
|
|
FT_ULong *asize ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error; |
|
|
|
|
FTC_GlyphNode gnode = FTC_GLYPH_NODE(snode); |
|
|
|
|
FT_Memory memory; |
|
|
|
|
FT_Face face; |
|
|
|
|
FT_Size size; |
|
|
|
|
FTC_SBit sbit; |
|
|
|
|
FT_Error error; |
|
|
|
|
FTC_GlyphNode gnode = FTC_GLYPH_NODE( snode ); |
|
|
|
|
FT_Memory memory; |
|
|
|
|
FT_Face face; |
|
|
|
|
FT_Size size; |
|
|
|
|
FTC_SBit sbit; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( gindex < (FT_UInt)gnode->item_start || |
|
|
|
|
gindex >= (FT_UInt)gnode->item_start + gnode->item_count ) |
|
|
|
|
{ |
|
|
|
|
FT_ERROR(( "FreeType.cache.sbit_load: invalid glyph index" )); |
|
|
|
|
FT_ERROR(( "ftc_sbit_node_load: invalid glyph index" )); |
|
|
|
|
return FTC_Err_Invalid_Argument; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
memory = manager->library->memory; |
|
|
|
|
|
|
|
|
|
sbit = snode->sbits + (gindex - gnode->item_start); |
|
|
|
|
sbit = snode->sbits + ( gindex - gnode->item_start ); |
|
|
|
|
|
|
|
|
|
error = FTC_Manager_Lookup_Size( manager, &sfam->desc.font, |
|
|
|
|
&face, &size ); |
|
|
|
|
if ( !error ) |
|
|
|
|
{ |
|
|
|
|
FT_UInt load_flags = FT_LOAD_DEFAULT; |
|
|
|
|
FT_UInt type = sfam->desc.type; |
|
|
|
|
FT_UInt load_flags = FT_LOAD_DEFAULT; |
|
|
|
|
FT_UInt type = sfam->desc.type; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* determine load flags, depending on the font description's */ |
|
|
|
@ -167,7 +167,7 @@ |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
FT_ERROR(( |
|
|
|
|
"FreeType.cache.sbit_load: cannot load scalable glyphs in an" |
|
|
|
|
"ftc_sbit_node_load: cannot load scalable glyphs in an" |
|
|
|
|
" sbit cache, please check your arguments!\n" )); |
|
|
|
|
error = FTC_Err_Invalid_Argument; |
|
|
|
|
goto Exit; |
|
|
|
@ -215,14 +215,14 @@ |
|
|
|
|
CHECK_CHAR( xadvance ) && |
|
|
|
|
CHECK_CHAR( yadvance ) ) |
|
|
|
|
{ |
|
|
|
|
sbit->width = (FT_Byte) bitmap->width; |
|
|
|
|
sbit->height = (FT_Byte) bitmap->rows; |
|
|
|
|
sbit->pitch = (FT_Char) bitmap->pitch; |
|
|
|
|
sbit->left = (FT_Char) slot->bitmap_left; |
|
|
|
|
sbit->top = (FT_Char) slot->bitmap_top; |
|
|
|
|
sbit->xadvance = (FT_Char) xadvance; |
|
|
|
|
sbit->yadvance = (FT_Char) yadvance; |
|
|
|
|
sbit->format = (FT_Byte) bitmap->pixel_mode; |
|
|
|
|
sbit->width = (FT_Byte)bitmap->width; |
|
|
|
|
sbit->height = (FT_Byte)bitmap->rows; |
|
|
|
|
sbit->pitch = (FT_Char)bitmap->pitch; |
|
|
|
|
sbit->left = (FT_Char)slot->bitmap_left; |
|
|
|
|
sbit->top = (FT_Char)slot->bitmap_top; |
|
|
|
|
sbit->xadvance = (FT_Char)xadvance; |
|
|
|
|
sbit->yadvance = (FT_Char)yadvance; |
|
|
|
|
sbit->format = (FT_Byte)bitmap->pixel_mode; |
|
|
|
|
|
|
|
|
|
/* grab the bitmap when possible - this is a hack !! */ |
|
|
|
|
if ( slot->flags & ft_glyph_own_bitmap ) |
|
|
|
@ -238,16 +238,16 @@ |
|
|
|
|
|
|
|
|
|
/* now, compute size */ |
|
|
|
|
if ( asize ) |
|
|
|
|
*asize = ABS(sbit->pitch) * sbit->height; |
|
|
|
|
*asize = ABS( sbit->pitch ) * sbit->height; |
|
|
|
|
|
|
|
|
|
} /* glyph dimensions ok */ |
|
|
|
|
|
|
|
|
|
} /* glyph loading successful */ |
|
|
|
|
|
|
|
|
|
/* ignore the errors that might have occurred -- */ |
|
|
|
|
/* we recognize unloaded glyphs with `sbit.buffer == 0' */ |
|
|
|
|
/* and 'width == 255', 'height == 0' */ |
|
|
|
|
/* */ |
|
|
|
|
/* ignore the errors that might have occurred -- */ |
|
|
|
|
/* we mark unloaded glyphs with `sbit.buffer == 0' */ |
|
|
|
|
/* and 'width == 255', 'height == 0' */ |
|
|
|
|
/* */ |
|
|
|
|
if ( error ) |
|
|
|
|
{ |
|
|
|
|
sbit->width = 255; |
|
|
|
@ -268,17 +268,18 @@ |
|
|
|
|
{ |
|
|
|
|
FT_Error error; |
|
|
|
|
|
|
|
|
|
ftc_glyph_node_init( FTC_GLYPH_NODE(snode), |
|
|
|
|
|
|
|
|
|
ftc_glyph_node_init( FTC_GLYPH_NODE( snode ), |
|
|
|
|
gquery->gindex, |
|
|
|
|
FTC_GLYPH_FAMILY(gquery->query.family) ); |
|
|
|
|
FTC_GLYPH_FAMILY( gquery->query.family ) ); |
|
|
|
|
|
|
|
|
|
error = ftc_sbit_node_load( snode, |
|
|
|
|
cache->manager, |
|
|
|
|
FTC_SBIT_FAMILY( FTC_QUERY(gquery)->family ), |
|
|
|
|
FTC_SBIT_FAMILY( FTC_QUERY( gquery )->family ), |
|
|
|
|
gquery->gindex, |
|
|
|
|
NULL ); |
|
|
|
|
if ( error ) |
|
|
|
|
ftc_glyph_node_done( FTC_GLYPH_NODE(snode), cache ); |
|
|
|
|
ftc_glyph_node_done( FTC_GLYPH_NODE( snode ), cache ); |
|
|
|
|
|
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
@ -287,7 +288,7 @@ |
|
|
|
|
FT_CALLBACK_DEF( FT_ULong ) |
|
|
|
|
ftc_sbit_node_weight( FTC_SBitNode snode ) |
|
|
|
|
{ |
|
|
|
|
FTC_GlyphNode gnode = FTC_GLYPH_NODE(snode); |
|
|
|
|
FTC_GlyphNode gnode = FTC_GLYPH_NODE( snode ); |
|
|
|
|
FT_UInt count = gnode->item_count; |
|
|
|
|
FTC_SBit sbit = snode->sbits; |
|
|
|
|
FT_Int pitch; |
|
|
|
@ -295,10 +296,10 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* the node itself */ |
|
|
|
|
size = sizeof ( *snode ); |
|
|
|
|
size = sizeof ( *snode ); |
|
|
|
|
|
|
|
|
|
/* the sbit records */ |
|
|
|
|
size += FTC_GLYPH_NODE(snode)->item_count * sizeof ( FTC_SBitRec ); |
|
|
|
|
size += FTC_GLYPH_NODE( snode )->item_count * sizeof ( FTC_SBitRec ); |
|
|
|
|
|
|
|
|
|
for ( ; count > 0; count--, sbit++ ) |
|
|
|
|
{ |
|
|
|
@ -322,25 +323,28 @@ |
|
|
|
|
FTC_SBitQuery squery, |
|
|
|
|
FTC_Cache cache ) |
|
|
|
|
{ |
|
|
|
|
FTC_GlyphQuery gquery = FTC_GLYPH_QUERY(squery); |
|
|
|
|
FTC_GlyphNode gnode = FTC_GLYPH_NODE(snode); |
|
|
|
|
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); |
|
|
|
|
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 ), |
|
|
|
|
FTC_SBIT_FAMILY( FTC_QUERY( squery )->family ), |
|
|
|
|
gindex, |
|
|
|
|
&size ); |
|
|
|
|
|
|
|
|
@ -370,6 +374,7 @@ |
|
|
|
|
FT_Error error; |
|
|
|
|
FT_Face face; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sfam->desc = squery->desc; |
|
|
|
|
|
|
|
|
|
/* we need to compute "cquery.item_total" now */ |
|
|
|
@ -378,11 +383,11 @@ |
|
|
|
|
&face ); |
|
|
|
|
if ( !error ) |
|
|
|
|
{ |
|
|
|
|
error = ftc_glyph_family_init( FTC_GLYPH_FAMILY(sfam), |
|
|
|
|
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), |
|
|
|
|
FTC_GLYPH_QUERY( squery ), |
|
|
|
|
cache ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -391,24 +396,23 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_DEF( FT_Bool ) |
|
|
|
|
ftc_sbit_family_compare( FTC_SBitFamily sfam, |
|
|
|
|
FTC_SBitQuery squery ) |
|
|
|
|
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.. */ |
|
|
|
|
/* */ |
|
|
|
|
/* 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); |
|
|
|
|
FTC_GLYPH_FAMILY_FOUND( sfam, squery ); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/***** *****/ |
|
|
|
@ -418,25 +422,24 @@ |
|
|
|
|
/*************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
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 |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -465,7 +468,8 @@ |
|
|
|
|
FTC_SBitQueryRec squery; |
|
|
|
|
FTC_SBitNode node; |
|
|
|
|
|
|
|
|
|
/* argument checks delayed to ftc_cache_lookup */ |
|
|
|
|
|
|
|
|
|
/* other argument checks delayed to ftc_cache_lookup */ |
|
|
|
|
if ( !ansbit ) |
|
|
|
|
return FTC_Err_Invalid_Argument; |
|
|
|
|
|
|
|
|
@ -477,25 +481,24 @@ |
|
|
|
|
squery.gquery.gindex = gindex; |
|
|
|
|
squery.desc = *desc; |
|
|
|
|
|
|
|
|
|
error = ftc_cache_lookup( FTC_CACHE(cache), |
|
|
|
|
FTC_QUERY(&squery), |
|
|
|
|
(FTC_Node*) &node ); |
|
|
|
|
error = ftc_cache_lookup( FTC_CACHE( cache ), |
|
|
|
|
FTC_QUERY( &squery ), |
|
|
|
|
(FTC_Node*)&node ); |
|
|
|
|
if ( !error ) |
|
|
|
|
{ |
|
|
|
|
*ansbit = node->sbits + (gindex - FTC_GLYPH_NODE(node)->item_start); |
|
|
|
|
*ansbit = node->sbits + ( gindex - FTC_GLYPH_NODE( node )->item_start ); |
|
|
|
|
|
|
|
|
|
if ( anode ) |
|
|
|
|
{ |
|
|
|
|
*anode = FTC_NODE(node); |
|
|
|
|
FTC_NODE(node)->ref_count ++; |
|
|
|
|
*anode = FTC_NODE( node ); |
|
|
|
|
FTC_NODE( node )->ref_count++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* backwards-compatibility functions */ |
|
|
|
|
/* backwards-compatibility functions */ |
|
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error ) |
|
|
|
|
FTC_SBit_Cache_New( FTC_Manager manager, |
|
|
|
@ -513,11 +516,12 @@ |
|
|
|
|
{ |
|
|
|
|
FTC_ImageDesc desc0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( !desc ) |
|
|
|
|
return FT_Err_Invalid_Argument; |
|
|
|
|
|
|
|
|
|
desc0.font = desc->font; |
|
|
|
|
desc0.type = (FT_UInt32) desc->image_type; |
|
|
|
|
desc0.type = (FT_UInt32)desc->image_type; |
|
|
|
|
|
|
|
|
|
return FTC_SBitCache_Lookup( (FTC_SBitCache)cache, |
|
|
|
|
&desc0, |
|
|
|
@ -527,5 +531,4 @@ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* END */ |
|
|
|
|