diff --git a/ChangeLog b/ChangeLog index 01df1e1f1..9001b7ecf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2001-12-20 David Turner + * docs/TODO: added "stem3 and counter hints support" to the TODO list + for the Postscript hinter + + * docs/BUGS: closed the AUTOHINT-NO-SBITS bug. + + * src/pshinter/pshrec.c (t2_hint_stems), src/cff/cffobjs.h, + src/cff/cffobjs.c, src/cff/cffload.c, src/cff/cffload.h, + src/cff/cffgload.c, src/cff/cffgload.h, src/cff/cffdriver.c, + include/freetype/internal/cfftypes.h: added Postscript hinter support + to the CFF driver + + * src/base/ftobjs.c (FT_Done_Library): fixed a stupid bug that crashed + the library on exit + * src/type1/t1gload.c (T1_Load_Glyph): enable font matrix transform on hinted glyphs.. diff --git a/docs/BUGS b/docs/BUGS index b350d7395..a09adb14d 100644 --- a/docs/BUGS +++ b/docs/BUGS @@ -27,7 +27,6 @@ I. Opened bugs Identifier Date Opened by Reproduceable ------------------------------------------------------------------------------ NO-CID-CMAPS 13-09-2001 David always -AUTOHINT-NO-SBITS 13-09-2001 David always BAD-TT-RENDERING 12-09-2001 Paul Pedriana ? BAD-THIN-LINES 13-09-2001 David ? NOT-WINDOWS-METRICS 07-10-2001 David always @@ -47,6 +46,7 @@ BAD-TTNAMEID.H 12-09-2001 Antoine N/A BAD-T1-CHARMAP 15-06-2001 David 2.0.5 BAD-UNIXXX-NAMES 30-07-2001 David 2.0.5 GLYPH_TO_BITMAP-BUG 05-12-2001 David 05-12-2001 +AUTOHINT-NO-SBITS 13-09-2001 David 2.0.6 --------------------END-OF-CLOSED-BUGS-TABLE---------------------------------- @@ -98,6 +98,10 @@ AUTOHINT-SBITS efficiently without making a few important internal changes to the library's design (more importantly, to the font driver interface). + This has been corrected with a hack in FT_Load_Glyph. More important + internal changes should help get rid of it with a clean solution in + a further release like FreeType 2.1 + BAD-TT-RENDERING @@ -108,6 +112,11 @@ BAD-TT-RENDERING Tests and comparisons show a _major_ discrepancy of monochrome truetype bytecode-hinted glyphs! Something seems to be really broken here! + Some of this has been fixed in 2.0.6, there was a bug in the TrueType + loader that prevented it from loading composites correctly. However, there + are still _subtle_ differences between FT1 and FT2 when it comes to + monochrome TrueType-hinted glyphs.. + BAD-THIN-LINES @@ -195,6 +204,8 @@ GLYPH_TO_BITMAP-BUG This was only noticeable with certain glyphs or certain fonts; it crept in a long time ago. - + + same bug in src/raster/ftrender1.c by the way.. + === end of file === diff --git a/docs/TODO b/docs/TODO index 76b34fe83..6094f6000 100644 --- a/docs/TODO +++ b/docs/TODO @@ -5,3 +5,5 @@ Here is a list of items that need to be addressed in FreeType 2; they are not exactly bugs, but should be considered though: * Add synthesized Unicode charmap processing to the CFF driver. + +* Implement stem3/counter hints properly in the Postscript hinter diff --git a/include/freetype/internal/cfftypes.h b/include/freetype/internal/cfftypes.h index 4465f5785..73a508b5d 100644 --- a/include/freetype/internal/cfftypes.h +++ b/include/freetype/internal/cfftypes.h @@ -238,6 +238,9 @@ FT_BEGIN_HEADER CFF_FD_Select fd_select; + /* interface to PostScript hinter */ + void* pshinter; + } CFF_Font; diff --git a/include/freetype/internal/tttypes.h b/include/freetype/internal/tttypes.h index 5014e2265..4fc504fc7 100644 --- a/include/freetype/internal/tttypes.h +++ b/include/freetype/internal/tttypes.h @@ -1640,7 +1640,6 @@ FT_BEGIN_HEADER /* for possible extensibility in other formats */ void* other; - }; diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c index 0d2d621c1..618d45aa7 100644 --- a/src/base/ftobjs.c +++ b/src/base/ftobjs.c @@ -2646,6 +2646,10 @@ library->generic.finalizer( library ); /* Close all modules in the library */ +#if 1 + while ( library->num_modules > 0 ) + FT_Remove_Module( library, library->modules[0] ); +#else for ( n = 0; n < library->num_modules; n++ ) { FT_Module module = library->modules[n]; @@ -2657,6 +2661,7 @@ library->modules[n] = 0; } } +#endif /* Destroy raster objects */ FREE( library->raster_pool ); diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c index c8270f8e4..03ad0c42c 100644 --- a/src/cff/cffdrivr.c +++ b/src/cff/cffdrivr.c @@ -411,7 +411,10 @@ { /* begin with 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( CFF_DriverRec ), "cff", 0x10000L, @@ -419,8 +422,8 @@ 0, /* module-specific interface */ - (FT_Module_Constructor)CFF_Init_Driver, - (FT_Module_Destructor) CFF_Done_Driver, + (FT_Module_Constructor)CFF_Driver_Init, + (FT_Module_Destructor) CFF_Driver_Done, (FT_Module_Requester) cff_get_interface, }, @@ -429,15 +432,15 @@ sizeof( FT_SizeRec ), sizeof( CFF_GlyphSlotRec ), - (FTDriver_initFace) CFF_Init_Face, - (FTDriver_doneFace) CFF_Done_Face, - (FTDriver_initSize) 0, - (FTDriver_doneSize) 0, - (FTDriver_initGlyphSlot)0, - (FTDriver_doneGlyphSlot)0, + (FTDriver_initFace) CFF_Face_Init, + (FTDriver_doneFace) CFF_Face_Done, + (FTDriver_initSize) CFF_Size_Init, + (FTDriver_doneSize) CFF_Size_Done, + (FTDriver_initGlyphSlot)CFF_GlyphSlot_Init, + (FTDriver_doneGlyphSlot)CFF_GlyphSlot_Done, - (FTDriver_setCharSizes) 0, - (FTDriver_setPixelSizes)0, + (FTDriver_setCharSizes) CFF_Size_Reset, + (FTDriver_setPixelSizes)CFF_Size_Reset, (FTDriver_loadGlyph) Load_Glyph, (FTDriver_getCharIndex) cff_get_char_index, diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c index be58ac132..01e3b4cb2 100644 --- a/src/cff/cffgload.c +++ b/src/cff/cffgload.c @@ -25,6 +25,7 @@ #include FT_TRUETYPE_TAGS_H #include FT_INTERNAL_POSTSCRIPT_HINTS_H +#include "cffobjs.h" #include "cffload.h" #include "cffgload.h" @@ -152,8 +153,8 @@ 2 | CFF_COUNT_CHECK_WIDTH, 2 | CFF_COUNT_CHECK_WIDTH, - 0, /* hintmask */ - 0, /* cntrmask */ + 0 | CFF_COUNT_CHECK_WIDTH, /* hintmask */ + 0 | CFF_COUNT_CHECK_WIDTH, /* cntrmask */ 0, /* dotsection */ 1, /* abs */ @@ -206,7 +207,7 @@ /*************************************************************************/ /* */ /* */ - /* CFF_Init_Builder */ + /* CFF_Builder_Init */ /* */ /* */ /* Initializes a given glyph builder. */ @@ -222,10 +223,11 @@ /* glyph :: The current glyph object. */ /* */ static void - CFF_Init_Builder( CFF_Builder* builder, + CFF_Builder_Init( CFF_Builder* builder, TT_Face face, CFF_Size size, - CFF_GlyphSlot glyph ) + CFF_GlyphSlot glyph, + FT_Bool hinting ) { builder->path_begun = 0; builder->load_points = 1; @@ -243,6 +245,15 @@ builder->base = &loader->base.outline; builder->current = &loader->current.outline; FT_GlyphLoader_Rewind( loader ); + + builder->hints_globals = 0; + builder->hints_funcs = 0; + + if ( hinting && size ) + { + builder->hints_globals = size->internal; + builder->hints_funcs = glyph->root.internal->glyph_hints; + } } if ( size ) @@ -264,7 +275,7 @@ /*************************************************************************/ /* */ /* */ - /* CFF_Done_Builder */ + /* CFF_Builder_Done */ /* */ /* */ /* Finalizes a given glyph builder. Its contents can still be used */ @@ -275,7 +286,7 @@ /* builder :: A pointer to the glyph builder to finalize. */ /* */ static void - CFF_Done_Builder( CFF_Builder* builder ) + CFF_Builder_Done( CFF_Builder* builder ) { CFF_GlyphSlot glyph = builder->glyph; @@ -338,7 +349,8 @@ CFF_Init_Decoder( CFF_Decoder* decoder, TT_Face face, CFF_Size size, - CFF_GlyphSlot slot ) + CFF_GlyphSlot slot, + FT_Bool hinting ) { CFF_Font* cff = (CFF_Font*)face->extra.data; @@ -347,7 +359,7 @@ MEM_Set( decoder, 0, sizeof ( *decoder ) ); /* initialize builder */ - CFF_Init_Builder( &decoder->builder, face, size, slot ); + CFF_Builder_Init( &decoder->builder, face, size, slot, hinting ); /* initialize Type2 decoder */ decoder->num_globals = cff->num_global_subrs; @@ -533,7 +545,7 @@ /* Get code to SID mapping from `cff_standard_encoding'. */ - glyph_sid = cff_standard_encoding[charcode]; + glyph_sid = CFF_Get_Standard_Encoding( (FT_UInt)charcode ); for ( n = 0; n < cff->num_glyphs; n++ ) { @@ -1080,19 +1092,29 @@ case cff_op_hintmask: case cff_op_cntrmask: FT_TRACE4(( op == cff_op_hintmask ? " hintmask" : " cntrmask" )); - - decoder->num_hints += num_args / 2; + + /* implement vstem when needed */ + if ( num_args > 0 ) + { + if ( hinter ) + hinter->stems( hinter->hints, + 1, + num_args / 2, + args ); + + decoder->num_hints += num_args / 2; + } if ( hinter ) { if ( op == cff_op_hintmask ) hinter->hintmask( hinter->hints, builder->current->n_points, - ( decoder->num_hints + 7 ) >> 3, + decoder->num_hints, ip ); else hinter->counter( hinter->hints, - ( decoder->num_hints + 7 ) >> 3, + decoder->num_hints, ip ); } @@ -2097,7 +2119,7 @@ *max_advance = 0; /* Initialize load decoder */ - CFF_Init_Decoder( &decoder, face, 0, 0 ); + CFF_Init_Decoder( &decoder, face, 0, 0, 0 ); decoder.builder.metrics_only = 1; decoder.builder.load_points = 0; @@ -2191,7 +2213,7 @@ FT_ULong charstring_len; - CFF_Init_Decoder( &decoder, face, size, glyph ); + CFF_Init_Decoder( &decoder, face, size, glyph, hinting ); decoder.builder.no_recurse = (FT_Bool)( ( load_flags & FT_LOAD_NO_RECURSE ) != 0 ); @@ -2219,7 +2241,7 @@ } /* save new glyph tables */ - CFF_Done_Builder( &decoder.builder ); + CFF_Builder_Done( &decoder.builder ); } font_matrix = cff->top_font.font_dict.font_matrix; @@ -2287,11 +2309,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/cff/cffgload.h b/src/cff/cffgload.h index d100bd02e..55af7c4d4 100644 --- a/src/cff/cffgload.h +++ b/src/cff/cffgload.h @@ -171,7 +171,8 @@ FT_BEGIN_HEADER CFF_Init_Decoder( CFF_Decoder* decoder, TT_Face face, CFF_Size size, - CFF_GlyphSlot slot ); + CFF_GlyphSlot slot, + FT_Bool hinting ); FT_LOCAL void CFF_Prepare_Decoder( CFF_Decoder* decoder, diff --git a/src/cff/cffload.c b/src/cff/cffload.c index c4ddc26cc..f69c11385 100644 --- a/src/cff/cffload.c +++ b/src/cff/cffload.c @@ -29,6 +29,1030 @@ #include "cfferrs.h" +#if 1 + static const FT_UShort cff_isoadobe_charset[229] = + { + 0, + 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 + }; + + static const FT_UShort cff_expert_charset[166] = + { + 0, + 1, + 229, + 230, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 13, + 14, + 15, + 99, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 27, + 28, + 249, + 250, + 251, + 252, + 253, + 254, + 255, + 256, + 257, + 258, + 259, + 260, + 261, + 262, + 263, + 264, + 265, + 266, + 109, + 110, + 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, + 158, + 155, + 163, + 319, + 320, + 321, + 322, + 323, + 324, + 325, + 326, + 150, + 164, + 169, + 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 + }; + + static const FT_UShort cff_expertsubset_charset[87] = + { + 0, + 1, + 231, + 232, + 235, + 236, + 237, + 238, + 13, + 14, + 15, + 99, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 27, + 28, + 249, + 250, + 251, + 253, + 254, + 255, + 256, + 257, + 258, + 259, + 260, + 261, + 262, + 263, + 264, + 265, + 266, + 109, + 110, + 267, + 268, + 269, + 270, + 272, + 300, + 301, + 302, + 305, + 314, + 315, + 158, + 155, + 163, + 320, + 321, + 322, + 323, + 324, + 325, + 326, + 150, + 164, + 169, + 327, + 328, + 329, + 330, + 331, + 332, + 333, + 334, + 335, + 336, + 337, + 338, + 339, + 340, + 341, + 342, + 343, + 344, + 345, + 346 + }; + + static const FT_UShort cff_standard_encoding[256] = + { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 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, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 96, + 97, + 98, + 99, + 100, + 101, + 102, + 103, + 104, + 105, + 106, + 107, + 108, + 109, + 110, + 0, + 111, + 112, + 113, + 114, + 0, + 115, + 116, + 117, + 118, + 119, + 120, + 121, + 122, + 0, + 123, + 0, + 124, + 125, + 126, + 127, + 128, + 129, + 130, + 131, + 0, + 132, + 133, + 0, + 134, + 135, + 136, + 137, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 138, + 0, + 139, + 0, + 0, + 0, + 0, + 140, + 141, + 142, + 143, + 0, + 0, + 0, + 0, + 0, + 144, + 0, + 0, + 0, + 145, + 0, + 0, + 146, + 147, + 148, + 149, + 0, + 0, + 0, + 0 + }; + + static const FT_UShort cff_expert_encoding[256] = + { + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 229, + 230, + 0, + 231, + 232, + 233, + 234, + 235, + 236, + 237, + 238, + 13, + 14, + 15, + 99, + 239, + 240, + 241, + 242, + 243, + 244, + 245, + 246, + 247, + 248, + 27, + 28, + 249, + 250, + 251, + 252, + 0, + 253, + 254, + 255, + 256, + 257, + 0, + 0, + 0, + 258, + 0, + 0, + 259, + 260, + 261, + 262, + 0, + 0, + 263, + 264, + 265, + 0, + 266, + 109, + 110, + 267, + 268, + 269, + 0, + 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, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 304, + 305, + 306, + 0, + 0, + 307, + 308, + 309, + 310, + 311, + 0, + 312, + 0, + 0, + 312, + 0, + 0, + 314, + 315, + 0, + 0, + 316, + 317, + 318, + 0, + 0, + 0, + 158, + 155, + 163, + 319, + 320, + 321, + 322, + 323, + 324, + 325, + 0, + 0, + 326, + 150, + 164, + 169, + 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 + }; +#endif + + + FT_LOCAL_DEF FT_UShort + CFF_Get_Standard_Encoding( FT_UInt charcode ) + { + return (charcode < 256 ? cff_standard_encoding[charcode] : 0); + } + + /*************************************************************************/ /* */ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ diff --git a/src/cff/cffload.h b/src/cff/cffload.h index 91f4ca586..cda42d5d9 100644 --- a/src/cff/cffload.h +++ b/src/cff/cffload.h @@ -28,6 +28,7 @@ FT_BEGIN_HEADER +#if 0 const FT_UShort cff_isoadobe_charset[229] = { 0, @@ -1041,6 +1042,10 @@ FT_BEGIN_HEADER 377, 378 }; +#endif + + FT_LOCAL FT_UShort + CFF_Get_Standard_Encoding( FT_UInt charcode ); FT_LOCAL FT_String* diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c index 1041ec284..b66d29bc1 100644 --- a/src/cff/cffobjs.c +++ b/src/cff/cffobjs.c @@ -25,6 +25,7 @@ #include FT_TRUETYPE_TAGS_H #include FT_INTERNAL_SFNT_H #include FT_INTERNAL_POSTSCRIPT_NAMES_H +#include FT_INTERNAL_POSTSCRIPT_HINTS_H #include "cffobjs.h" #include "cffload.h" @@ -43,6 +44,178 @@ #define FT_COMPONENT trace_cffobjs + + + /*************************************************************************/ + /* */ + /* SIZE FUNCTIONS */ + /* */ + /* note that we store the global hints in the size's "internal" root */ + /* field */ + /* */ + /*************************************************************************/ + + + static PSH_Globals_Funcs + CFF_Size_Get_Globals_Funcs( CFF_Size size ) + { + CFF_Face face = (CFF_Face) size->face; + CFF_Font* font = face->extra.data; + PSHinter_Interface* pshinter = font->pshinter; + FT_Module module; + + + module = FT_Get_Module( size->face->driver->root.library, + "pshinter" ); + return ( module && pshinter && pshinter->get_globals_funcs ) + ? pshinter->get_globals_funcs( module ) + : 0 ; + } + + + FT_LOCAL_DEF void + CFF_Size_Done( CFF_Size size ) + { + if ( size->internal ) + { + PSH_Globals_Funcs funcs; + + + funcs = CFF_Size_Get_Globals_Funcs( size ); + if ( funcs ) + funcs->destroy( (PSH_Globals)size->internal ); + + size->internal = 0; + } + } + + + FT_LOCAL_DEF FT_Error + CFF_Size_Init( CFF_Size size ) + { + FT_Error error = 0; + PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs( size ); + + + if ( funcs ) + { + PSH_Globals globals; + CFF_Face face = (CFF_Face)size->face; + CFF_Font* font = face->extra.data; + CFF_SubFont* subfont = &font->top_font; + + CFF_Private* cpriv = &subfont->private_dict; + T1_Private priv; + + /* IMPORTANT: the CFF and Type1 private dictionaries have */ + /* slightly different structures, we need to */ + /* synthetize a type1 dictionary on the fly here !! */ + + { + FT_UInt n, count; + + MEM_Set( &priv, 0, sizeof(priv) ); + + count = priv.num_blue_values = cpriv->num_blue_values; + for ( n = 0; n < count; n++ ) + priv.blue_values[n] = cpriv->blue_values[n]; + + count = priv.num_other_blues = cpriv->num_other_blues; + for ( n = 0; n < count; n++ ) + priv.other_blues[n] = cpriv->other_blues[n]; + + count = priv.num_family_blues = cpriv->num_family_blues; + for ( n = 0; n < count; n++ ) + priv.family_blues[n] = cpriv->family_blues[n]; + + count = priv.num_family_other_blues = cpriv->num_family_other_blues; + for ( n = 0; n < count; n++ ) + priv.family_other_blues[n] = cpriv->family_other_blues[n]; + + priv.blue_scale = cpriv->blue_scale; + priv.blue_shift = cpriv->blue_shift; + priv.blue_fuzz = cpriv->blue_fuzz; + + priv.standard_width[0] = (FT_UShort) cpriv->standard_width; + priv.standard_height[0] = (FT_UShort) cpriv->standard_height; + + count = priv.num_snap_widths = cpriv->num_snap_widths; + for ( n = 0; n < count; n++ ) + priv.snap_widths[n] = cpriv->snap_widths[n]; + + count = priv.num_snap_heights = cpriv->num_snap_heights; + for ( n = 0; n < count; n++ ) + priv.snap_heights[n] = cpriv->snap_heights[n]; + + priv.force_bold = cpriv->force_bold; + priv.language_group = cpriv->language_group; + priv.lenIV = cpriv->lenIV; + } + + error = funcs->create( size->face->memory, &priv, &globals ); + if ( !error ) + size->internal = (FT_Size_Internal)(void*)globals; + } + + return error; + } + + + FT_LOCAL_DEF FT_Error + CFF_Size_Reset( CFF_Size size ) + { + PSH_Globals_Funcs funcs = CFF_Size_Get_Globals_Funcs( size ); + FT_Error error = 0; + + + if ( funcs ) + error = funcs->set_scale( (PSH_Globals)size->internal, + size->metrics.x_scale, + size->metrics.y_scale, + 0, 0 ); + return error; + } + + + /*************************************************************************/ + /* */ + /* SLOT FUNCTIONS */ + /* */ + /*************************************************************************/ + + FT_LOCAL_DEF void + CFF_GlyphSlot_Done( CFF_GlyphSlot slot ) + { + slot->root.internal->glyph_hints = 0; + } + + + FT_LOCAL_DEF FT_Error + CFF_GlyphSlot_Init( CFF_GlyphSlot slot ) + { + CFF_Face face = (CFF_Face) slot->root.face; + CFF_Font* font = face->extra.data; + PSHinter_Interface* pshinter = font->pshinter; + + if (pshinter) + { + FT_Module module; + + module = FT_Get_Module( slot->root.face->driver->root.library, "pshinter" ); + if (module) + { + T2_Hints_Funcs funcs; + + funcs = pshinter->get_t2_funcs( module ); + slot->root.internal->glyph_hints = (void*)funcs; + } + } + return 0; + } + + + + /*************************************************************************/ /* */ /* FACE FUNCTIONS */ @@ -240,7 +413,7 @@ /*************************************************************************/ /* */ /* */ - /* CFF_Init_Face */ + /* CFF_Face_Init */ /* */ /* */ /* Initializes a given OpenType face object. */ @@ -261,7 +434,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF FT_Error - CFF_Init_Face( FT_Stream stream, + CFF_Face_Init( FT_Stream stream, CFF_Face face, FT_Int face_index, FT_Int num_params, @@ -270,6 +443,7 @@ FT_Error error; SFNT_Interface* sfnt; PSNames_Interface* psnames; + PSHinter_Interface* pshinter; FT_Bool pure_cff = 1; FT_Bool sfnt_format = 0; @@ -282,6 +456,9 @@ psnames = (PSNames_Interface*)FT_Get_Module_Interface( face->root.driver->root.library, "psnames" ); + pshinter = (PSHinter_Interface*)FT_Get_Module_Interface( + face->root.driver->root.library, "pshinter" ); + /* create input stream from resource */ if ( FILE_Seek( 0 ) ) goto Exit; @@ -356,10 +533,14 @@ if ( error ) goto Exit; + cff->pshinter = pshinter; + /* Complement the root flags with some interesting information. */ /* Note that this is only necessary for pure CFF and CEF fonts. */ root = &face->root; + + root->num_glyphs = cff->num_glyphs; if ( pure_cff ) { CFF_Font_Dict* dict = &cff->top_font.font_dict; @@ -368,7 +549,7 @@ /* we need the `PSNames' module for pure-CFF and CEF formats */ if ( !psnames ) { - FT_ERROR(( "CFF_Init_Face:" )); + FT_ERROR(( "CFF_Face_Init:" )); FT_ERROR(( " cannot open CFF & CEF fonts\n" )); FT_ERROR(( " " )); FT_ERROR(( " without the `PSNames' module\n" )); @@ -503,7 +684,7 @@ /*************************************************************************/ /* */ /* */ - /* CFF_Done_Face */ + /* CFF_Face_Done */ /* */ /* */ /* Finalizes a given face object. */ @@ -512,7 +693,7 @@ /* face :: A pointer to the face object to destroy. */ /* */ FT_LOCAL_DEF void - CFF_Done_Face( CFF_Face face ) + CFF_Face_Done( CFF_Face face ) { FT_Memory memory = face->root.memory; SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt; @@ -537,7 +718,7 @@ /*************************************************************************/ /* */ /* */ - /* CFF_Init_Driver */ + /* CFF_Driver_Init */ /* */ /* */ /* Initializes a given OpenType driver object. */ @@ -549,7 +730,7 @@ /* FreeType error code. 0 means success. */ /* */ FT_LOCAL_DEF FT_Error - CFF_Init_Driver( CFF_Driver driver ) + CFF_Driver_Init( CFF_Driver driver ) { /* init extension registry if needed */ @@ -570,7 +751,7 @@ /*************************************************************************/ /* */ /* */ - /* CFF_Done_Driver */ + /* CFF_Driver_Done */ /* */ /* */ /* Finalizes a given OpenType driver. */ @@ -579,7 +760,7 @@ /* driver :: A handle to the target OpenType driver. */ /* */ FT_LOCAL_DEF void - CFF_Done_Driver( CFF_Driver driver ) + CFF_Driver_Done( CFF_Driver driver ) { /* destroy extensions registry if needed */ diff --git a/src/cff/cffobjs.h b/src/cff/cffobjs.h index 10b2e6148..709bbe332 100644 --- a/src/cff/cffobjs.h +++ b/src/cff/cffobjs.h @@ -109,19 +109,34 @@ FT_BEGIN_HEADER } CFF_DriverRec; + FT_LOCAL FT_Error + CFF_Size_Init( CFF_Size size ); + + FT_LOCAL void + CFF_Size_Done( CFF_Size size ); + + FT_LOCAL FT_Error + CFF_Size_Reset( CFF_Size size ); + + FT_LOCAL void + CFF_GlyphSlot_Done( CFF_GlyphSlot slot ); + + FT_LOCAL FT_Error + CFF_GlyphSlot_Init( CFF_GlyphSlot slot ); + /*************************************************************************/ /* */ /* Face functions */ /* */ FT_LOCAL FT_Error - CFF_Init_Face( FT_Stream stream, + CFF_Face_Init( FT_Stream stream, CFF_Face face, FT_Int face_index, FT_Int num_params, FT_Parameter* params ); FT_LOCAL void - CFF_Done_Face( CFF_Face face ); + CFF_Face_Done( CFF_Face face ); /*************************************************************************/ @@ -129,10 +144,10 @@ FT_BEGIN_HEADER /* Driver functions */ /* */ FT_LOCAL FT_Error - CFF_Init_Driver( CFF_Driver driver ); + CFF_Driver_Init( CFF_Driver driver ); FT_LOCAL void - CFF_Done_Driver( CFF_Driver driver ); + CFF_Driver_Done( CFF_Driver driver ); FT_END_HEADER diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c index c78d55258..85dd95efd 100644 --- a/src/pshinter/pshrec.c +++ b/src/pshinter/pshrec.c @@ -1158,24 +1158,32 @@ FT_Int count, FT_Fixed* coords ) { - FT_Long stems[32], n, total = count; + FT_Pos stems[32], y, n, total = count; + y = 0; while ( total > 0 ) { /* determine number of stems to write */ count = total; - if ( count > 32 ) - count = 32; + if ( count > 16 ) + count = 16; - /* compute integer stem position in font units */ + /* compute integer stem positions in font units */ for ( n = 0; n < count * 2; n++ ) - stems[n] = ( coords[n] + 0x8000 ) >> 16; + { + y += coords[n]; + stems[n] = ( y + 0x8000 ) >> 16; + } + + /* compute lengths */ + for ( n = 0; n < count*2; n += 2 ) + stems[n+1] = stems[n+1] - stems[n]; /* add them to the current dimension */ ps_hints_stem( (PS_Hints)hints, dimension, count, stems ); - total -= count >> 1; + total -= count; } }