|
|
|
@ -172,6 +172,113 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static FT_Error |
|
|
|
|
bdf_interpret_style( BDF_Face bdf ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error = BDF_Err_Ok; |
|
|
|
|
FT_Face face = FT_FACE( bdf ); |
|
|
|
|
FT_Memory memory = face->memory; |
|
|
|
|
bdf_font_t* font = bdf->bdffont; |
|
|
|
|
bdf_property_t* prop; |
|
|
|
|
|
|
|
|
|
char *istr = NULL, *bstr = NULL; |
|
|
|
|
char *sstr = NULL, *astr = NULL; |
|
|
|
|
|
|
|
|
|
int parts = 0, len = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face->style_flags = 0; |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, (char *)"SLANT" ); |
|
|
|
|
if ( prop && prop->format == BDF_ATOM && |
|
|
|
|
prop->value.atom && |
|
|
|
|
( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' || |
|
|
|
|
*(prop->value.atom) == 'I' || *(prop->value.atom) == 'i' ) ) |
|
|
|
|
{ |
|
|
|
|
face->style_flags |= FT_STYLE_FLAG_ITALIC; |
|
|
|
|
istr = ( *(prop->value.atom) == 'O' || *(prop->value.atom) == 'o' ) |
|
|
|
|
? (char *)"Oblique" |
|
|
|
|
: (char *)"Italic"; |
|
|
|
|
len += ft_strlen( istr ); |
|
|
|
|
parts++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, (char *)"WEIGHT_NAME" ); |
|
|
|
|
if ( prop && prop->format == BDF_ATOM && |
|
|
|
|
prop->value.atom && |
|
|
|
|
( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) ) |
|
|
|
|
{ |
|
|
|
|
face->style_flags |= FT_STYLE_FLAG_BOLD; |
|
|
|
|
bstr = (char *)"Bold"; |
|
|
|
|
len += ft_strlen( bstr ); |
|
|
|
|
parts++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, (char *)"SETWIDTH_NAME" ); |
|
|
|
|
if ( prop && prop->format == BDF_ATOM && |
|
|
|
|
prop->value.atom && *(prop->value.atom) && |
|
|
|
|
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) ) |
|
|
|
|
{ |
|
|
|
|
sstr = (char *)(prop->value.atom); |
|
|
|
|
len += ft_strlen( sstr ); |
|
|
|
|
parts++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, (char *)"ADD_STYLE_NAME" ); |
|
|
|
|
if ( prop && prop->format == BDF_ATOM && |
|
|
|
|
prop->value.atom && *(prop->value.atom) && |
|
|
|
|
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) ) |
|
|
|
|
{ |
|
|
|
|
astr = (char *)(prop->value.atom); |
|
|
|
|
len += ft_strlen( astr ); |
|
|
|
|
parts++; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( !parts || !len ) |
|
|
|
|
face->style_name = (char *)"Regular"; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
char *style, *s;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( FT_ALLOC( style, len + parts ) ) |
|
|
|
|
return error; |
|
|
|
|
|
|
|
|
|
s = style; |
|
|
|
|
|
|
|
|
|
if ( astr ) |
|
|
|
|
{ |
|
|
|
|
ft_strcpy( s, astr); |
|
|
|
|
s += ft_strlen( astr ); |
|
|
|
|
*(s++) = ' '; |
|
|
|
|
} |
|
|
|
|
if ( bstr ) |
|
|
|
|
{ |
|
|
|
|
ft_strcpy( s, bstr ); |
|
|
|
|
s += ft_strlen( bstr ); |
|
|
|
|
*(s++) = ' '; |
|
|
|
|
} |
|
|
|
|
if ( istr ) |
|
|
|
|
{ |
|
|
|
|
ft_strcpy( s, istr ); |
|
|
|
|
s += ft_strlen( istr ); |
|
|
|
|
*(s++) = ' '; |
|
|
|
|
} |
|
|
|
|
if ( sstr ) |
|
|
|
|
{ |
|
|
|
|
ft_strcpy( s, sstr ); |
|
|
|
|
s += ft_strlen( sstr ); |
|
|
|
|
*(s++) = ' '; |
|
|
|
|
} |
|
|
|
|
*(--s) = '\0'; /* overwrite last ' ', terminate the string */ |
|
|
|
|
|
|
|
|
|
face->style_name = style; /* allocated string */ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FT_CALLBACK_DEF( FT_Error ) |
|
|
|
|
BDF_Face_Done( BDF_Face face ) |
|
|
|
|
{ |
|
|
|
@ -252,39 +359,17 @@ THE SOFTWARE. |
|
|
|
|
FT_FACE_FLAG_FAST_GLYPHS; |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, "SPACING" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop->format == BDF_ATOM ) |
|
|
|
|
if ( prop->value.atom != NULL ) |
|
|
|
|
if ( ( *(prop->value.atom) == 'M' ) || |
|
|
|
|
( *(prop->value.atom) == 'm' ) || |
|
|
|
|
( *(prop->value.atom) == 'C' ) || |
|
|
|
|
( *(prop->value.atom) == 'c' ) ) |
|
|
|
|
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; |
|
|
|
|
if ( prop && prop->format == BDF_ATOM && |
|
|
|
|
prop->value.atom && |
|
|
|
|
( *(prop->value.atom) == 'M' || *(prop->value.atom) == 'm' || |
|
|
|
|
*(prop->value.atom) == 'C' || *(prop->value.atom) == 'c' ) ) |
|
|
|
|
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; |
|
|
|
|
|
|
|
|
|
/* FZ XXX: TO DO: FT_FACE_FLAGS_VERTICAL */ |
|
|
|
|
/* FZ XXX: I need a font to implement this */ |
|
|
|
|
|
|
|
|
|
root->style_flags = 0; |
|
|
|
|
prop = bdf_get_font_property( font, "SLANT" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop->format == BDF_ATOM ) |
|
|
|
|
if ( prop->value.atom != NULL ) |
|
|
|
|
if ( ( *(prop->value.atom) == 'O' ) || |
|
|
|
|
( *(prop->value.atom) == 'o' ) || |
|
|
|
|
( *(prop->value.atom) == 'I' ) || |
|
|
|
|
( *(prop->value.atom) == 'i' ) ) |
|
|
|
|
root->style_flags |= FT_STYLE_FLAG_ITALIC; |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, "WEIGHT_NAME" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop->format == BDF_ATOM ) |
|
|
|
|
if ( prop->value.atom != NULL ) |
|
|
|
|
if ( ( *(prop->value.atom) == 'B' ) || |
|
|
|
|
( *(prop->value.atom) == 'b' ) ) |
|
|
|
|
root->style_flags |= FT_STYLE_FLAG_BOLD; |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, "FAMILY_NAME" ); |
|
|
|
|
if ( ( prop != NULL ) && ( prop->value.atom != NULL ) ) |
|
|
|
|
if ( prop && prop->value.atom ) |
|
|
|
|
{ |
|
|
|
|
int l = ft_strlen( prop->value.atom ) + 1; |
|
|
|
|
|
|
|
|
@ -296,16 +381,8 @@ THE SOFTWARE. |
|
|
|
|
else |
|
|
|
|
root->family_name = 0; |
|
|
|
|
|
|
|
|
|
root->style_name = (char *)"Regular"; |
|
|
|
|
if ( root->style_flags & FT_STYLE_FLAG_BOLD ) |
|
|
|
|
{ |
|
|
|
|
if ( root->style_flags & FT_STYLE_FLAG_ITALIC ) |
|
|
|
|
root->style_name = (char *)"Bold Italic"; |
|
|
|
|
else |
|
|
|
|
root->style_name = (char *)"Bold"; |
|
|
|
|
} |
|
|
|
|
else if ( root->style_flags & FT_STYLE_FLAG_ITALIC ) |
|
|
|
|
root->style_name = (char *)"Italic"; |
|
|
|
|
if ( ( error = bdf_interpret_style( face ) ) ) |
|
|
|
|
goto Exit; |
|
|
|
|
|
|
|
|
|
root->num_glyphs = font->glyphs_size; /* unencoded included */ |
|
|
|
|
|
|
|
|
@ -320,26 +397,26 @@ THE SOFTWARE. |
|
|
|
|
FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) ); |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, "PIXEL_SIZE" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop ) |
|
|
|
|
bsize->height = (FT_Short)prop->value.int32; |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, "AVERAGE_WIDTH" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop ) |
|
|
|
|
bsize->width = (FT_Short)( ( prop->value.int32 + 5 ) / 10 ); |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, "POINT_SIZE" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop ) |
|
|
|
|
/* convert from 722.7 decipoints to 72 points per inch */ |
|
|
|
|
bsize->size = |
|
|
|
|
(FT_Pos)( ( prop->value.int32 * 64 * 7200 + 36135L ) / 72270L ); |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, "RESOLUTION_X" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop ) |
|
|
|
|
bsize->x_ppem = |
|
|
|
|
(FT_Pos)( ( prop->value.int32 * bsize->size + 36 ) / 72 ); |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( font, "RESOLUTION_Y" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop ) |
|
|
|
|
bsize->y_ppem = |
|
|
|
|
(FT_Pos)( ( prop->value.int32 * bsize->size + 36 ) / 72 ); |
|
|
|
|
|
|
|
|
@ -381,12 +458,12 @@ THE SOFTWARE. |
|
|
|
|
bdf_get_font_property( font, "CHARSET_REGISTRY" ); |
|
|
|
|
charset_encoding = |
|
|
|
|
bdf_get_font_property( font, "CHARSET_ENCODING" ); |
|
|
|
|
if ( ( charset_registry != NULL ) && ( charset_encoding != NULL ) ) |
|
|
|
|
if ( charset_registry && charset_encoding ) |
|
|
|
|
{ |
|
|
|
|
if ( ( charset_registry->format == BDF_ATOM ) && |
|
|
|
|
( charset_encoding->format == BDF_ATOM ) && |
|
|
|
|
( charset_registry->value.atom != NULL ) && |
|
|
|
|
( charset_encoding->value.atom != NULL ) ) |
|
|
|
|
if ( charset_registry->format == BDF_ATOM && |
|
|
|
|
charset_encoding->format == BDF_ATOM && |
|
|
|
|
charset_registry->value.atom && |
|
|
|
|
charset_encoding->value.atom ) |
|
|
|
|
{ |
|
|
|
|
const char* s; |
|
|
|
|
|
|
|
|
@ -669,7 +746,7 @@ THE SOFTWARE. |
|
|
|
|
FT_ASSERT( face && face->bdffont ); |
|
|
|
|
|
|
|
|
|
prop = bdf_get_font_property( face->bdffont, prop_name ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop ) |
|
|
|
|
{ |
|
|
|
|
switch ( prop->format ) |
|
|
|
|
{ |
|
|
|
|