* docs/CHANGES: Mention the size selection change. * src/bdf/bdfdrivr.c (BDF_Size_Request, BDF_Size_Select), src/pcf/pcfdrivr.c (PCF_Size_Request, PCF_Size_Select), src/winfonts/winfnt.c (FNT_Size_Request, FNT_Size_Select): Do size matching for request of type NOMINAL and REAL_DIM. * src/winfonts/winfnt.c (FNT_Face_Init): Print trace message when `pixel_height' is used for nominal height. * src/base/ftobjs.c (FT_Request_Size): Call `FT_Match_Size' if the face is bitmap only and driver doesn't provide `request_size'. This is added merely for completion as no driver satisfies the conditions.
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 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289
diff --git a/ChangeLog b/ChangeLog
index 833b427..c6210ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2006-01-14 Chia-I Wu <b90201047@ntu.edu.tw>
+
+ * docs/CHANGES: Mention the size selection change.
+
+ * src/bdf/bdfdrivr.c (BDF_Size_Request, BDF_Size_Select),
+ src/pcf/pcfdrivr.c (PCF_Size_Request, PCF_Size_Select),
+ src/winfonts/winfnt.c (FNT_Size_Request, FNT_Size_Select): Do size
+ matching for request of type NOMINAL and REAL_DIM.
+
+ * src/winfonts/winfnt.c (FNT_Face_Init): Print trace message when
+ `pixel_height' is used for nominal height.
+
+ * src/base/ftobjs.c (FT_Request_Size): Call `FT_Match_Size' if the
+ face is bitmap only and driver doesn't provide `request_size'. This
+ is added merely for completion as no driver satisfies the conditions.
+
2006-01-13 Chia-I Wu <b90201047@ntu.edu.tw>
Introduce new size selection interface.
diff --git a/docs/CHANGES b/docs/CHANGES
index fd63451..5bfdf7d 100644
--- a/docs/CHANGES
+++ b/docs/CHANGES
@@ -52,6 +52,16 @@ LATEST CHANGES BETWEEN 2.2.0 and 2.1.10
`FT_GetFile_From_Mac_Name'. Legacy APIs are still available, if
FreeType is built without disabling them.
+ - A new API `FT_Select_Size' is added to select a bitmap strike by
+ its index. Code using other functions to select bitmap strikes
+ should be updated to use this function.
+
+ - In 2.1.10, the behavior of `FT_Set_Pixel_Sizes' is changed for
+ BDF/PCF fonts, and only for them. This causes inconsistency.
+ In this release, we undo the change. The intent of the change
+ in 2.1.10 is to allow size selection through real dimensions,
+ which can now be done through `FT_Request_Size'.
+
III. MISCELLANEOUS
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index a19092c..c2efbe0 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -2093,6 +2093,7 @@
FT_Driver_Class clazz;
FT_Size_Metrics* metrics;
FT_Error error;
+ FT_Bool bitmap_only = 0;
if ( !face )
@@ -2190,13 +2191,36 @@
else
{
FT_ZERO( metrics );
+
+ if ( FT_HAS_FIXED_SIZES( face ) )
+ bitmap_only = 1;
+
error = FT_Err_Invalid_Pixel_Size;
}
if ( clazz->request_size )
- return clazz->request_size( face->size, req );
- else
- return error;
+ error = clazz->request_size( face->size, req );
+ /*
+ * The reason that a driver not having `request_size' defined is
+ * either the scaling here suffices or the supported formats
+ * are bitmap-only and size matching is not implmented.
+ *
+ * In the latter case, a simple size matching is done.
+ */
+ else if ( bitmap_only )
+ {
+ FT_ULong index;
+
+
+ if ( !FT_Match_Size( face, req, 0, &index ) )
+ {
+ FT_TRACE3(( "FT_Request_Size: bitmap strike %lu matched\n", index ));
+
+ error = FT_Select_Size( face, index );
+ }
+ }
+
+ return error;
}
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index 445fb9f..213abcb 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -592,6 +592,8 @@ THE SOFTWARE.
size->metrics.ascender = bdffont->font_ascent << 6;
size->metrics.descender = -bdffont->font_descent << 6;
+ size->metrics.height = ( bdffont->font_ascent +
+ bdffont->font_descent ) << 6;
size->metrics.max_advance = bdffont->bbx.width << 6;
return BDF_Err_Ok;
@@ -602,20 +604,40 @@ THE SOFTWARE.
BDF_Size_Request( FT_Size size,
FT_Size_Request req )
{
- FT_Face face = size->face;
- FT_Error error;
+ FT_Face face = size->face;
+ FT_Bitmap_Size* bsize = face->available_sizes;
+ bdf_font_t* bdffont = ( (BDF_Face)face )->bdffont;
+ FT_Error error = BDF_Err_Invalid_Pixel_Size;
+ FT_Long height;
- error = FT_Match_Size( face, req, 1, NULL );
+ if ( req->vertResolution )
+ height = ( req->height * req->vertResolution + 36 ) / 72;
+ else
+ height = req->height;
+
+ height = ( height + 32 ) >> 6;
+
+ switch ( req->type )
+ {
+ case FT_SIZE_REQUEST_TYPE_NOMINAL:
+ if ( height == ( bsize->y_ppem + 32 ) >> 6 )
+ error = BDF_Err_Ok;
+ break;
+ case FT_SIZE_REQUEST_TYPE_REAL_DIM:
+ if ( height == ( bdffont->font_ascent +
+ bdffont->font_descent ) )
+ error = BDF_Err_Ok;
+ break;
+ default:
+ error = BDF_Err_Unimplemented_Feature;
+ break;
+ }
if ( error )
return error;
else
- {
- size->metrics.height = face->available_sizes->height << 6;
-
return BDF_Size_Select( size, 0 );
- }
}
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 011b45d..f3d56d9 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -375,6 +375,9 @@ THE SOFTWARE.
size->metrics.descender = -face->accel.fontDescent << 6;
#if 0
size->metrics.height = face->accel.maxbounds.ascent << 6;
+#else
+ size->metrics.height = size->metrics.ascender -
+ size->metrics.descender;
#endif
size->metrics.max_advance = face->accel.maxbounds.characterWidth << 6;
@@ -386,20 +389,39 @@ THE SOFTWARE.
PCF_Size_Request( FT_Size size,
FT_Size_Request req )
{
- FT_Face face = size->face;
- FT_Error error;
+ PCF_Face face = (PCF_Face)size->face;
+ FT_Bitmap_Size* bsize = size->face->available_sizes;
+ FT_Error error = PCF_Err_Invalid_Pixel_Size;
+ FT_Long height;
- error = FT_Match_Size( face, req, 1, NULL );
+ if ( req->vertResolution )
+ height = ( req->height * req->vertResolution + 36 ) / 72;
+ else
+ height = req->height;
+
+ height = ( height + 32 ) >> 6;
+
+ switch ( req->type )
+ {
+ case FT_SIZE_REQUEST_TYPE_NOMINAL:
+ if ( height == ( bsize->y_ppem + 32 ) >> 6 )
+ error = PCF_Err_Ok;
+ break;
+ case FT_SIZE_REQUEST_TYPE_REAL_DIM:
+ if ( height == ( face->accel.fontAscent +
+ face->accel.fontDescent ) )
+ error = PCF_Err_Ok;
+ break;
+ default:
+ error = PCF_Err_Unimplemented_Feature;
+ break;
+ }
if ( error )
return error;
else
- {
- size->metrics.height = face->available_sizes->height << 6;
-
return PCF_Size_Select( size, 0 );
- }
}
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index a24ea1b..66ae9f1 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -489,6 +489,8 @@
*/
if ( bsize->y_ppem > font->header.pixel_height << 6 )
{
+ FT_TRACE2(( "use pixel_height as the nominal height\n" ));
+
bsize->y_ppem = font->header.pixel_height << 6;
bsize->size = FT_MulDiv( bsize->y_ppem, 72, y_res );
}
@@ -579,6 +581,8 @@
size->metrics.ascender = header->ascent * 64;
size->metrics.descender = -( header->pixel_height -
header->ascent ) * 64;
+ size->metrics.height = ( header->pixel_height +
+ header->external_leading ) * 64;
size->metrics.max_advance = header->max_width * 64;
return FNT_Err_Ok;
@@ -589,20 +593,39 @@
FNT_Size_Request( FT_Size size,
FT_Size_Request req )
{
- FT_Face face = size->face;
- FT_Error error;
-
+ FNT_Face face = (FNT_Face)size->face;
+ FT_WinFNT_Header header = &face->font->header;
+ FT_Bitmap_Size* bsize = size->face->available_sizes;
+ FT_Error error = FNT_Err_Invalid_Pixel_Size;
+ FT_Long height;
- error = FT_Match_Size( face, req, 1, NULL );
- if ( error )
- return error;
+ if ( req->vertResolution )
+ height = ( req->height * req->vertResolution + 36 ) / 72;
else
+ height = req->height;
+
+ height = ( height + 32 ) >> 6;
+
+ switch ( req->type )
{
- size->metrics.height = face->available_sizes->height << 6;
+ case FT_SIZE_REQUEST_TYPE_NOMINAL:
+ if ( height == ( bsize->y_ppem + 32 ) >> 6 )
+ error = FNT_Err_Ok;
+ break;
+ case FT_SIZE_REQUEST_TYPE_REAL_DIM:
+ if ( height == header->pixel_height )
+ error = FNT_Err_Ok;
+ break;
+ default:
+ error = FNT_Err_Unimplemented_Feature;
+ break;
+ }
+ if ( error )
+ return error;
+ else
return FNT_Size_Select( size );
- }
}