* docs/CHANGES: Updated.

Handle SETWIDTH_NAME and ADD_STYLE_NAME properties for BDF and PCF
fonts.

* src/bdf/bdfdrivr.c (bdf_interpret_style): New auxiliary function.
(BDF_Face_Init): Don't handle style properties but call
bdf_interpret_style.

* src/pcf/pcfread.c (pcf_interpret_style): New auxiliary function.
(pcf_load_font): Don't handle style properties but call
pcf_interpret_style.
This commit is contained in:
Werner Lemberg 2003-11-13 10:19:27 +00:00
parent d88d5419ad
commit 51ecb69a88
4 changed files with 285 additions and 104 deletions

View File

@ -1,3 +1,20 @@
2003-11-11 Werner Lemberg <wl@gnu.org>
* docs/CHANGES: Updated.
2003-11-11 John A. Boyd Jr. <jaboydjr@netwalk.com>
Handle SETWIDTH_NAME and ADD_STYLE_NAME properties for BDF and PCF
fonts.
* src/bdf/bdfdrivr.c (bdf_interpret_style): New auxiliary function.
(BDF_Face_Init): Don't handle style properties but call
bdf_interpret_style.
* src/pcf/pcfread.c (pcf_interpret_style): New auxiliary function.
(pcf_load_font): Don't handle style properties but call
pcf_interpret_style.
2003-11-07 Werner Lemberg <wl@gnu.org>

View File

@ -1,4 +1,18 @@
LATEST CHANGES BETWEEN 2.1.8 and 2.1.7
I. IMPORTANT BUG FIXES
II. IMPORTANT CHANGES
- Both PCF and BDF drivers now handle the SETWIDTH_NAME and
ADD_STYLE_NAME properties. Values are appended to
face->style_name; example: `Bold SemiCondensed'.
======================================================================
LATEST CHANGES BETWEEN 2.1.7 and 2.1.6
I. IMPORTANT BUG FIXES

View File

@ -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 )
{

View File

@ -862,6 +862,111 @@ THE SOFTWARE.
}
static FT_Error
pcf_interpret_style( PCF_Face pcf )
{
FT_Error error = PCF_Err_Ok;
FT_Face face = FT_FACE( pcf );
FT_Memory memory = face->memory;
PCF_Property prop;
char *istr = NULL, *bstr = NULL;
char *sstr = NULL, *astr = NULL;
int parts = 0, len = 0;
face->style_flags = 0;
prop = pcf_find_property( pcf, "SLANT" );
if ( prop && prop->isString &&
( *(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 = pcf_find_property( pcf, "WEIGHT_NAME" );
if ( prop && prop->isString &&
( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
{
face->style_flags |= FT_STYLE_FLAG_BOLD;
bstr = (char *)"Bold";
len += ft_strlen( bstr );
parts++;
}
prop = pcf_find_property( pcf, "SETWIDTH_NAME" );
if ( prop && prop->isString &&
*(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
{
sstr = (char *)(prop->value.atom);
len += ft_strlen( sstr );
parts++;
}
prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );
if ( prop && prop->isString &&
*(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_LOCAL_DEF( FT_Error )
pcf_load_font( FT_Stream stream,
PCF_Face face )
@ -930,49 +1035,21 @@ THE SOFTWARE.
if ( face->accel.constantWidth )
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH;
root->style_flags = 0;
prop = pcf_find_property( face, "SLANT" );
if ( prop != NULL )
if ( prop->isString )
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 = pcf_find_property( face, "WEIGHT_NAME" );
if ( prop != NULL )
if ( prop->isString )
if ( ( *(prop->value.atom) == 'B' ) ||
( *(prop->value.atom) == 'b' ) )
root->style_flags |= FT_STYLE_FLAG_BOLD;
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 = pcf_interpret_style( face ) ) )
goto Exit;
prop = pcf_find_property( face, "FAMILY_NAME" );
if ( prop != NULL )
if ( prop && prop->isString )
{
if ( prop->isString )
{
int l = ft_strlen( prop->value.atom ) + 1;
int l = ft_strlen( prop->value.atom ) + 1;
if ( FT_NEW_ARRAY( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, prop->value.atom );
}
if ( FT_NEW_ARRAY( root->family_name, l ) )
goto Exit;
ft_strcpy( root->family_name, prop->value.atom );
}
else
root->family_name = 0;
root->family_name = NULL;
/* Note: We shift all glyph indices by +1 since we must
* respect the convention that glyph 0 always corresponds
@ -993,26 +1070,26 @@ THE SOFTWARE.
FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
prop = pcf_find_property( face, "PIXEL_SIZE" );
if ( prop != NULL )
if ( prop )
bsize->height = (FT_Short)prop->value.integer;
prop = pcf_find_property( face, "AVERAGE_WIDTH" );
if ( prop != NULL )
if ( prop )
bsize->width = (FT_Short)( ( prop->value.integer + 5 ) / 10 );
prop = pcf_find_property( face, "POINT_SIZE" );
if ( prop != NULL )
if ( prop )
/* convert from 722,7 decipoints to 72 points per inch */
bsize->size =
(FT_Pos)( ( prop->value.integer * 64 * 7200 + 36135L ) / 72270L );
prop = pcf_find_property( face, "RESOLUTION_X" );
if ( prop != NULL )
if ( prop )
bsize->x_ppem =
(FT_Pos)( ( prop->value.integer * bsize->size + 36 ) / 72 );
prop = pcf_find_property( face, "RESOLUTION_Y" );
if ( prop != NULL )
if ( prop )
bsize->y_ppem =
(FT_Pos)( ( prop->value.integer * bsize->size + 36 ) / 72 );
@ -1031,23 +1108,19 @@ THE SOFTWARE.
charset_registry = pcf_find_property( face, "CHARSET_REGISTRY" );
charset_encoding = pcf_find_property( face, "CHARSET_ENCODING" );
if ( ( charset_registry != NULL ) &&
( charset_encoding != NULL ) )
if ( charset_registry && charset_registry->isString &&
charset_encoding && charset_encoding->isString )
{
if ( ( charset_registry->isString ) &&
( charset_encoding->isString ) )
{
if ( FT_NEW_ARRAY( face->charset_encoding,
ft_strlen( charset_encoding->value.atom ) + 1 ) )
goto Exit;
if ( FT_NEW_ARRAY( face->charset_encoding,
ft_strlen( charset_encoding->value.atom ) + 1 ) )
goto Exit;
if ( FT_NEW_ARRAY( face->charset_registry,
ft_strlen( charset_registry->value.atom ) + 1 ) )
goto Exit;
if ( FT_NEW_ARRAY( face->charset_registry,
ft_strlen( charset_registry->value.atom ) + 1 ) )
goto Exit;
ft_strcpy( face->charset_registry, charset_registry->value.atom );
ft_strcpy( face->charset_encoding, charset_encoding->value.atom );
}
ft_strcpy( face->charset_registry, charset_registry->value.atom );
ft_strcpy( face->charset_encoding, charset_encoding->value.atom );
}
}
}