|
|
|
@ -1,9 +1,9 @@ |
|
|
|
|
/* pcfread.c
|
|
|
|
|
/* pcfread.c
|
|
|
|
|
|
|
|
|
|
FreeType font driver for pcf fonts |
|
|
|
|
|
|
|
|
|
Copyright 2000 by
|
|
|
|
|
Francesco Zappa Nardelli
|
|
|
|
|
Copyright 2000 by |
|
|
|
|
Francesco Zappa Nardelli |
|
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
|
|
|
|
of this software and associated documentation files (the "Software"), to deal |
|
|
|
@ -38,6 +38,7 @@ THE SOFTWARE. |
|
|
|
|
|
|
|
|
|
#include <string.h> /* strlen(), strcpy() */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/ |
|
|
|
|
/* */ |
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
|
|
|
@ -57,7 +58,7 @@ THE SOFTWARE. |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
static |
|
|
|
|
const FT_Frame_Field pcf_toc_header[] = |
|
|
|
|
{ |
|
|
|
|
#undef FT_STRUCTURE |
|
|
|
@ -70,7 +71,7 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
static |
|
|
|
|
const FT_Frame_Field pcf_table_header[] = |
|
|
|
|
{ |
|
|
|
|
#undef FT_STRUCTURE |
|
|
|
@ -85,9 +86,9 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
FT_Error pcf_read_TOC( FT_Stream stream,
|
|
|
|
|
PCF_Face face ) |
|
|
|
|
static FT_Error |
|
|
|
|
pcf_read_TOC( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error; |
|
|
|
|
PCF_Toc toc = &face->toc; |
|
|
|
@ -100,7 +101,7 @@ THE SOFTWARE. |
|
|
|
|
if ( FILE_Seek ( 0 ) || |
|
|
|
|
READ_Fields ( pcf_toc_header, toc ) ) |
|
|
|
|
return PCF_Err_Cannot_Open_Resource; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( toc->version != PCF_FILE_VERSION ) |
|
|
|
|
return PCF_Err_Invalid_File_Format; |
|
|
|
|
|
|
|
|
@ -133,7 +134,7 @@ THE SOFTWARE. |
|
|
|
|
"size=0x%06lX (%8ld) offset=0x%04lX\n", |
|
|
|
|
i, name, |
|
|
|
|
tables[i].format, |
|
|
|
|
tables[i].size, tables[i].size,
|
|
|
|
|
tables[i].size, tables[i].size, |
|
|
|
|
tables[i].offset )); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -148,7 +149,7 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
static |
|
|
|
|
const FT_Frame_Field pcf_metric_header[] = |
|
|
|
|
{ |
|
|
|
|
#undef FT_STRUCTURE |
|
|
|
@ -165,7 +166,7 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
static |
|
|
|
|
const FT_Frame_Field pcf_metric_msb_header[] = |
|
|
|
|
{ |
|
|
|
|
#undef FT_STRUCTURE |
|
|
|
@ -182,7 +183,7 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
static |
|
|
|
|
const FT_Frame_Field pcf_compressed_metric_header[] = |
|
|
|
|
{ |
|
|
|
|
#undef FT_STRUCTURE |
|
|
|
@ -198,28 +199,28 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
FT_Error pcf_parse_metric( FT_Stream stream,
|
|
|
|
|
const FT_Frame_Field* header,
|
|
|
|
|
PCF_Metric metric ) |
|
|
|
|
static FT_Error |
|
|
|
|
pcf_parse_metric( FT_Stream stream, |
|
|
|
|
const FT_Frame_Field* header, |
|
|
|
|
PCF_Metric metric ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error = PCF_Err_Ok; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( READ_Fields( header, metric ) ) |
|
|
|
|
return error; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return PCF_Err_Ok; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
FT_Error pcf_parse_compressed_metric( FT_Stream stream, |
|
|
|
|
PCF_Metric metric ) |
|
|
|
|
static FT_Error |
|
|
|
|
pcf_parse_compressed_metric( FT_Stream stream, |
|
|
|
|
PCF_Metric metric ) |
|
|
|
|
{ |
|
|
|
|
PCF_Compressed_MetricRec compr_metric; |
|
|
|
|
FT_Error error = PCF_Err_Ok; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( READ_Fields( pcf_compressed_metric_header, &compr_metric ) ) |
|
|
|
|
return error; |
|
|
|
@ -235,15 +236,15 @@ THE SOFTWARE. |
|
|
|
|
metric->descent = |
|
|
|
|
(FT_Short)( compr_metric.descent - 0x80 ); |
|
|
|
|
metric->attributes = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return PCF_Err_Ok; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
FT_Error pcf_get_metric( FT_Stream stream, |
|
|
|
|
FT_ULong format, |
|
|
|
|
PCF_Metric metric ) |
|
|
|
|
static FT_Error |
|
|
|
|
pcf_get_metric( FT_Stream stream, |
|
|
|
|
FT_ULong format, |
|
|
|
|
PCF_Metric metric ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error = PCF_Err_Ok; |
|
|
|
|
|
|
|
|
@ -260,15 +261,15 @@ THE SOFTWARE. |
|
|
|
|
|
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
FT_Error pcfSeekToType( FT_Stream stream, |
|
|
|
|
PCF_Table tables, |
|
|
|
|
int ntables,
|
|
|
|
|
FT_ULong type, |
|
|
|
|
FT_ULong* formatp, |
|
|
|
|
FT_ULong* sizep ) |
|
|
|
|
|
|
|
|
|
static FT_Error |
|
|
|
|
pcfSeekToType( FT_Stream stream, |
|
|
|
|
PCF_Table tables, |
|
|
|
|
int ntables, |
|
|
|
|
FT_ULong type, |
|
|
|
|
FT_ULong* formatp, |
|
|
|
|
FT_ULong* sizep ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error; |
|
|
|
|
int i; |
|
|
|
@ -290,13 +291,13 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
FT_Bool pcfHasType( PCF_Table tables, |
|
|
|
|
int ntables, |
|
|
|
|
FT_ULong type ) |
|
|
|
|
static FT_Bool |
|
|
|
|
pcfHasType( PCF_Table tables, |
|
|
|
|
int ntables, |
|
|
|
|
FT_ULong type ) |
|
|
|
|
{ |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0; i < ntables; i++ ) |
|
|
|
|
if ( tables[i].type == type ) |
|
|
|
@ -306,7 +307,7 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
static |
|
|
|
|
const FT_Frame_Field pcf_property_header[] = |
|
|
|
|
{ |
|
|
|
|
#undef FT_STRUCTURE |
|
|
|
@ -320,7 +321,7 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
static |
|
|
|
|
const FT_Frame_Field pcf_property_msb_header[] = |
|
|
|
|
{ |
|
|
|
|
#undef FT_STRUCTURE |
|
|
|
@ -334,9 +335,9 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
PCF_Property find_property( PCF_Face face, |
|
|
|
|
const FT_String* prop ) |
|
|
|
|
static PCF_Property |
|
|
|
|
find_property( PCF_Face face, |
|
|
|
|
const FT_String* prop ) |
|
|
|
|
{ |
|
|
|
|
PCF_Property properties = face->properties; |
|
|
|
|
FT_Bool found = 0; |
|
|
|
@ -348,7 +349,7 @@ THE SOFTWARE. |
|
|
|
|
if ( !strcmp( properties[i].name, prop ) ) |
|
|
|
|
found = 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( found ) |
|
|
|
|
return properties + i - 1; |
|
|
|
|
else |
|
|
|
@ -356,9 +357,9 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
FT_Error pcf_get_properties( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
static FT_Error |
|
|
|
|
pcf_get_properties( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
{ |
|
|
|
|
PCF_ParseProperty props = 0; |
|
|
|
|
PCF_Property properties = 0; |
|
|
|
@ -368,10 +369,10 @@ THE SOFTWARE. |
|
|
|
|
FT_Memory memory = FT_FACE(face)->memory; |
|
|
|
|
FT_ULong string_size; |
|
|
|
|
FT_String* strings = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error = pcfSeekToType( stream, |
|
|
|
|
face->toc.tables,
|
|
|
|
|
face->toc.tables, |
|
|
|
|
face->toc.count, |
|
|
|
|
PCF_PROPERTIES, |
|
|
|
|
&format, |
|
|
|
@ -395,7 +396,7 @@ THE SOFTWARE. |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
FT_TRACE4(( "get_prop: nprop = %d\n", nprops )); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( ALLOC( props, nprops * sizeof ( PCF_ParsePropertyRec ) ) ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
@ -430,50 +431,50 @@ THE SOFTWARE. |
|
|
|
|
(void)READ_ULongLE( string_size ); |
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FT_TRACE4(( "get_prop: string_size = %ld\n", string_size )); |
|
|
|
|
|
|
|
|
|
if ( ALLOC( strings, string_size * sizeof ( char ) ) ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error = FT_Read_Stream( stream, (FT_Byte*)strings, string_size ); |
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
if ( ALLOC( properties, nprops * sizeof ( PCF_PropertyRec ) ) ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0; i < nprops; i++ ) |
|
|
|
|
{ |
|
|
|
|
/* XXX: make atom */
|
|
|
|
|
if ( ALLOC( properties[i].name,
|
|
|
|
|
/* XXX: make atom */ |
|
|
|
|
if ( ALLOC( properties[i].name, |
|
|
|
|
( strlen( strings + props[i].name ) + 1 ) * |
|
|
|
|
sizeof ( char ) ) ) |
|
|
|
|
goto Bail; |
|
|
|
|
strcpy( properties[i].name,strings + props[i].name ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
properties[i].isString = props[i].isString; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( props[i].isString ) |
|
|
|
|
{ |
|
|
|
|
if ( ALLOC( properties[i].value.atom,
|
|
|
|
|
( strlen( strings + props[i].value ) + 1 ) *
|
|
|
|
|
if ( ALLOC( properties[i].value.atom, |
|
|
|
|
( strlen( strings + props[i].value ) + 1 ) * |
|
|
|
|
sizeof ( char ) ) ) |
|
|
|
|
goto Bail; |
|
|
|
|
strcpy( properties[i].value.atom, strings + props[i].value ); |
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
properties[i].value.integer = props[i].value; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face->properties = properties; |
|
|
|
|
face->nprops = nprops; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FREE( props ); |
|
|
|
|
FREE( strings ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return PCF_Err_Ok; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bail: |
|
|
|
|
FREE( props ); |
|
|
|
|
FREE( strings ); |
|
|
|
@ -482,10 +483,10 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
FT_Error pcf_get_metrics( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
{
|
|
|
|
|
static FT_Error |
|
|
|
|
pcf_get_metrics( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error = PCF_Err_Ok; |
|
|
|
|
FT_Memory memory = FT_FACE(face)->memory; |
|
|
|
|
FT_ULong format = 0; |
|
|
|
@ -496,12 +497,12 @@ THE SOFTWARE. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error = pcfSeekToType( stream, |
|
|
|
|
face->toc.tables,
|
|
|
|
|
face->toc.tables, |
|
|
|
|
face->toc.count, |
|
|
|
|
PCF_METRICS, |
|
|
|
|
&format, |
|
|
|
|
&size ); |
|
|
|
|
if ( error )
|
|
|
|
|
if ( error ) |
|
|
|
|
return error; |
|
|
|
|
|
|
|
|
|
error = READ_ULongLE( format ); |
|
|
|
@ -526,7 +527,7 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
if ( error || nmetrics == -1 ) |
|
|
|
|
return PCF_Err_Invalid_File_Format; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face->nmetrics = nmetrics; |
|
|
|
|
|
|
|
|
|
if ( ALLOC( face->metrics, nmetrics * sizeof ( PCF_MetricRec ) ) ) |
|
|
|
@ -536,7 +537,7 @@ THE SOFTWARE. |
|
|
|
|
for ( i = 0; i < nmetrics; i++ ) |
|
|
|
|
{ |
|
|
|
|
pcf_get_metric( stream, format, metrics + i ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
metrics[i].bits = 0; |
|
|
|
|
|
|
|
|
|
FT_TRACE4(( "%d : width=%d, " |
|
|
|
@ -548,7 +549,7 @@ THE SOFTWARE. |
|
|
|
|
( metrics + i )->ascent, |
|
|
|
|
( metrics + i )->descent, |
|
|
|
|
( metrics + i )->attributes )); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( error ) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -559,9 +560,9 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
FT_Error pcf_get_bitmaps( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
static FT_Error |
|
|
|
|
pcf_get_bitmaps( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error = PCF_Err_Ok; |
|
|
|
|
FT_Memory memory = FT_FACE(face)->memory; |
|
|
|
@ -573,7 +574,7 @@ THE SOFTWARE. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error = pcfSeekToType( stream, |
|
|
|
|
face->toc.tables,
|
|
|
|
|
face->toc.tables, |
|
|
|
|
face->toc.count, |
|
|
|
|
PCF_BITMAPS, |
|
|
|
|
&format, |
|
|
|
@ -587,7 +588,7 @@ THE SOFTWARE. |
|
|
|
|
format = GET_ULongLE(); |
|
|
|
|
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) |
|
|
|
|
return PCF_Err_Invalid_File_Format; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( PCF_BYTE_ORDER( format ) == MSBFirst ) |
|
|
|
|
nbitmaps = GET_ULong(); |
|
|
|
|
else |
|
|
|
@ -602,7 +603,7 @@ THE SOFTWARE. |
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
for ( i = 0; i < nbitmaps; i++ ) |
|
|
|
|
{
|
|
|
|
|
{ |
|
|
|
|
if ( PCF_BYTE_ORDER( format ) == MSBFirst ) |
|
|
|
|
(void)READ_Long( offsets[i] ); |
|
|
|
|
else |
|
|
|
@ -616,9 +617,9 @@ THE SOFTWARE. |
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
for ( i = 0; i < GLYPHPADOPTIONS; i++ ) |
|
|
|
|
{
|
|
|
|
|
{ |
|
|
|
|
if ( PCF_BYTE_ORDER( format ) == MSBFirst ) |
|
|
|
|
(void)READ_Long( bitmapSizes[i] );
|
|
|
|
|
(void)READ_Long( bitmapSizes[i] ); |
|
|
|
|
else |
|
|
|
|
(void)READ_LongLE( bitmapSizes[i] ); |
|
|
|
|
if ( error ) |
|
|
|
@ -635,10 +636,10 @@ THE SOFTWARE. |
|
|
|
|
FT_TRACE4(( "bitmap size = %d\n", sizebitmaps )); |
|
|
|
|
|
|
|
|
|
for ( i = 0; i < nbitmaps; i++ ) |
|
|
|
|
face->metrics[i].bits = stream->pos + offsets[i];
|
|
|
|
|
|
|
|
|
|
face->metrics[i].bits = stream->pos + offsets[i]; |
|
|
|
|
|
|
|
|
|
face->bitmapsFormat = format; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FREE ( offsets ); |
|
|
|
|
return error; |
|
|
|
|
|
|
|
|
@ -649,9 +650,9 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static |
|
|
|
|
FT_Error pcf_get_encodings( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
static FT_Error |
|
|
|
|
pcf_get_encodings( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error = PCF_Err_Ok; |
|
|
|
|
FT_Memory memory = FT_FACE(face)->memory; |
|
|
|
@ -664,7 +665,7 @@ THE SOFTWARE. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error = pcfSeekToType( stream, |
|
|
|
|
face->toc.tables,
|
|
|
|
|
face->toc.tables, |
|
|
|
|
face->toc.count, |
|
|
|
|
PCF_BDF_ENCODINGS, |
|
|
|
|
&format, |
|
|
|
@ -678,7 +679,7 @@ THE SOFTWARE. |
|
|
|
|
format = GET_ULongLE(); |
|
|
|
|
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) ) |
|
|
|
|
return PCF_Err_Invalid_File_Format; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( PCF_BYTE_ORDER( format ) == MSBFirst ) |
|
|
|
|
{ |
|
|
|
|
firstCol = GET_Short(); |
|
|
|
@ -705,18 +706,18 @@ THE SOFTWARE. |
|
|
|
|
|
|
|
|
|
if ( ALLOC( tmpEncoding, nencoding * sizeof ( PCF_EncodingRec ) ) ) |
|
|
|
|
return PCF_Err_Out_Of_Memory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
error = FT_Access_Frame( stream, 2 * nencoding ); |
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0, j = 0 ; i < nencoding; i++ ) |
|
|
|
|
{ |
|
|
|
|
if ( PCF_BYTE_ORDER( format ) == MSBFirst ) |
|
|
|
|
encodingOffset = GET_Short();
|
|
|
|
|
encodingOffset = GET_Short(); |
|
|
|
|
else |
|
|
|
|
encodingOffset = GET_ShortLE(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( encodingOffset != (signed short)0xFFFF ) |
|
|
|
|
{ |
|
|
|
|
tmpEncoding[j].enc = ( ( ( i / ( lastCol - firstCol + 1 ) ) + |
|
|
|
@ -755,7 +756,7 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
static |
|
|
|
|
const FT_Frame_Field pcf_accel_header[] = |
|
|
|
|
{ |
|
|
|
|
#undef FT_STRUCTURE |
|
|
|
@ -777,7 +778,7 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
static |
|
|
|
|
const FT_Frame_Field pcf_accel_msb_header[] = |
|
|
|
|
{ |
|
|
|
|
#undef FT_STRUCTURE |
|
|
|
@ -799,10 +800,10 @@ THE SOFTWARE. |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
FT_Error pcf_get_accel( FT_Stream stream, |
|
|
|
|
PCF_Face face, |
|
|
|
|
FT_ULong type ) |
|
|
|
|
static FT_Error |
|
|
|
|
pcf_get_accel( FT_Stream stream, |
|
|
|
|
PCF_Face face, |
|
|
|
|
FT_ULong type ) |
|
|
|
|
{ |
|
|
|
|
FT_ULong format, size; |
|
|
|
|
FT_Error error = PCF_Err_Ok; |
|
|
|
@ -811,18 +812,18 @@ THE SOFTWARE. |
|
|
|
|
|
|
|
|
|
error = pcfSeekToType( stream, |
|
|
|
|
face->toc.tables, |
|
|
|
|
face->toc.count,
|
|
|
|
|
face->toc.count, |
|
|
|
|
type, |
|
|
|
|
&format, |
|
|
|
|
&size ); |
|
|
|
|
if ( error )
|
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
error = READ_ULongLE( format ); |
|
|
|
|
if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) && |
|
|
|
|
!PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( PCF_BYTE_ORDER( format ) == MSBFirst ) |
|
|
|
|
{ |
|
|
|
|
if ( READ_Fields( pcf_accel_msb_header, accel ) ) |
|
|
|
@ -835,12 +836,12 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
error = pcf_get_metric( stream, format, &(accel->minbounds) ); |
|
|
|
|
if ( error )
|
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
error = pcf_get_metric( stream, format, &(accel->maxbounds) ); |
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) ) |
|
|
|
|
{ |
|
|
|
|
error = pcf_get_metric( stream, format, &(accel->ink_minbounds) ); |
|
|
|
@ -849,22 +850,22 @@ THE SOFTWARE. |
|
|
|
|
error = pcf_get_metric( stream, format, &(accel->ink_maxbounds) ); |
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
accel->ink_minbounds = accel->minbounds; /* I'm not sure about this */ |
|
|
|
|
accel->ink_maxbounds = accel->maxbounds; |
|
|
|
|
} |
|
|
|
|
return error; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bail: |
|
|
|
|
return error; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FT_LOCAL_DEF |
|
|
|
|
FT_Error pcf_load_font( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
FT_LOCAL_DEF FT_Error |
|
|
|
|
pcf_load_font( FT_Stream stream, |
|
|
|
|
PCF_Face face ) |
|
|
|
|
{ |
|
|
|
|
FT_Error error = PCF_Err_Ok; |
|
|
|
|
FT_Memory memory = FT_FACE(face)->memory; |
|
|
|
@ -878,18 +879,18 @@ THE SOFTWARE. |
|
|
|
|
error = pcf_get_properties( stream, face ); |
|
|
|
|
if ( error ) |
|
|
|
|
return error;; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Use the old accelerators if no BDF accelerators are in the file. */ |
|
|
|
|
hasBDFAccelerators = pcfHasType( face->toc.tables, |
|
|
|
|
face->toc.count,
|
|
|
|
|
face->toc.count, |
|
|
|
|
PCF_BDF_ACCELERATORS ); |
|
|
|
|
if ( !hasBDFAccelerators ) |
|
|
|
|
{ |
|
|
|
|
error = pcf_get_accel( stream, face, PCF_ACCELERATORS ); |
|
|
|
|
if ( error )
|
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* metrics */ |
|
|
|
|
error = pcf_get_metrics( stream, face ); |
|
|
|
|
if ( error ) |
|
|
|
@ -904,13 +905,13 @@ THE SOFTWARE. |
|
|
|
|
error = pcf_get_encodings( stream, face ); |
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* BDF style accelerators (i.e. bounds based on encoded glyphs) */ |
|
|
|
|
if ( hasBDFAccelerators ) |
|
|
|
|
{ |
|
|
|
|
error = pcf_get_accel( stream, face, PCF_BDF_ACCELERATORS ); |
|
|
|
|
if ( error ) |
|
|
|
|
goto Bail;
|
|
|
|
|
goto Bail; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* XXX: TO DO: inkmetrics and glyph_names are missing */ |
|
|
|
@ -926,20 +927,20 @@ THE SOFTWARE. |
|
|
|
|
root->face_flags = FT_FACE_FLAG_FIXED_SIZES | |
|
|
|
|
FT_FACE_FLAG_HORIZONTAL | |
|
|
|
|
FT_FACE_FLAG_FAST_GLYPHS; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( face->accel.constantWidth ) |
|
|
|
|
root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; |
|
|
|
|
|
|
|
|
|
root->style_flags = 0; |
|
|
|
|
prop = find_property( face, "SLANT" ); |
|
|
|
|
if ( prop != NULL )
|
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop->isString ) |
|
|
|
|
if ( ( *(prop->value.atom) == 'O' ) || |
|
|
|
|
( *(prop->value.atom) == 'I' ) ) |
|
|
|
|
root->style_flags |= FT_STYLE_FLAG_ITALIC; |
|
|
|
|
|
|
|
|
|
prop = find_property( face, "WEIGHT_NAME" ); |
|
|
|
|
if ( prop != NULL )
|
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
if ( prop->isString ) |
|
|
|
|
if ( *(prop->value.atom) == 'B' ) |
|
|
|
|
root->style_flags |= FT_STYLE_FLAG_BOLD; |
|
|
|
@ -954,7 +955,7 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
else if ( root->style_flags & FT_STYLE_FLAG_ITALIC ) |
|
|
|
|
root->style_name = (char *)"Italic"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prop = find_property( face, "FAMILY_NAME" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
{ |
|
|
|
@ -972,11 +973,11 @@ THE SOFTWARE. |
|
|
|
|
root->family_name = 0; |
|
|
|
|
|
|
|
|
|
root->num_glyphs = face->nmetrics; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
root->num_fixed_sizes = 1; |
|
|
|
|
if ( ALLOC_ARRAY( root->available_sizes, 1, FT_Bitmap_Size ) ) |
|
|
|
|
goto Bail; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prop = find_property( face, "PIXEL_SIZE" ); |
|
|
|
|
if ( prop != NULL ) |
|
|
|
|
{ |
|
|
|
@ -998,9 +999,9 @@ THE SOFTWARE. |
|
|
|
|
#if 0 |
|
|
|
|
printf( "PCF Warning: Pixel Size undefined, assuming 12\n"); |
|
|
|
|
#endif |
|
|
|
|
root->available_sizes->width = 12;
|
|
|
|
|
root->available_sizes->width = 12; |
|
|
|
|
root->available_sizes->height = 12; |
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* XXX: charmaps */ |
|
|
|
|
root->charmaps = &face->charmap_handle; |
|
|
|
@ -1008,7 +1009,7 @@ THE SOFTWARE. |
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
PCF_Property charset_registry = 0, charset_encoding = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
charset_registry = find_property( face, "CHARSET_REGISTRY" ); |
|
|
|
|
charset_encoding = find_property( face, "CHARSET_ENCODING" ); |
|
|
|
@ -1019,18 +1020,18 @@ THE SOFTWARE. |
|
|
|
|
if ( ( charset_registry->isString ) && |
|
|
|
|
( charset_encoding->isString ) ) |
|
|
|
|
{ |
|
|
|
|
if ( ALLOC( face->charset_encoding,
|
|
|
|
|
if ( ALLOC( face->charset_encoding, |
|
|
|
|
( strlen( charset_encoding->value.atom ) + 1 ) * |
|
|
|
|
sizeof ( char ) ) )
|
|
|
|
|
sizeof ( char ) ) ) |
|
|
|
|
goto Bail; |
|
|
|
|
if ( ALLOC( face->charset_registry,
|
|
|
|
|
if ( ALLOC( face->charset_registry, |
|
|
|
|
( strlen( charset_registry->value.atom ) + 1 ) * |
|
|
|
|
sizeof ( char ) ) )
|
|
|
|
|
sizeof ( char ) ) ) |
|
|
|
|
goto Bail; |
|
|
|
|
strcpy( face->charset_registry, charset_registry->value.atom ); |
|
|
|
|
strcpy( face->charset_encoding, charset_encoding->value.atom ); |
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
#if 0 |
|
|
|
|
if ( !strcmp( charset_registry, "ISO10646" ) ) |
|
|
|
|
{ |
|
|
|
|
face->charmap.encoding = ft_encoding_unicode; |
|
|
|
@ -1045,14 +1046,14 @@ THE SOFTWARE. |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
face->charmap.encoding = ft_encoding_none; |
|
|
|
|
face->charmap.platform_id = 0; |
|
|
|
|
face->charmap.encoding_id = 0; |
|
|
|
|
face->charmap.face = root;
|
|
|
|
|
face->charmap.face = root; |
|
|
|
|
face->charmap_handle = &face->charmap; |
|
|
|
|
root->charmap = face->charmap_handle; |
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
return PCF_Err_Ok; |
|
|
|
|
|
|
|
|
|
Bail: |
|
|
|
|