[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Devel] pcfread.c accelerator and size patch
From: |
Detlef Würkner |
Subject: |
[Devel] pcfread.c accelerator and size patch |
Date: |
Fri, 08 Feb 2002 14:33:27 +0100 |
Hello!
After some confusion (Sorry for that...) this patch fixes the parsing
of the accelerator metrics and uses this metrics instead of properties
for the face->available_sizes pixel width and height. Did not find a
font not working with this patch, but I dont have many PCF fonts.
Since -current in the meantime is somehow different from -2.0.7, I send
two patches for safety.
----8<----
--- freetype-2.0.7/src/pcf/pcfread.c.ori Tue Feb 5 13:57:35 2002
+++ freetype-2.0.7/src/pcf/pcfread.c Fri Feb 8 10:36:26 2002
@@ -244,12 +244,13 @@
static FT_Error
pcf_get_metric( FT_Stream stream,
FT_ULong format,
- PCF_Metric metric )
+ PCF_Metric metric,
+ FT_Bool uncompressed )
{
FT_Error error = PCF_Err_Ok;
- if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
+ if ( uncompressed || PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
{
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
error = pcf_parse_metric( stream, pcf_metric_msb_header, metric );
@@ -536,7 +537,7 @@
metrics = face->metrics;
for ( i = 0; i < nmetrics; i++ )
{
- pcf_get_metric( stream, format, metrics + i );
+ pcf_get_metric( stream, format, metrics + i, 0 );
metrics[i].bits = 0;
@@ -835,19 +836,19 @@
goto Bail;
}
- error = pcf_get_metric( stream, format, &(accel->minbounds) );
+ error = pcf_get_metric( stream, format, &(accel->minbounds), 1 );
if ( error )
goto Bail;
- error = pcf_get_metric( stream, format, &(accel->maxbounds) );
+ error = pcf_get_metric( stream, format, &(accel->maxbounds), 1 );
if ( error )
goto Bail;
if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )
{
- error = pcf_get_metric( stream, format, &(accel->ink_minbounds) );
+ error = pcf_get_metric( stream, format, &(accel->ink_minbounds), 1 );
if ( error )
goto Bail;
- error = pcf_get_metric( stream, format, &(accel->ink_maxbounds) );
+ error = pcf_get_metric( stream, format, &(accel->ink_maxbounds), 1 );
if ( error )
goto Bail;
}
@@ -920,7 +921,6 @@
{
FT_Face root = FT_FACE( face );
PCF_Property prop;
- int size_set = 0;
root->num_faces = 1;
@@ -979,40 +979,19 @@
if ( ALLOC_ARRAY( root->available_sizes, 1, FT_Bitmap_Size ) )
goto Bail;
- prop = find_property( face, "PIXEL_SIZE" );
- if ( prop != NULL )
+ if ( ( face->accel.maxbounds.characterWidth > 0 ) &&
+ ( face->accel.maxbounds.ascent > 0 ) &&
+ ( face->accel.maxbounds.descent >= 0 ) )
{
- root->available_sizes->width = (FT_Short)( prop->value.integer );
- root->available_sizes->height = (FT_Short)( prop->value.integer );
-
- size_set = 1;
- }
- else
- {
- prop = find_property( face, "POINT_SIZE" );
- if ( prop != NULL )
- {
- PCF_Property xres = 0, yres = 0;
-
-
- xres = find_property( face, "RESOLUTION_X" );
- yres = find_property( face, "RESOLUTION_Y" );
-
- if ( ( xres != NULL ) && ( yres != NULL ) )
- {
- root->available_sizes->width =
- (FT_Short)( prop->value.integer *
- xres->value.integer / 720 );
- root->available_sizes->height =
- (FT_Short)( prop->value.integer *
- yres->value.integer / 720 );
-
- size_set = 1;
- }
- }
+ /* bbox, units_per_EM, ascender, descender, height, max_advance_width,
+ * max_advance_height, underline_position and underline_thickness
+ * are only relevant for scalable formats.
+ */
+ root->available_sizes->width = face->accel.maxbounds.characterWidth;
+ root->available_sizes->height =
+ face->accel.maxbounds.ascent + face->accel.maxbounds.descent;
}
-
- if (size_set == 0 )
+ else
{
#if 0
printf( "PCF Warning: Pixel Size undefined, assuming 12\n");
----8<----
----8<----
--- freetype2-current/src/pcf/pcfread.c.ori Thu Feb 7 21:40:35 2002
+++ freetype2-current/src/pcf/pcfread.c. Fri Feb 8 10:46:32 2002
@@ -205,12 +205,13 @@
static FT_Error
pcf_get_metric( FT_Stream stream,
FT_ULong format,
- PCF_Metric metric )
+ PCF_Metric metric,
+ FT_Bool uncompressed )
{
FT_Error error = PCF_Err_Ok;
- if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
+ if ( uncompressed || PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
{
const FT_Frame_Field* fields;
@@ -520,7 +521,7 @@
metrics = face->metrics;
for ( i = 0; i < nmetrics; i++ )
{
- pcf_get_metric( stream, format, metrics + i );
+ pcf_get_metric( stream, format, metrics + i, 0 );
metrics[i].bits = 0;
@@ -821,21 +822,21 @@
goto Bail;
}
- error = pcf_get_metric( stream, format, &(accel->minbounds) );
+ error = pcf_get_metric( stream, format, &(accel->minbounds), 1 );
if ( error )
goto Bail;
- error = pcf_get_metric( stream, format, &(accel->maxbounds) );
+ error = pcf_get_metric( stream, format, &(accel->maxbounds), 1 );
if ( error )
goto Bail;
if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )
{
- error = pcf_get_metric( stream, format, &(accel->ink_minbounds) );
+ error = pcf_get_metric( stream, format, &(accel->ink_minbounds), 1 );
if ( error )
goto Bail;
- error = pcf_get_metric( stream, format, &(accel->ink_maxbounds) );
+ error = pcf_get_metric( stream, format, &(accel->ink_maxbounds), 1 );
if ( error )
goto Bail;
}
@@ -908,7 +909,6 @@
{
FT_Face root = FT_FACE( face );
PCF_Property prop;
- int size_set = 0;
root->num_faces = 1;
@@ -967,54 +967,19 @@
if ( ALLOC_ARRAY( root->available_sizes, 1, FT_Bitmap_Size ) )
goto Bail;
- prop = pcf_find_property( face, "PIXEL_SIZE" );
- if ( prop != NULL )
- {
- root->available_sizes->height =
- root->available_sizes->width = (FT_Short)( prop->value.integer );
-
-#if 0 /* average width property support removed until maturation */
- prop = pcf_find_property( face, "AVERAGE_WIDTH" );
- if ( prop != NULL )
- root->available_sizes->width = (FT_Short)( prop->value.integer / 10
);
-#endif
-
- size_set = 1;
- }
- else
+ if ( ( face->accel.maxbounds.characterWidth > 0 ) &&
+ ( face->accel.maxbounds.ascent > 0 ) &&
+ ( face->accel.maxbounds.descent >= 0 ) )
{
- prop = pcf_find_property( face, "POINT_SIZE" );
- if ( prop != NULL )
- {
- PCF_Property xres, yres, avgw;
-
-
- xres = pcf_find_property( face, "RESOLUTION_X" );
- yres = pcf_find_property( face, "RESOLUTION_Y" );
- avgw = pcf_find_property( face, "AVERAGE_WIDTH" );
-
- if ( ( yres != NULL ) && ( xres != NULL ) )
- {
- root->available_sizes->height =
- (FT_Short)( prop->value.integer *
- yres->value.integer / 720 );
-
-#if 0 /* average width property support removed until maturation */
- if ( avgw != NULL )
- root->available_sizes->width =
- (FT_Short)( avgw->value.integer / 10 );
- else
-#endif
- root->available_sizes->width =
- (FT_Short)( prop->value.integer *
- xres->value.integer / 720 );
-
- size_set = 1;
- }
- }
+ /* bbox, units_per_EM, ascender, descender, height, max_advance_width,
+ * max_advance_height, underline_position and underline_thickness
+ * are only relevant for scalable formats.
+ */
+ root->available_sizes->width = face->accel.maxbounds.characterWidth;
+ root->available_sizes->height =
+ face->accel.maxbounds.ascent + face->accel.maxbounds.descent;
}
-
- if (size_set == 0 )
+ else
{
#if 0
printf( "PCF Warning: Pixel Size undefined, assuming 12\n");
----8<----
Ciao, Detlef
--
_ // address@hidden
\X/ Detlef Wuerkner, Langgoens/Germany
- [Devel] pcfread.c accelerator and size patch,
Detlef Würkner <=