* src/bdf/bdfdrivr.c (BDF_Face_Init, BDF_Set_Pixel_Size): Fix computation of various vertical and horizontal metric values. * src/pcfdrivr.c (PCF_Set_Pixel_Size), src/pcfread (pcf_load_font): Ditto.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
diff --git a/ChangeLog b/ChangeLog
index 71eac35..3df5e4f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-02-07 Keith Packard <keithp@keithp.com>
+
+ * src/bdf/bdfdrivr.c (BDF_Face_Init, BDF_Set_Pixel_Size): Fix
+ computation of various vertical and horizontal metric values.
+
+ * src/pcfdrivr.c (PCF_Set_Pixel_Size), src/pcfread (pcf_load_font):
+ Ditto.
+
2003-02-07 Werner Lemberg <wl@gnu.org>
* builds/win32/visualc/index.html,
diff --git a/docs/CHANGES b/docs/CHANGES
index d04e0ef..a1e6c70 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -32,6 +32,8 @@ LATEST CHANGES BETWEEN 2.1.8 and 2.1.7
- The flex operator didn't work for CFF fonts.
+ - Metrics for BDF and PCF bitmap font formats have been fixed.
+
II. IMPORTANT CHANGES
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index a231fcd..7358615 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -2,7 +2,7 @@
FreeType font driver for bdf files
- Copyright (C) 2001, 2002, 2003 by
+ Copyright (C) 2001, 2002, 2003, 2004 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -397,17 +397,18 @@ THE SOFTWARE.
{
FT_Bitmap_Size* bsize = root->available_sizes;
+ FT_Short resolution_x = 0, resolution_y = 0;
FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
- prop = bdf_get_font_property( font, "PIXEL_SIZE" );
- if ( prop )
- bsize->height = (FT_Short)prop->value.int32;
+ bsize->height = font->font_ascent + font->font_descent;
prop = bdf_get_font_property( font, "AVERAGE_WIDTH" );
if ( prop )
bsize->width = (FT_Short)( ( prop->value.int32 + 5 ) / 10 );
+ else
+ bsize->width = bsize->height * 2/3;
prop = bdf_get_font_property( font, "POINT_SIZE" );
if ( prop )
@@ -415,25 +416,28 @@ THE SOFTWARE.
bsize->size =
(FT_Pos)( ( prop->value.int32 * 64 * 7200 + 36135L ) / 72270L );
+ prop = bdf_get_font_property( font, "PIXEL_SIZE" );
+ if ( prop )
+ bsize->y_ppem = (FT_Short)prop->value.int32 << 6;
+
prop = bdf_get_font_property( font, "RESOLUTION_X" );
if ( prop )
- bsize->x_ppem =
- (FT_Pos)( ( prop->value.int32 * bsize->size + 36 ) / 72 );
+ resolution_x = (FT_Short)prop->value.int32;
prop = bdf_get_font_property( font, "RESOLUTION_Y" );
if ( prop )
- bsize->y_ppem =
- (FT_Pos)( ( prop->value.int32 * bsize->size + 36 ) / 72 );
-
- if ( bsize->height == 0 )
- bsize->height = (FT_Short)( ( bsize->y_ppem + 32 ) / 64 );
+ resolution_y = (FT_Short)prop->value.int32;
- if ( bsize->height == 0 )
+ if ( bsize->y_ppem == 0 )
{
- /* some fonts have a broken SIZE declaration (jiskan24.bdf) */
- FT_ERROR(( "BDF_Face_Init: reading size\n" ));
- bsize->height = (FT_Short)font->point_size;
+ bsize->y_ppem = bsize->size;
+ if ( resolution_y )
+ bsize->y_ppem = bsize->y_ppem * resolution_y / 72;
}
+ if ( resolution_x && resolution_y )
+ bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y;
+ else
+ bsize->x_ppem = bsize->y_ppem;
}
/* encoding table */
@@ -563,13 +567,14 @@ THE SOFTWARE.
FT_TRACE4(( "rec %d - pres %d\n",
- size->metrics.y_ppem, root->available_sizes->height ));
+ size->metrics.y_ppem, root->available_sizes->y_ppem ));
- if ( size->metrics.y_ppem == root->available_sizes->height )
+ if ( size->metrics.y_ppem == root->available_sizes->y_ppem >> 6 )
{
- size->metrics.ascender = face->bdffont->bbx.ascent << 6;
- size->metrics.descender = face->bdffont->bbx.descent * ( -64 );
- size->metrics.height = face->bdffont->bbx.height << 6;
+ size->metrics.ascender = face->bdffont->font_ascent << 6;
+ size->metrics.descender = -face->bdffont->font_descent << 6;
+ size->metrics.height = ( face->bdffont->font_ascent +
+ face->bdffont->font_descent ) << 6;
size->metrics.max_advance = face->bdffont->bbx.width << 6;
return BDF_Err_Ok;
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 8807332..dc25b5d 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -2,7 +2,7 @@
FreeType font driver for pcf files
- Copyright (C) 2000, 2001, 2002, 2003 by
+ Copyright (C) 2000, 2001, 2002, 2003, 2004 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -336,9 +336,9 @@ THE SOFTWARE.
FT_TRACE4(( "rec %d - pres %d\n", size->metrics.y_ppem,
- face->root.available_sizes->height ));
+ face->root.available_sizes->y_ppem >> 6 ));
- if ( size->metrics.y_ppem == face->root.available_sizes->height )
+ if ( size->metrics.y_ppem == face->root.available_sizes->y_ppem >> 6 )
{
size->metrics.ascender = face->accel.fontAscent << 6;
size->metrics.descender = face->accel.fontDescent * (-64);
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index f29512f..c8a1404 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -2,7 +2,7 @@
FreeType font driver for pcf fonts
- Copyright 2000, 2001, 2002, 2003 by
+ Copyright 2000, 2001, 2002, 2003, 2004 by
Francesco Zappa Nardelli
Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1070,39 +1070,47 @@ THE SOFTWARE.
{
FT_Bitmap_Size* bsize = root->available_sizes;
+ FT_Short resolution_x = 0, resolution_y = 0;
FT_MEM_ZERO( bsize, sizeof ( FT_Bitmap_Size ) );
- prop = pcf_find_property( face, "PIXEL_SIZE" );
- if ( prop )
- bsize->height = (FT_Short)prop->value.integer;
+ bsize->height = face->accel.fontAscent + face->accel.fontDescent;
prop = pcf_find_property( face, "AVERAGE_WIDTH" );
if ( prop )
bsize->width = (FT_Short)( ( prop->value.integer + 5 ) / 10 );
+ else
+ bsize->width = bsize->height * 2/3;
prop = pcf_find_property( face, "POINT_SIZE" );
if ( prop )
- /* convert from 722,7 decipoints to 72 points per inch */
+ /* 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, "PIXEL_SIZE" );
+ if ( prop )
+ bsize->y_ppem = (FT_Short)prop->value.integer << 6;
+
prop = pcf_find_property( face, "RESOLUTION_X" );
if ( prop )
- bsize->x_ppem =
- (FT_Pos)( ( prop->value.integer * bsize->size + 36 ) / 72 );
+ resolution_x = (FT_Short)prop->value.integer;
prop = pcf_find_property( face, "RESOLUTION_Y" );
if ( prop )
- bsize->y_ppem =
- (FT_Pos)( ( prop->value.integer * bsize->size + 36 ) / 72 );
-
- if ( bsize->height == 0 )
- bsize->height = (FT_Short)( ( bsize->y_ppem + 32 ) / 64 );
+ resolution_y = (FT_Short)prop->value.integer;
- if ( bsize->height == 0 )
- bsize->height = 12;
+ if ( bsize->y_ppem == 0 )
+ {
+ bsize->y_ppem = bsize->size;
+ if ( resolution_y )
+ bsize->y_ppem = bsize->y_ppem * resolution_y / 72;
+ }
+ if ( resolution_x && resolution_y )
+ bsize->x_ppem = bsize->y_ppem * resolution_x / resolution_y;
+ else
+ bsize->x_ppem = bsize->y_ppem;
}
/* set up charset */