* src/type1/t1gload.c (T1_Load_Glyph): enable font matrix transform on hinted glyphs.. * src/cid/cidgload.c, src/cid/cidobjs.c, src/cid/cidobjs.h, src/cid/cidriver.c, include/freetype/internal/t1types.h: added Postscript hinter support to the CID font driver !!
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 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428
diff --git a/ChangeLog b/ChangeLog
index 4764638..01df1e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2001-12-20 David Turner <david@freetype.org>
+
+ * src/type1/t1gload.c (T1_Load_Glyph): enable font matrix transform
+ on hinted glyphs..
+
+ * src/cid/cidgload.c, src/cid/cidobjs.c, src/cid/cidobjs.h,
+ src/cid/cidriver.c, include/freetype/internal/t1types.h: added
+ Postscript hinter support to the CID font driver !!
+
+
2001-12-19 David Turner <david@freetype.org>
* include/freetype/cache/ftcache.h: Added comments to indicate that
diff --git a/include/freetype/internal/t1types.h b/include/freetype/internal/t1types.h
index f3cb083..c8c87eb 100644
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -188,6 +188,9 @@ FT_BEGIN_HEADER
CID_Info cid;
void* afm_data;
CID_Subrs* subrs;
+
+ /* since FT 2.1 - interface to PostScript hinter */
+ void* pshinter;
} CID_FaceRec;
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index 3769da1..e7a70e8 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -238,7 +238,7 @@
(FT_GlyphSlot)glyph,
0, /* glyph names -- XXX */
0, /* blend == 0 */
- 0, /* hinting == 0 */
+ hinting,
cid_load_glyph );
/* set up the decoder */
@@ -316,11 +316,12 @@
/* First of all, scale the points */
- for ( n = cur->n_points; n > 0; n--, vec++ )
- {
- vec->x = FT_MulFix( vec->x, x_scale );
- vec->y = FT_MulFix( vec->y, y_scale );
- }
+ if ( !hinting )
+ for ( n = cur->n_points; n > 0; n--, vec++ )
+ {
+ vec->x = FT_MulFix( vec->x, x_scale );
+ vec->y = FT_MulFix( vec->y, y_scale );
+ }
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c
index 77c25ed..9967f65 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -23,6 +23,7 @@
#include "cidload.h"
#include FT_INTERNAL_POSTSCRIPT_NAMES_H
#include FT_INTERNAL_POSTSCRIPT_AUX_H
+#include FT_INTERNAL_POSTSCRIPT_HINTS_H
#include "ciderrs.h"
@@ -37,6 +38,127 @@
#define FT_COMPONENT trace_cidobjs
+
+ /*************************************************************************/
+ /* */
+ /* SLOT FUNCTIONS */
+ /* */
+ /*************************************************************************/
+
+ FT_LOCAL_DEF void
+ CID_GlyphSlot_Done( CID_GlyphSlot slot )
+ {
+ slot->root.internal->glyph_hints = 0;
+ }
+
+
+ FT_LOCAL_DEF FT_Error
+ CID_GlyphSlot_Init( CID_GlyphSlot slot )
+ {
+ CID_Face face;
+ PSHinter_Interface* pshinter;
+
+ face = (CID_Face) slot->root.face;
+ pshinter = face->pshinter;
+ if (pshinter)
+ {
+ FT_Module module;
+
+ module = FT_Get_Module( slot->root.face->driver->root.library, "pshinter" );
+ if (module)
+ {
+ T1_Hints_Funcs funcs;
+
+ funcs = pshinter->get_t1_funcs( module );
+ slot->root.internal->glyph_hints = (void*)funcs;
+ }
+ }
+ return 0;
+ }
+
+
+ /*************************************************************************/
+ /* */
+ /* SIZE FUNCTIONS */
+ /* */
+ /*************************************************************************/
+
+
+ static PSH_Globals_Funcs
+ CID_Size_Get_Globals_Funcs( CID_Size size )
+ {
+ CID_Face face = (CID_Face) size->root.face;
+ PSHinter_Interface* pshinter = face->pshinter;
+ FT_Module module;
+
+
+ module = FT_Get_Module( size->root.face->driver->root.library,
+ "pshinter" );
+ return ( module && pshinter && pshinter->get_globals_funcs )
+ ? pshinter->get_globals_funcs( module )
+ : 0 ;
+ }
+
+
+ FT_LOCAL_DEF void
+ CID_Size_Done( CID_Size size )
+ {
+ if ( size->root.internal )
+ {
+ PSH_Globals_Funcs funcs;
+
+
+ funcs = CID_Size_Get_Globals_Funcs( size );
+ if ( funcs )
+ funcs->destroy( (PSH_Globals)size->root.internal );
+
+ size->root.internal = 0;
+ }
+ }
+
+
+ FT_LOCAL_DEF FT_Error
+ CID_Size_Init( CID_Size size )
+ {
+ FT_Error error = 0;
+ PSH_Globals_Funcs funcs = CID_Size_Get_Globals_Funcs( size );
+
+
+ if ( funcs )
+ {
+ PSH_Globals globals;
+ CID_Face face = (CID_Face)size->root.face;
+ CID_FontDict* dict = face->cid.font_dicts + face->root.face_index;
+ T1_Private* priv = &dict->private_dict;
+
+
+ error = funcs->create( size->root.face->memory, priv, &globals );
+ if ( !error )
+ size->root.internal = (FT_Size_Internal)(void*)globals;
+ }
+
+ return error;
+ }
+
+
+ FT_LOCAL_DEF FT_Error
+ CID_Size_Reset( CID_Size size )
+ {
+ PSH_Globals_Funcs funcs = CID_Size_Get_Globals_Funcs( size );
+ FT_Error error = 0;
+
+
+ if ( funcs )
+ error = funcs->set_scale( (PSH_Globals)size->root.internal,
+ size->root.metrics.x_scale,
+ size->root.metrics.y_scale,
+ 0, 0 );
+ return error;
+ }
+
+
+
+
/*************************************************************************/
/* */
/* FACE FUNCTIONS */
@@ -47,7 +169,7 @@
/*************************************************************************/
/* */
/* <Function> */
- /* CID_Done_Face */
+ /* CID_Face_Done */
/* */
/* <Description> */
/* Finalizes a given face object. */
@@ -56,7 +178,7 @@
/* face :: A pointer to the face object to destroy. */
/* */
FT_LOCAL_DEF void
- CID_Done_Face( CID_Face face )
+ CID_Face_Done( CID_Face face )
{
FT_Memory memory;
@@ -94,7 +216,7 @@
/*************************************************************************/
/* */
/* <Function> */
- /* CID_Init_Face */
+ /* CID_Face_Init */
/* */
/* <Description> */
/* Initializes a given CID face object. */
@@ -115,7 +237,7 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF FT_Error
- CID_Init_Face( FT_Stream stream,
+ CID_Face_Init( FT_Stream stream,
CID_Face face,
FT_Int face_index,
FT_Int num_params,
@@ -124,6 +246,7 @@
FT_Error error;
PSNames_Interface* psnames;
PSAux_Interface* psaux;
+ PSHinter_Interface* pshinter;
FT_UNUSED( num_params );
FT_UNUSED( params );
@@ -151,6 +274,17 @@
face->psaux = psaux;
}
+
+ pshinter = (PSHinter_Interface*)face->pshinter;
+ if ( !pshinter )
+ {
+ pshinter = (PSHinter_Interface*)
+ FT_Get_Module_Interface( FT_FACE_LIBRARY( face ), "pshinter" );
+
+ face->pshinter = pshinter;
+ }
+
+
/* open the tokenizer; this will also check the font format */
if ( FILE_Seek( 0 ) )
goto Exit;
@@ -166,7 +300,7 @@
/* check the face index */
if ( face_index != 0 )
{
- FT_ERROR(( "CID_Init_Face: invalid face index\n" ));
+ FT_ERROR(( "CID_Face_Init: invalid face index\n" ));
error = CID_Err_Invalid_Argument;
goto Exit;
}
@@ -342,7 +476,7 @@
/*************************************************************************/
/* */
/* <Function> */
- /* CID_Init_Driver */
+ /* CID_Driver_Init */
/* */
/* <Description> */
/* Initializes a given CID driver object. */
@@ -354,7 +488,7 @@
/* FreeType error code. 0 means success. */
/* */
FT_LOCAL_DEF FT_Error
- CID_Init_Driver( CID_Driver driver )
+ CID_Driver_Init( CID_Driver driver )
{
FT_UNUSED( driver );
@@ -365,7 +499,7 @@
/*************************************************************************/
/* */
/* <Function> */
- /* CID_Done_Driver */
+ /* CID_Driver_Done */
/* */
/* <Description> */
/* Finalizes a given CID driver. */
@@ -374,7 +508,7 @@
/* driver :: A handle to the target CID driver. */
/* */
FT_LOCAL_DEF void
- CID_Done_Driver( CID_Driver driver )
+ CID_Driver_Done( CID_Driver driver )
{
FT_UNUSED( driver );
}
diff --git a/src/cid/cidobjs.h b/src/cid/cidobjs.h
index 8330663..19d52c2 100644
--- a/src/cid/cidobjs.h
+++ b/src/cid/cidobjs.h
@@ -111,22 +111,43 @@ FT_BEGIN_HEADER
} CID_GlyphSlotRec;
+ FT_LOCAL void
+ CID_GlyphSlot_Done( CID_GlyphSlot slot );
+
+ FT_LOCAL FT_Error
+ CID_GlyphSlot_Init( CID_GlyphSlot slot );
+
+
+ FT_LOCAL void
+ CID_Size_Done( CID_Size size );
+
+
FT_LOCAL FT_Error
- CID_Init_Face( FT_Stream stream,
+ CID_Size_Init( CID_Size size );
+
+
+ FT_LOCAL FT_Error
+ CID_Size_Reset( CID_Size size );
+
+
+ FT_LOCAL FT_Error
+ CID_Face_Init( FT_Stream stream,
CID_Face face,
FT_Int face_index,
FT_Int num_params,
FT_Parameter* params );
+
FT_LOCAL void
- CID_Done_Face( CID_Face face );
+ CID_Face_Done( CID_Face face );
FT_LOCAL FT_Error
- CID_Init_Driver( CID_Driver driver );
+ CID_Driver_Init( CID_Driver driver );
+
FT_LOCAL void
- CID_Done_Driver( CID_Driver driver );
+ CID_Driver_Done( CID_Driver driver );
FT_END_HEADER
diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c
index dead1c4..9edbc69 100644
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -190,7 +190,10 @@
{
/* first of all, the FT_Module_Class fields */
{
- ft_module_font_driver | ft_module_driver_scalable,
+ ft_module_font_driver |
+ ft_module_driver_scalable |
+ ft_module_driver_has_hinter ,
+
sizeof( FT_DriverRec ),
"t1cid", /* module name */
0x10000L, /* version 1.0 of driver */
@@ -198,8 +201,8 @@
0,
- (FT_Module_Constructor)CID_Init_Driver,
- (FT_Module_Destructor) CID_Done_Driver,
+ (FT_Module_Constructor)CID_Driver_Init,
+ (FT_Module_Destructor) CID_Driver_Done,
(FT_Module_Requester) CID_Get_Interface
},
@@ -208,16 +211,16 @@
sizeof( CID_SizeRec ),
sizeof( CID_GlyphSlotRec ),
- (FTDriver_initFace) CID_Init_Face,
- (FTDriver_doneFace) CID_Done_Face,
+ (FTDriver_initFace) CID_Face_Init,
+ (FTDriver_doneFace) CID_Face_Done,
- (FTDriver_initSize) 0,
- (FTDriver_doneSize) 0,
- (FTDriver_initGlyphSlot)0,
- (FTDriver_doneGlyphSlot)0,
+ (FTDriver_initSize) CID_Size_Init,
+ (FTDriver_doneSize) CID_Size_Done,
+ (FTDriver_initGlyphSlot)CID_GlyphSlot_Init,
+ (FTDriver_doneGlyphSlot)CID_GlyphSlot_Done,
- (FTDriver_setCharSizes) 0,
- (FTDriver_setPixelSizes)0,
+ (FTDriver_setCharSizes) CID_Size_Reset,
+ (FTDriver_setPixelSizes)CID_Size_Reset,
(FTDriver_loadGlyph) CID_Load_Glyph,
(FTDriver_getCharIndex) CID_Get_Char_Index,
diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c
index 515e305..78fa41f 100644
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -241,8 +241,7 @@
if ( size && size->root.metrics.y_ppem < 24 )
glyph->root.outline.flags |= ft_outline_high_precision;
- /* XXX: the following needs serious work to work properly with hinting! */
-#if 0
+#if 1
/* apply the font matrix, if any */
FT_Outline_Transform( &glyph->root.outline, &font_matrix );