diff --git a/src/base/ftinit.c b/src/base/ftinit.c index 8b5dabe42..6035486ea 100644 --- a/src/base/ftinit.c +++ b/src/base/ftinit.c @@ -115,7 +115,7 @@ const FT_DriverInterface* ft_default_drivers[] = /* library :: A handle to a new library object. */ /* */ /* */ - /* FreeTyoe error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ FT_EXPORT_FUNC( FT_Error ) FT_Init_FreeType( FT_Library* library ) { diff --git a/src/cff/t2driver.c b/src/cff/t2driver.c index ec5d49df2..a2f051729 100644 --- a/src/cff/t2driver.c +++ b/src/cff/t2driver.c @@ -78,7 +78,7 @@ /* formats. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* Only horizontal layouts (left-to-right & right-to-left) are */ @@ -181,7 +181,7 @@ /* size :: A handle to the target size object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Set_Char_Sizes( T2_Size size, @@ -239,7 +239,7 @@ /* size :: A handle to the target size object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Set_Pixel_Sizes( T2_Size size, @@ -277,7 +277,7 @@ /* whether to hint the outline, etc). */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Load_Glyph( T2_GlyphSlot slot, diff --git a/src/cff/t2gload.c b/src/cff/t2gload.c index c1e4ae9d8..4114925bf 100644 --- a/src/cff/t2gload.c +++ b/src/cff/t2gload.c @@ -550,7 +550,7 @@ /* charstring_len :: The length in bytes of the charstring stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error T2_Parse_CharStrings( T2_Decoder* decoder, diff --git a/src/cff/t2objs.c b/src/cff/t2objs.c index 44826ee1d..cf57ed802 100644 --- a/src/cff/t2objs.c +++ b/src/cff/t2objs.c @@ -68,7 +68,7 @@ /* face :: The newly built face object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeTrue error code. 0 means success. */ /* */ LOCAL_DEF FT_Error T2_Init_Face( FT_Stream stream, @@ -205,7 +205,7 @@ /* size :: A handle to the size object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_DEF FT_Error T2_Init_Size( T2_Size size ) @@ -247,7 +247,7 @@ /* size :: A handle to the target size object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_DEF FT_Error T2_Reset_Size( T2_Size size ) @@ -288,7 +288,7 @@ /* slot :: The glyph record to build. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error T2_Init_GlyphSlot( T2_GlyphSlot slot ) @@ -342,7 +342,7 @@ /* driver :: A handle to the target driver object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error T2_Init_Driver( T2_Driver driver ) diff --git a/src/cid/cidafm.c b/src/cid/cidafm.c index bbd5a8ccc..f75f5b7bc 100644 --- a/src/cid/cidafm.c +++ b/src/cid/cidafm.c @@ -36,9 +36,11 @@ #define FT_COMPONENT trace_cidafm +#if 0 + LOCAL_FUNC - void CID_Done_AFM( FT_Memory memory, - T1_AFM* afm ) + void CID_Done_AFM( FT_Memory memory, + T1_AFM* afm ) { FREE( afm->kern_pairs ); afm->num_pairs = 0; @@ -178,7 +180,7 @@ limit = (FT_Byte*)stream->limit; p = start; - /* we are now going to count the occurences of "KP" or "KPX" in */ + /* we are now going to count the occurences of `KP' or `KPX' in */ /* the AFM file. */ count = 0; for ( p = start; p < limit - 3; p++ ) @@ -279,5 +281,7 @@ kerning->y = 0; } +#endif /* 0 */ + /* END */ diff --git a/src/cid/cidafm.h b/src/cid/cidafm.h index 89d47f2eb..00babec7e 100644 --- a/src/cid/cidafm.h +++ b/src/cid/cidafm.h @@ -21,6 +21,7 @@ #include + typedef struct T1_Kern_Pair_ { FT_UInt glyph1; @@ -39,21 +40,22 @@ #if 0 -LOCAL_DEF -FT_Error CID_Read_AFM( FT_Face face, - FT_Stream stream ); + LOCAL_DEF + FT_Error CID_Read_AFM( FT_Face t1_face, + FT_Stream stream ); -LOCAL_DEF -void CID_Done_AFM( FT_Memory memory, - T1_AFM* afm ); + LOCAL_DEF + void CID_Done_AFM( FT_Memory memory, + T1_AFM* afm ); -LOCAL_DEF -void CID_Get_Kerning( T1_AFM* afm, - FT_UInt glyph1, - FT_UInt glyph2, - FT_Vector* kerning ); + LOCAL_DEF + void CID_Get_Kerning( T1_AFM* afm, + FT_UInt glyph1, + FT_UInt glyph2, + FT_Vector* kerning ); + +#endif /* 0 */ -#endif #endif /* CIDAFM_H */ diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c index 99ff5c111..8fe3fb058 100644 --- a/src/cid/cidgload.c +++ b/src/cid/cidgload.c @@ -473,7 +473,7 @@ /* achar :: The accent character's StandardEncoding charcode. */ /* */ /* */ - /* Type 1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error t1operator_seac( CID_Decoder* decoder, @@ -626,7 +626,7 @@ /* charstring_len :: The length in bytes of the charstring stream. */ /* */ /* */ - /* Type1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error CID_Parse_CharStrings( CID_Decoder* decoder, diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index 495712b25..4c63beea2 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -72,7 +72,7 @@ /* size :: A handle to the size object. */ /* */ /* */ - /* Type1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_DEF FT_Error CID_Init_Size( T1_Size size ) @@ -96,7 +96,7 @@ /* size :: A handle to the target size object. */ /* */ /* */ - /* Type1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error CID_Reset_Size( T1_Size size ) @@ -201,7 +201,7 @@ /* face :: The newly built face object. */ /* */ /* */ - /* Type1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error CID_Init_Face( FT_Stream stream, @@ -458,7 +458,7 @@ /* slot :: The glyph record to build. */ /* */ /* */ - /* Type1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error CID_Init_GlyphSlot( T1_GlyphSlot glyph ) @@ -486,7 +486,7 @@ /* driver :: A handle to the target driver object. */ /* */ /* */ - /* Type1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error CID_Init_Driver( T1_Driver driver ) diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c index e99f1f209..263022043 100644 --- a/src/cid/cidparse.c +++ b/src/cid/cidparse.c @@ -67,7 +67,7 @@ /* reallocations. */ /* */ /* */ - /* Type1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error T1_New_Table( T1_Table* table, @@ -157,7 +157,7 @@ /* length :: The length in bytes of the source object. */ /* */ /* */ - /* Type1 error code. 0 means success. An error is returned if */ + /* FreeType error code. 0 means success. An error is returned if */ /* reallocation fails. */ /* */ LOCAL_FUNC diff --git a/src/cid/cidriver.c b/src/cid/cidriver.c index 7f86d612c..a3d06c379 100644 --- a/src/cid/cidriver.c +++ b/src/cid/cidriver.c @@ -75,7 +75,7 @@ } -#ifdef xxxT1_CONFIG_OPTION_NO_AFM +#ifndef T1_CONFIG_OPTION_NO_AFM /*************************************************************************/ @@ -116,21 +116,29 @@ FT_UInt right_glyph, FT_Vector* kerning ) { +#if 0 + T1_AFM* afm; +#endif + kerning->x = 0; kerning->y = 0; +#if 0 + afm = (T1_AFM*)face->afm_data; if ( afm ) CID_Get_Kerning( afm, left_glyph, right_glyph, kerning ); +#endif /* 0 */ + return T1_Err_Ok; } -#endif /* xxxT1_CONFIG_OPTION_NO_AFM */ +#endif /* !T1_CONFIG_OPTION_NO_AFM */ /*************************************************************************/ @@ -157,7 +165,7 @@ /* size :: A handle to the target size object. */ /* */ /* */ - /* Type1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Set_Char_Sizes( T1_Size size, @@ -194,7 +202,7 @@ /* size :: A handle to the target size object. */ /* */ /* */ - /* Type1 error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Set_Pixel_Sizes( T1_Size size, @@ -329,7 +337,7 @@ (FTDriver_initFace) CID_Init_Face, (FTDriver_doneFace) CID_Done_Face, -#ifndef xxxxT1_CONFIG_OPTION_NO_AFM +#ifdef T1_CONFIG_OPTION_NO_AFM (FTDriver_getKerning) 0, #else (FTDriver_getKerning) Get_Kerning, diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c index e91d3336c..1a5cbba3d 100644 --- a/src/sfnt/ttcmap.c +++ b/src/sfnt/ttcmap.c @@ -59,7 +59,7 @@ /* table :: A pointer to a cmap object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* The function assumes that the stream is already in use (i.e., */ @@ -281,7 +281,7 @@ /* cmap :: A handle to a cmap object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_CharMap_Free( TT_Face face, diff --git a/src/sfnt/ttload.c b/src/sfnt/ttload.c index effb9d1aa..94e4171f3 100644 --- a/src/sfnt/ttload.c +++ b/src/sfnt/ttload.c @@ -96,7 +96,7 @@ /* length :: The length of the table if found, undefined otherwise. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Goto_Table( TT_Face face, @@ -141,7 +141,7 @@ /* sfnt :: The SFNT header. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* The stream cursor must be at the font file's origin. */ @@ -275,7 +275,7 @@ /* sfnt :: The SFNT directory header. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* The stream cursor must be at the font file's origin. */ @@ -373,7 +373,7 @@ /* buffer :: The address of target buffer. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Any( TT_Face face, @@ -436,7 +436,7 @@ /* stream :: The input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Header( TT_Face face, @@ -507,7 +507,7 @@ /* stream :: The input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_MaxProfile( TT_Face face, @@ -597,7 +597,7 @@ /* vertical :: A boolean flag. If set, load vertical metrics. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error TT_Load_Metrics( TT_Face face, @@ -733,7 +733,7 @@ /* vertical :: A boolean flag. If set, load vertical metrics. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Metrics_Header( TT_Face face, @@ -829,7 +829,7 @@ /* stream :: The input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Names( TT_Face face, @@ -1020,7 +1020,7 @@ /* stream :: A handle to the input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_CMap( TT_Face face, @@ -1129,7 +1129,7 @@ /* stream :: A handle to the input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_OS2( TT_Face face, @@ -1263,7 +1263,7 @@ /* stream :: A handle to the input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_PostScript( TT_Face face, @@ -1318,7 +1318,7 @@ /* stream :: A handle to the input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_PCLT( TT_Face face, @@ -1389,7 +1389,7 @@ /* stream :: The input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Gasp( TT_Face face, @@ -1461,7 +1461,7 @@ /* stream :: The input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Kern( TT_Face face, @@ -1566,7 +1566,7 @@ /* stream :: A handle to the input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Hdmx( TT_Face face, diff --git a/src/sfnt/ttpost.c b/src/sfnt/ttpost.c index 513078295..8fad70562 100644 --- a/src/sfnt/ttpost.c +++ b/src/sfnt/ttpost.c @@ -427,7 +427,7 @@ /* You must not modify the returned string! */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Get_PS_Name( TT_Face face, diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c index ecfb88e69..9768e63be 100644 --- a/src/sfnt/ttsbit.c +++ b/src/sfnt/ttsbit.c @@ -211,7 +211,7 @@ /* stream :: The input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Load_SBit_Const_Metrics( TT_SBit_Range* range, @@ -243,7 +243,7 @@ /* load_offsets :: A flag whether to load the glyph offset table. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Load_SBit_Range_Codes( TT_SBit_Range* range, @@ -306,7 +306,7 @@ /* stream :: The input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Load_SBit_Range( TT_SBit_Range* range, @@ -381,7 +381,7 @@ /* stream :: The input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_SBit_Strikes( TT_Face face, @@ -631,7 +631,7 @@ /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */ /* */ /* */ - /* TrueType error code. 0 means the glyph index was found. */ + /* FreeType error code. 0 means the glyph index was found. */ /* */ static FT_Error Find_SBit_Range( FT_UInt glyph_index, @@ -735,7 +735,7 @@ /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */ /* */ /* */ - /* TrueType error code. 0 means success. Returns */ + /* FreeType error code. 0 means success. Returns */ /* TT_Err_Invalid_Argument if no sbit exists for the requested glyph. */ /* */ static @@ -800,7 +800,7 @@ /* big_metrics :: A big SBit metrics structure for the glyph. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* The stream cursor must be positioned at the glyph's offset within */ @@ -1349,7 +1349,7 @@ /* metrics :: A big sbit metrics structure for the glyph image. */ /* */ /* */ - /* TrueType error code. 0 means success. Returns an error if no */ + /* FreeType error code. 0 means success. Returns an error if no */ /* glyph sbit exists for the index. */ /* */ /* */ diff --git a/src/truetype/ttdriver.c b/src/truetype/ttdriver.c index 23b1b5cd0..635521ee2 100644 --- a/src/truetype/ttdriver.c +++ b/src/truetype/ttdriver.c @@ -75,7 +75,7 @@ /* formats. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* Only horizontal layouts (left-to-right & right-to-left) are */ @@ -178,7 +178,7 @@ /* size :: A handle to the target size object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Set_Char_Sizes( TT_Size size, @@ -238,7 +238,7 @@ /* size :: A handle to the target size object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Set_Pixel_Sizes( TT_Size size, @@ -280,7 +280,7 @@ /* whether to hint the outline, etc). */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Load_Glyph( TT_GlyphSlot slot, diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index a1be11f21..181a5a1be 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -1293,7 +1293,7 @@ /* whether to hint the outline, etc). */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Glyph( TT_Size size, diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c index f98008e1e..cefb1af8b 100644 --- a/src/truetype/ttinterp.c +++ b/src/truetype/ttinterp.c @@ -257,7 +257,7 @@ /* exec :: The target execution context. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Goto_CodeRange( TT_ExecContext exec, @@ -307,7 +307,7 @@ /* exec :: The target execution context. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Set_CodeRange( TT_ExecContext exec, @@ -339,7 +339,7 @@ /* exec :: The target execution context. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* Does not set the Error variable. */ @@ -378,7 +378,7 @@ /* memory :: A handle to the parent memory object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* Only the glyph loader and debugger should call this function. */ @@ -433,7 +433,7 @@ /* exec :: A handle to the target execution context. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Init_Context( TT_ExecContext exec, @@ -504,7 +504,7 @@ /* buff :: The address of the buffer base pointer. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ static FT_Error Update_Max( FT_Memory memory, @@ -546,7 +546,7 @@ /* exec :: A handle to the target execution context. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* Only the glyph loader and debugger should call this function. */ @@ -649,7 +649,7 @@ /* size :: A handle to the target size object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* Only the glyph loader and debugger should call this function. */ @@ -696,7 +696,7 @@ /* exec :: A handle to the target execution context. */ /* */ /* */ - /* TrueTyoe error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* Only the glyph loader and debugger should call this function. */ @@ -834,7 +834,7 @@ /* exec :: A handle to the target execution context. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* Only the glyph loader and debugger should call this function. */ @@ -6781,7 +6781,7 @@ /* exec :: A handle to the target execution context. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ /* */ /* Only the object manager and debugger should call this function. */ diff --git a/src/truetype/ttobjs.c b/src/truetype/ttobjs.c index eefdb6f92..2ac0d2a61 100644 --- a/src/truetype/ttobjs.c +++ b/src/truetype/ttobjs.c @@ -201,7 +201,7 @@ /* face :: The newly built face object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_DEF FT_Error TT_Init_Face( FT_Stream stream, @@ -320,7 +320,7 @@ /* size :: A handle to the size object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_DEF FT_Error TT_Init_Size( TT_Size size ) @@ -709,7 +709,7 @@ /* slot :: The glyph record to build. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Init_GlyphSlot( TT_GlyphSlot slot ) @@ -767,7 +767,7 @@ /* driver :: A handle to the target driver object. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Init_Driver( TT_Driver driver ) diff --git a/src/truetype/ttpload.c b/src/truetype/ttpload.c index 2f143882f..d87bd40cc 100644 --- a/src/truetype/ttpload.c +++ b/src/truetype/ttpload.c @@ -50,7 +50,7 @@ /* stream :: The input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Locations( TT_Face face, @@ -143,7 +143,7 @@ /* stream :: A handle to the input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_CVT( TT_Face face, @@ -210,7 +210,7 @@ /* stream :: A handle to the input stream. */ /* */ /* */ - /* TrueType error code. 0 means success. */ + /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC FT_Error TT_Load_Programs( TT_Face face, diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c index 806b84ccb..fbc460d37 100644 --- a/src/type1/t1afm.c +++ b/src/type1/t1afm.c @@ -1,51 +1,86 @@ -/*************************************************************************** - * - * t1afm.c - support for reading Type 1 AFM files - * - * - ***************************************************************************/ +/***************************************************************************/ +/* */ +/* t1afm.c */ +/* */ +/* AFM support for Type 1 fonts (body). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + +#include #include #include -#include /* for qsort */ -#include + +#include /* for qsort() */ +#include /* for strcmp() */ +#include /* for isalnum() */ + + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_t1afm + LOCAL_FUNC - void T1_Done_AFM( FT_Memory memory, T1_AFM* afm ) + void T1_Done_AFM( FT_Memory memory, + T1_AFM* afm ) { FREE( afm->kern_pairs ); afm->num_pairs = 0; } + #undef IS_KERN_PAIR -#define IS_KERN_PAIR(p) ( p[0] == 'K' && p[1] == 'P' ) +#define IS_KERN_PAIR( p ) ( p[0] == 'K' && p[1] == 'P' ) -#define IS_ALPHANUM(c) ( (c >= 'A' && c <= 'Z') || \ - (c >= 'a' && c <= 'z') || \ - (c >= '0' && c <= '9') || \ - (c == '_' && c == '.') ) +#define IS_ALPHANUM( c ) ( isalnum( c ) || \ + c == '_' || \ + c == '.' ) - /* read a glyph name and return the equivalent glyph index */ + + /* read a glyph name and return the equivalent glyph index */ static - FT_UInt afm_atoindex( FT_Byte* *start, FT_Byte* limit, T1_Font* type1 ) + FT_UInt afm_atoindex( FT_Byte** start, + FT_Byte* limit, + T1_Font* type1 ) { - FT_Byte* p = *start; - FT_Int len; - FT_UInt result = 0; - char temp[64]; + FT_Byte* p = *start; + FT_Int len; + FT_UInt result = 0; + char temp[64]; + /* skip whitespace */ - while ( (*p == ' ' || *p == '\t' || *p == ':' || *p == ';') && p < limit ) + while ( ( *p == ' ' || *p == '\t' || *p == ':' || *p == ';' ) && + p < limit ) p++; *start = p; /* now, read glyph name */ - while ( IS_ALPHANUM(*p) && p < limit ) p++; + while ( IS_ALPHANUM( *p ) && p < limit ) + p++; + len = p - *start; - if (len > 0 && len < 64) + + if ( len > 0 && len < 64 ) { FT_Int n; + /* copy glyph name to intermediate array */ MEM_Copy( temp, *start, len ); temp[len] = 0; @@ -55,7 +90,8 @@ { char* gname = (char*)type1->glyph_names[n]; - if ( gname && gname[0] == temp[0] && strcmp(gname,temp) == 0 ) + + if ( gname && gname[0] == temp[0] && strcmp( gname, temp ) == 0 ) { result = n; break; @@ -67,16 +103,18 @@ } - /* read an integer */ + /* read an integer */ static - int afm_atoi( FT_Byte** start, FT_Byte* limit ) + int afm_atoi( FT_Byte** start, + FT_Byte* limit ) { FT_Byte* p = *start; int sum = 0; int sign = 1; + /* skip everything that is not a number */ - while ( p < limit && (*p < '0' || *p > '9') ) + while ( p < limit && !isdigit( *p ) ) { sign = 1; if (*p == '-') @@ -85,38 +123,41 @@ p++; } - while ( p < limit && (*p >= '0' && *p < '9') ) + while ( p < limit && isdigit( *p ) ) { - sum = sum*10 + (*p - '0'); + sum = sum * 10 + ( *p - '0' ); p++; } *start = p; - return sum*sign; + + return sum * sign; } #undef KERN_INDEX -#define KERN_INDEX(g1,g2) (((FT_ULong)g1 << 16) | g2) +#define KERN_INDEX( g1, g2 ) ( ( (FT_ULong)g1 << 16 ) | g2 ) - /* compare two kerning pairs */ + + /* compare two kerning pairs */ static - int compare_kern_pairs( const void* a, const void* b ) + int compare_kern_pairs( const void* a, + const void* b ) { T1_Kern_Pair* pair1 = (T1_Kern_Pair*)a; T1_Kern_Pair* pair2 = (T1_Kern_Pair*)b; - FT_ULong index1 = KERN_INDEX(pair1->glyph1,pair1->glyph2); - FT_ULong index2 = KERN_INDEX(pair2->glyph1,pair2->glyph2); + FT_ULong index1 = KERN_INDEX( pair1->glyph1, pair1->glyph2 ); + FT_ULong index2 = KERN_INDEX( pair2->glyph1, pair2->glyph2 ); - return ( index1 < index2 ? -1 : - ( index1 > index2 ? 1 : 0 )); + + return ( index1 - index2 ); } - /* parse an AFM file - for now, only read the kerning pairs */ + /* parse an AFM file - for now, only read the kerning pairs */ LOCAL_FUNC - FT_Error T1_Read_AFM( FT_Face t1_face, - FT_Stream stream ) + FT_Error T1_Read_AFM( FT_Face t1_face, + FT_Stream stream ) { FT_Error error; FT_Memory memory = stream->memory; @@ -128,28 +169,29 @@ T1_Font* type1 = &((T1_Face)t1_face)->type1; T1_AFM* afm = 0; - if ( ACCESS_Frame(stream->size) ) + + if ( ACCESS_Frame( stream->size ) ) return error; start = (FT_Byte*)stream->cursor; limit = (FT_Byte*)stream->limit; p = start; - /* we are now going to count the occurences of "KP" or "KPX" in */ - /* the AFM file.. */ + /* we are now going to count the occurences of `KP' or `KPX' in */ + /* the AFM file. */ count = 0; - for ( p = start; p < limit-3; p++ ) + for ( p = start; p < limit - 3; p++ ) { - if ( IS_KERN_PAIR(p) ) + if ( IS_KERN_PAIR( p ) ) count++; } - /* Actually, kerning pairs are simply optional !! */ - if (count == 0) + /* Actually, kerning pairs are simply optional! */ + if ( count == 0 ) goto Exit; /* allocate the pairs */ - if ( ALLOC( afm, sizeof(*afm ) ) || + if ( ALLOC( afm, sizeof ( *afm ) ) || ALLOC_ARRAY( afm->kern_pairs, count, T1_Kern_Pair ) ) goto Exit; @@ -160,15 +202,17 @@ /* save in face object */ ((T1_Face)t1_face)->afm_data = afm; - for ( p = start; p < limit-3; p++ ) + for ( p = start; p < limit - 3; p++ ) { - if ( IS_KERN_PAIR(p) ) + if ( IS_KERN_PAIR( p ) ) { FT_Byte* q; + /* skip keyword (KP or KPX) */ - q = p+2; - if (*q == 'X') q++; + q = p + 2; + if ( *q == 'X' ) + q++; pair->glyph1 = afm_atoindex( &q, limit, type1 ); pair->glyph2 = afm_atoindex( &q, limit, type1 ); @@ -183,18 +227,20 @@ } /* now, sort the kern pairs according to their glyph indices */ - qsort( afm->kern_pairs, count, sizeof(T1_Kern_Pair), compare_kern_pairs ); + qsort( afm->kern_pairs, count, sizeof ( T1_Kern_Pair ), + compare_kern_pairs ); Exit: - if (error) + if ( error ) FREE( afm ); FORGET_Frame(); + return error; } - /* find the kerning for a given glyph pair */ + /* find the kerning for a given glyph pair */ LOCAL_FUNC void T1_Get_Kerning( T1_AFM* afm, FT_UInt glyph1, @@ -202,28 +248,35 @@ FT_Vector* kerning ) { T1_Kern_Pair *min, *mid, *max; - FT_ULong index = KERN_INDEX(glyph1,glyph2); + FT_ULong index = KERN_INDEX( glyph1, glyph2 ); + /* simple binary search */ min = afm->kern_pairs; - max = min + afm->num_pairs-1; + max = min + afm->num_pairs - 1; - while (min <= max) + while ( min <= max ) { FT_ULong midi; - mid = min + (max-min)/2; - midi = KERN_INDEX(mid->glyph1,mid->glyph2); + + mid = min + ( max - min ) / 2; + midi = KERN_INDEX( mid->glyph1, mid->glyph2 ); if ( midi == index ) { *kerning = mid->kerning; return; } - if ( midi < index ) min = mid+1; - else max = mid-1; + if ( midi < index ) + min = mid + 1; + else + max = mid - 1; } + kerning->x = 0; kerning->y = 0; } + +/* END */ diff --git a/src/type1/t1afm.h b/src/type1/t1afm.h index 984ae945c..1e9bba0c0 100644 --- a/src/type1/t1afm.h +++ b/src/type1/t1afm.h @@ -1,47 +1,59 @@ -/*************************************************************************** - * - * t1afm.h - support for reading Type 1 AFM files - * - * - ***************************************************************************/ +/***************************************************************************/ +/* */ +/* t1afm.h */ +/* */ +/* AFM support for Type 1 fonts (specification). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + #ifndef T1AFM_H #define T1AFM_H #include -/* In this version, we only read the kerning table from the */ -/* AFM file. We may add support for ligatures a bit later.. */ -typedef struct T1_Kern_Pair_ -{ - FT_UInt glyph1; - FT_UInt glyph2; - FT_Vector kerning; + typedef struct T1_Kern_Pair_ + { + FT_UInt glyph1; + FT_UInt glyph2; + FT_Vector kerning; -} T1_Kern_Pair; + } T1_Kern_Pair; + + typedef struct T1_AFM_ + { + FT_Int num_pairs; + T1_Kern_Pair* kern_pairs; + + } T1_AFM; -typedef struct T1_AFM_ -{ - FT_Int num_pairs; - T1_Kern_Pair* kern_pairs; + LOCAL_DEF + FT_Error T1_Read_AFM( FT_Face face, + FT_Stream stream ); -} T1_AFM; + LOCAL_DEF + void T1_Done_AFM( FT_Memory memory, + T1_AFM* afm ); + LOCAL_DEF + void T1_Get_Kerning( T1_AFM* afm, + FT_UInt glyph1, + FT_UInt glyph2, + FT_Vector* kerning ); -LOCAL_DEF -FT_Error T1_Read_AFM( FT_Face face, - FT_Stream stream ); - -LOCAL_DEF -void T1_Done_AFM( FT_Memory memory, - T1_AFM* afm ); - -LOCAL_DEF -void T1_Get_Kerning( T1_AFM* afm, - FT_UInt glyph1, - FT_UInt glyph2, - FT_Vector* kerning ); #endif /* T1AFM_H */ + + +/* END */ diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c index 04f7f31dd..504f87c05 100644 --- a/src/type1/t1driver.c +++ b/src/type1/t1driver.c @@ -1,19 +1,20 @@ -/******************************************************************* - * - * t1driver.c - * - * High-level Type1 driver interface for FreeType 2.0 - * - * Copyright 1996-1998 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used, - * modified, and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ +/***************************************************************************/ +/* */ +/* t1driver.c */ +/* */ +/* Type 1 driver interface (body). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + #include #include @@ -23,10 +24,20 @@ #include #include + + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ #undef FT_COMPONENT #define FT_COMPONENT trace_t1driver + #ifndef T1_CONFIG_OPTION_NO_AFM + + /*************************************************************************/ /* */ /* */ @@ -58,7 +69,7 @@ FTDriver_Interface Get_Interface( FT_Driver driver, const FT_String* interface ) { - UNUSED(driver); + UNUSED( driver ); if ( strcmp( (const char*)interface, "attach_file" ) == 0 ) return (FTDriver_Interface)T1_Read_AFM; @@ -108,87 +119,97 @@ { T1_AFM* afm; + kerning->x = 0; kerning->y = 0; afm = (T1_AFM*)face->afm_data; - if (afm) + if ( afm ) T1_Get_Kerning( afm, left_glyph, right_glyph, kerning ); return T1_Err_Ok; } -#endif - /******************************************************************/ - /* */ - /* Set_Char_Sizes */ - /* */ - /* */ - /* A driver method used to reset a size's character sizes */ - /* (horizontal and vertical) expressed in fractional points. */ - /* */ - /* */ - /* size :: handle to target size object */ - /* char_width :: character width expressed in 26.6 points */ - /* char_height :: character height expressed in 26.6 points */ - /* */ - /* */ - /* FreeType error code. 0 means success */ - /* */ + +#endif /* !T1_CONFIG_OPTION_NO_AFM */ + + + /*************************************************************************/ + /* */ + /* */ + /* Set_Char_Sizes */ + /* */ + /* */ + /* A driver method used to reset a size's character sizes (horizontal */ + /* and vertical) expressed in fractional points. */ + /* */ + /* */ + /* char_width :: The character width expressed in 26.6 */ + /* fractional points. */ + /* */ + /* char_height :: The character height expressed in 26.6 */ + /* fractional points. */ + /* */ + /* horz_resolution :: The horizontal resolution of the output device. */ + /* */ + /* vert_resolution :: The vertical resolution of the output device. */ + /* */ + /* */ + /* size :: A handle to the target size object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ static - FT_Error Set_Char_Sizes( T1_Size size, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ) + FT_Error Set_Char_Sizes( T1_Size size, + FT_F26Dot6 char_width, + FT_F26Dot6 char_height, + FT_UInt horz_resolution, + FT_UInt vert_resolution ) { - UNUSED(char_width); - UNUSED(char_height); - UNUSED(horz_resolution); - UNUSED(vert_resolution); + UNUSED( char_width ); + UNUSED( char_height ); + UNUSED( horz_resolution ); + UNUSED( vert_resolution ); size->valid = FALSE; return T1_Reset_Size( size ); } - /******************************************************************/ - /* */ - /* Set_Pixel_Sizes */ - /* */ - /* */ - /* A driver method used to reset a size's character sizes */ - /* (horizontal and vertical) expressed in integer pixels. */ - /* */ - /* */ - /* size :: handle to target size object */ - /* */ - /* pixel_width :: character width expressed in 26.6 points */ - /* */ - /* pixel_height :: character height expressed in 26.6 points */ - /* */ - /* char_size :: the corresponding character size in points */ - /* This value is only sent to the TrueType */ - /* bytecode interpreter, even though 99% of */ - /* glyph programs will simply ignore it. A */ - /* safe value there is the maximum of the */ - /* pixel width and height (multiplied by */ - /* 64 to make it a 26.6 fixed float !) */ - /* */ - /* FreeType error code. 0 means success */ - /* */ + /*************************************************************************/ + /* */ + /* */ + /* Set_Pixel_Sizes */ + /* */ + /* */ + /* A driver method used to reset a size's character sizes (horizontal */ + /* and vertical) expressed in integer pixels. */ + /* */ + /* */ + /* pixel_width :: The character width expressed in integer pixels. */ + /* */ + /* pixel_height :: The character height expressed in integer pixels. */ + /* */ + /* */ + /* size :: A handle to the target size object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ static - FT_Error Set_Pixel_Sizes( T1_Size size, - FT_Int pixel_width, - FT_Int pixel_height ) + FT_Error Set_Pixel_Sizes( T1_Size size, + FT_Int pixel_width, + FT_Int pixel_height ) { - UNUSED(pixel_width); - UNUSED(pixel_height); + UNUSED( pixel_width ); + UNUSED( pixel_height ); size->valid = FALSE; - return T1_Reset_Size(size); + return T1_Reset_Size( size ); } + /*************************************************************************/ /* */ /* */ @@ -212,154 +233,82 @@ FT_UInt result = 0; PSNames_Interface* psnames; + face = (T1_Face)charmap->face; psnames = (PSNames_Interface*)face->psnames; - if (psnames) - switch (charmap->encoding) + if ( psnames ) + switch ( charmap->encoding ) { - /********************************************************************/ - /* */ - /* Unicode encoding support */ - /* */ - case ft_encoding_unicode: - { - /* use the "psnames" module to synthetize the Unicode charmap */ - result = psnames->lookup_unicode( &face->unicode_map, - (FT_ULong)charcode ); + /*******************************************************************/ + /* */ + /* Unicode encoding support */ + /* */ + case ft_encoding_unicode: + /* use the `PSNames' module to synthetize the Unicode charmap */ + result = psnames->lookup_unicode( &face->unicode_map, + (FT_ULong)charcode ); - /* the function returns 0xFFFF when the Unicode charcode has */ - /* no corresponding glyph.. */ - if (result == 0xFFFF) - result = 0; - goto Exit; - } + /* the function returns 0xFFFF if the Unicode charcode has */ + /* no corresponding glyph. */ + if ( result == 0xFFFF ) + result = 0; + goto Exit; - /********************************************************************/ - /* */ - /* Custom Type 1 encoding */ - /* */ - case ft_encoding_adobe_custom: + /*******************************************************************/ + /* */ + /* Custom Type 1 encoding */ + /* */ + case ft_encoding_adobe_custom: + { + T1_Encoding* encoding = &face->type1.encoding; + + + if ( charcode >= encoding->code_first && + charcode <= encoding->code_last ) + result = encoding->char_index[charcode]; + goto Exit; + } + + /*******************************************************************/ + /* */ + /* Adobe Standard & Expert encoding support */ + /* */ + default: + if ( charcode < 256 ) + { + FT_UInt code; + FT_Int n; + const char* glyph_name; + + + code = psnames->adobe_std_encoding[charcode]; + if ( charmap->encoding == ft_encoding_adobe_expert ) + code = psnames->adobe_expert_encoding[charcode]; + + glyph_name = psnames->adobe_std_strings( code ); + if ( !glyph_name ) + break; + + for ( n = 0; n < face->type1.num_glyphs; n++ ) { - T1_Encoding* encoding = &face->type1.encoding; - if (charcode >= encoding->code_first && - charcode <= encoding->code_last) + const char* gname = face->type1.glyph_names[n]; + + + if ( gname && gname[0] == glyph_name[0] && + strcmp( gname, glyph_name ) == 0 ) { - result = encoding->char_index[charcode]; + result = n; + break; } - goto Exit; } - - /********************************************************************/ - /* */ - /* Adobe Standard & Expert encoding support */ - /* */ - default: - if (charcode < 256) - { - FT_UInt code; - FT_Int n; - const char* glyph_name; - - code = psnames->adobe_std_encoding[charcode]; - if (charmap->encoding == ft_encoding_adobe_expert) - code = psnames->adobe_expert_encoding[charcode]; - - glyph_name = psnames->adobe_std_strings(code); - if (!glyph_name) break; - - for ( n = 0; n < face->type1.num_glyphs; n++ ) - { - const char* gname = face->type1.glyph_names[n]; - - if ( gname && gname[0] == glyph_name[0] && - strcmp( gname, glyph_name ) == 0 ) - { - result = n; - break; - } - } - } + } } + Exit: return result; } - - /******************************************************************/ - /* */ - /* FT_DriverInterface */ - /* */ - /* */ - /* A structure used to hold a font driver's basic interface */ - /* used by the high-level parts of FreeType (or other apps) */ - /* */ - /* Most scalable drivers provide a specialized interface to */ - /* access format-specific features. It can be retrieved with */ - /* a call to the "get_format_interface", and should be defined */ - /* in each font driver header (e.g. ttdriver.h, t1driver.h,..) */ - /* */ - /* All fields are function pointers .. */ - /* */ - /* */ - /* */ - /* */ - /* new_engine :: */ - /* used to create and initialise a new driver object */ - /* */ - /* done_engine :: */ - /* used to finalise and destroy a given driver object */ - /* */ - /* get_format_interface :: */ - /* return a typeless pointer to the format-specific */ - /* driver interface. */ - /* */ - /* new_face :: */ - /* create a new face object from a resource */ - /* */ - /* done_face :: */ - /* discards a face object, as well as all child objects */ - /* ( sizes, charmaps, glyph slots ) */ - /* */ - /* get_face_properties :: */ - /* return generic face properties */ - /* */ - /* get_kerning :: */ - /* return the kerning vector corresponding to a pair */ - /* of glyphs, expressed in unscaled font units. */ - /* */ - /* new_size :: */ - /* create and initialise a new scalable size object. */ - /* */ - /* new_fixed_size :: */ - /* create and initialise a new fixed-size object. */ - /* */ - /* done_size :: */ - /* finalize a given face size object. */ - /* */ - /* set_size_resolutions :: */ - /* reset a scalable size object's output resolutions */ - /* */ - /* set_size_char_sizes :: */ - /* reset a scalable size object's character size */ - /* */ - /* set_pixel_sizes :: */ - /* reset a face size object's pixel dimensions. Applies */ - /* to both scalable and fixed faces. */ - /* */ - /* new_glyph_slot :: */ - /* create and initialise a new glyph slot */ - /* */ - /* done_glyph_slot :: */ - /* discard a given glyph slot */ - /* */ - /* load_glyph :: */ - /* load a given glyph into a given slot */ - /* */ - /* get_glyph_metrics :: */ - /* return a loaded glyph's metrics. */ - /* */ - const FT_DriverInterface t1_driver_interface = { sizeof( FT_DriverRec ), @@ -373,64 +322,66 @@ 0, /* format interface */ - (FTDriver_initDriver) T1_Init_Driver, - (FTDriver_doneDriver) T1_Done_Driver, + (FTDriver_initDriver) T1_Init_Driver, + (FTDriver_doneDriver) T1_Done_Driver, #ifdef T1_CONFIG_OPTION_NO_AFM - (FTDriver_getInterface) 0, + (FTDriver_getInterface) 0, #else - (FTDriver_getInterface) Get_Interface, + (FTDriver_getInterface) Get_Interface, #endif - (FTDriver_initFace) T1_Init_Face, - (FTDriver_doneFace) T1_Done_Face, + (FTDriver_initFace) T1_Init_Face, + (FTDriver_doneFace) T1_Done_Face, #ifdef T1_CONFIG_OPTION_NO_AFM - (FTDriver_getKerning) 0, + (FTDriver_getKerning) 0, #else - (FTDriver_getKerning) Get_Kerning, + (FTDriver_getKerning) Get_Kerning, #endif - (FTDriver_initSize) T1_Init_Size, - (FTDriver_doneSize) T1_Done_Size, - (FTDriver_setCharSizes) Set_Char_Sizes, - (FTDriver_setPixelSizes) Set_Pixel_Sizes, + (FTDriver_initSize) T1_Init_Size, + (FTDriver_doneSize) T1_Done_Size, + (FTDriver_setCharSizes) Set_Char_Sizes, + (FTDriver_setPixelSizes)Set_Pixel_Sizes, - (FTDriver_initGlyphSlot) T1_Init_GlyphSlot, - (FTDriver_doneGlyphSlot) T1_Done_GlyphSlot, - (FTDriver_loadGlyph) T1_Load_Glyph, + (FTDriver_initGlyphSlot)T1_Init_GlyphSlot, + (FTDriver_doneGlyphSlot)T1_Done_GlyphSlot, + (FTDriver_loadGlyph) T1_Load_Glyph, - (FTDriver_getCharIndex) Get_Char_Index, + (FTDriver_getCharIndex) Get_Char_Index, }; - /******************************************************************/ - /* */ - /* Get_FreeType_Driver_Interface */ - /* */ - /* */ - /* This function is used when compiling the TrueType driver */ - /* as a shared library (.DLL or .so). It will be used by the */ - /* high-level library of FreeType to retrieve the address of */ - /* the driver's generic interface. */ - /* */ - /* It shouldn't be implemented in a static build, as each */ - /* driver must have the same function as an exported entry */ - /* point. */ - /* */ - /* */ - /* address of TrueType's driver generic interface. The */ - /* forma-specific interface can then be retrieved through */ - /* the method interface->get_format_interface.. */ - /* */ - #ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS - EXPORT_FUNC(FT_DriverInterface*) getDriverInterface( void ) + + /*************************************************************************/ + /* */ + /* */ + /* getDriverInterface */ + /* */ + /* */ + /* This function is used when compiling the CID driver as a shared */ + /* library (`.DLL' or `.so'). It will be used by the high-level */ + /* library of FreeType to retrieve the address of the driver's */ + /* generic interface. */ + /* */ + /* It shouldn't be implemented in a static build, as each driver must */ + /* have the same function as an exported entry point. */ + /* */ + /* */ + /* The address of the CID's driver generic interface. The */ + /* format-specific interface can then be retrieved through the method */ + /* interface->get_format_interface. */ + /* */ + EXPORT_FUNC( FT_DriverInterface* ) getDriverInterface( void ) { return &t1_driver_interface; } + #endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS */ +/* END */ diff --git a/src/type1/t1driver.h b/src/type1/t1driver.h index 5cd362bcb..e42dfe616 100644 --- a/src/type1/t1driver.h +++ b/src/type1/t1driver.h @@ -1,19 +1,20 @@ -/******************************************************************* - * - * t1driver.h - * - * High-level Type1 driver interface for FreeType 2.0 - * - * Copyright 1996-1998 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used, - * modified, and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ +/***************************************************************************/ +/* */ +/* t1driver.h */ +/* */ +/* High-level Type 1 driver interface (specification). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + #ifndef T1DRIVER_H #define T1DRIVER_H @@ -21,7 +22,9 @@ #include #include - FT_EXPORT_VAR(const FT_DriverInterface) t1_driver_interface; + FT_EXPORT_VAR( const FT_DriverInterface ) t1_driver_interface; #endif /* T1DRIVER_H */ + +/* END */ diff --git a/src/type1/t1gload.c b/src/type1/t1gload.c index 2f5280db9..76d0fec04 100644 --- a/src/type1/t1gload.c +++ b/src/type1/t1gload.c @@ -1,19 +1,20 @@ -/******************************************************************* - * - * t1gload.c 1.0 - * - * Type1 Glyph Loader. - * - * Copyright 1996-1999 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - ******************************************************************/ +/***************************************************************************/ +/* */ +/* t1gload.c */ +/* */ +/* Type 1 Glyph Loader (body). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + #include #include @@ -23,37 +24,33 @@ #include #endif - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ - /********** *********/ - /********** *********/ - /********** GENERIC CHARSTRINGS PARSING *********/ - /********** *********/ - /********** *********/ - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ -/********************************************************************* - * - * - * T1_Init_Builder - * - * - * Initialise a given glyph builder. - * - * - * builder :: glyph builder to initialise - * face :: current face object - * size :: current size object - * glyph :: current glyph object - * funcs :: glyph builder functions (or "methods"). - * - *********************************************************************/ + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ +#undef FT_COMPONENT +#define FT_COMPONENT trace_t1gload + + + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********** *********/ + /********** *********/ + /********** GENERIC CHARSTRING PARSING *********/ + /********** *********/ + /********** *********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + static - void T1_Reset_Builder( T1_Builder* builder, FT_Bool reset_base ) + void T1_Reset_Builder( T1_Builder* builder, + FT_Bool reset_base ) { builder->pos_x = 0; builder->pos_y = 0; @@ -66,7 +63,7 @@ builder->pass = 0; builder->hint_point = 0; - if (reset_base) + if ( reset_base ) { builder->base.n_points = 0; builder->base.n_contours = 0; @@ -75,6 +72,7 @@ { FT_Outline* base = &builder->base; FT_Outline* cur = &builder->current; + cur->n_points = 0; cur->n_contours = 0; @@ -85,12 +83,32 @@ } + /*************************************************************************/ + /* */ + /* */ + /* T1_Init_Builder */ + /* */ + /* */ + /* Initializes a given glyph builder. */ + /* */ + /* */ + /* builder :: A pointer to the glyph builder to initialize. */ + /* */ + /* */ + /* face :: The current face object. */ + /* */ + /* size :: The current size object. */ + /* */ + /* glyph :: The current glyph object. */ + /* */ + /* funcs :: Glyph builder functions (or `methods'). */ + /* */ LOCAL_FUNC - void T1_Init_Builder( T1_Builder* builder, - T1_Face face, - T1_Size size, - T1_GlyphSlot glyph, - const T1_Builder_Funcs* funcs ) + void T1_Init_Builder( T1_Builder* builder, + T1_Face face, + T1_Size size, + T1_GlyphSlot glyph, + const T1_Builder_Funcs* funcs ) { builder->funcs = *funcs; builder->path_begun = 0; @@ -101,14 +119,14 @@ builder->glyph = glyph; builder->memory = face->root.memory; - if (glyph) + if ( glyph ) { builder->base = glyph->root.outline; builder->max_points = glyph->max_points; builder->max_contours = glyph->max_contours; } - if (size) + if ( size ) { builder->scale_x = size->root.metrics.x_scale; builder->scale_y = size->root.metrics.y_scale; @@ -118,27 +136,26 @@ } -/********************************************************************* - * - * - * T1_Done_Builder - * - * - * Finalise a given glyph builder. Its content can still be - * used after the call, but the function saves important information - * within the corresponding glyph slot. - * - * - * builder :: glyph builder to initialise - * - *********************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* T1_Done_Builder */ + /* */ + /* */ + /* Finalizes a given glyph builder. Its contents can still be used */ + /* after the call, but the function saves important information */ + /* within the corresponding glyph slot. */ + /* */ + /* */ + /* builder :: A pointer to the glyph builder to finalize. */ + /* */ LOCAL_FUNC - void T1_Done_Builder( T1_Builder* builder ) + void T1_Done_Builder( T1_Builder* builder ) { T1_GlyphSlot glyph = builder->glyph; - if (glyph) + + if ( glyph ) { glyph->root.outline = builder->base; glyph->max_points = builder->max_points; @@ -147,22 +164,19 @@ } - -/********************************************************************* - * - * - * T1_Init_Decoder - * - * - * Initialise a given Type 1 decoder for parsing - * - * - * decoder :: Type 1 decoder to initialise - * funcs :: hinter functions interface - * - *********************************************************************/ - - + /*************************************************************************/ + /* */ + /* */ + /* T1_Init_Decoder */ + /* */ + /* */ + /* Initializes a given glyph decoder. */ + /* */ + /* */ + /* decoder :: A pointer to the glyph builder to initialize. */ + /* */ + /* */ + /* funcs :: The hinting functions interface. */ LOCAL_FUNC void T1_Init_Decoder( T1_Decoder* decoder, const T1_Hinter_Funcs* funcs ) @@ -175,49 +189,50 @@ decoder->num_flex_vectors = 0; /* Clear loader */ - MEM_Set( &decoder->builder, 0, sizeof(decoder->builder) ); + MEM_Set( &decoder->builder, 0, sizeof ( decoder->builder ) ); } -/********************************************************************* - * - * - * lookup_glyph_by_stdcharcode - * - * - * Lookup a given glyph by its StandardEncoding charcode. Used - * to implement the SEAC Type 1 operator. - * - * - * face :: current face object - * charcode :: charcode to look for - * - * - * glyph index in font face. Returns -1 if the corresponding - * glyph wasn't found. - * - *********************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* lookup_glyph_by_stdcharcode */ + /* */ + /* */ + /* Looks up a given glyph by its StandardEncoding charcode. Used */ + /* to implement the SEAC Type 1 operator. */ + /* */ + /* */ + /* face :: The current face object. */ + /* */ + /* charcode :: The character code to look for. */ + /* */ + /* */ + /* A glyph index in the font face. Returns -1 if the corresponding */ + /* glyph wasn't found. */ + /* */ static - FT_Int lookup_glyph_by_stdcharcode( T1_Face face, - FT_Int charcode ) + FT_Int lookup_glyph_by_stdcharcode( T1_Face face, + FT_Int charcode ) { FT_Int n; const FT_String* glyph_name; PSNames_Interface* psnames = (PSNames_Interface*)face->psnames; + /* check range of standard char code */ - if (charcode < 0 || charcode > 255) + if ( charcode < 0 || charcode > 255 ) return -1; glyph_name = psnames->adobe_std_strings( - psnames->adobe_std_encoding[charcode]); + psnames->adobe_std_encoding[charcode]); for ( n = 0; n < face->type1.num_glyphs; n++ ) { FT_String* name = (FT_String*)face->type1.glyph_names[n]; - if ( name && strcmp(name,glyph_name) == 0 ) + + if ( name && strcmp( name, glyph_name ) == 0 ) return n; } @@ -225,27 +240,30 @@ } -/********************************************************************* - * - * - * t1operator_seac - * - * - * Implements the "seac" Type 1 operator for a Type 1 decoder - * - * - * decoder :: current Type 1 decoder - * asb :: accent's side bearing - * adx :: horizontal position of accent - * ady :: vertical position of accent - * bchar :: base character's StandardEncoding charcode - * achar :: accent character's StandardEncoding charcode - * - * - * Error code. 0 means success. - * - *********************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* t1operator_seac */ + /* */ + /* */ + /* Implements the `seac' Type 1 operator for a Type 1 decoder. */ + /* */ + /* */ + /* decoder :: The current CID decoder. */ + /* */ + /* asb :: The accent's side bearing. */ + /* */ + /* adx :: The horizontal offset of the accent. */ + /* */ + /* ady :: The vertical offset of the accent. */ + /* */ + /* bchar :: The base character's StandardEncoding charcode. */ + /* */ + /* achar :: The accent character's StandardEncoding charcode. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ static FT_Error t1operator_seac( T1_Decoder* decoder, FT_Pos asb, @@ -262,27 +280,31 @@ FT_Vector left_bearing, advance; T1_Font* type1 = &face->type1; + bchar_index = lookup_glyph_by_stdcharcode( face, bchar ); achar_index = lookup_glyph_by_stdcharcode( face, achar ); - if (bchar_index < 0 || achar_index < 0) + if ( bchar_index < 0 || achar_index < 0 ) { - FT_ERROR(( "T1.Parse_Seac : invalid seac character code arguments\n" )); + FT_ERROR(( "t1operator_seac: invalid seac character code arguments\n" )); return T1_Err_Syntax_Error; } if ( decoder->builder.no_recurse ) { - /* if we're trying to load a composite glyph, do not load the */ - /* accent character and return the array of subglyphs.. */ + /* if we are trying to load a composite glyph, do not load the */ + /* accent character and return the array of subglyphs. */ + FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph; FT_SubGlyph* subg; + /* reallocate subglyph array if necessary */ - if (glyph->max_subglyphs < 2) + if ( glyph->max_subglyphs < 2 ) { FT_Memory memory = decoder->builder.face->root.memory; + if ( REALLOC_ARRAY( glyph->subglyphs, glyph->max_subglyphs, 2, FT_SubGlyph ) ) return error; @@ -312,8 +334,9 @@ } else { - /* First load "bchar" in builder */ + /* First load `bchar' in builder */ /* now load the unscaled outline */ + cur->n_points = 0; cur->n_contours = 0; cur->points = base->points + base->n_points; @@ -326,21 +349,23 @@ type1->num_subrs, type1->subrs, type1->subrs_len ); - if (error) return error; + if ( error ) + return error; n_base_points = cur->n_points; /* save the left bearing and width of the base character */ - /* as they will be erased by the next load.. */ + /* as they will be erased by the next load. */ + left_bearing = decoder->builder.left_bearing; advance = decoder->builder.advance; decoder->builder.left_bearing.x = 0; decoder->builder.left_bearing.y = 0; - /* Now load "achar" on top of */ + /* Now load `achar' on top of */ /* the base outline */ - /* */ + cur->n_points = 0; cur->n_contours = 0; cur->points = base->points + base->n_points; @@ -353,7 +378,8 @@ type1->num_subrs, type1->subrs, type1->subrs_len ); - if (error) return error; + if ( error ) + return error; /* adjust contours in accented character outline */ { @@ -365,34 +391,35 @@ /* restore the left side bearing and */ /* advance width of the base character */ + decoder->builder.left_bearing = left_bearing; decoder->builder.advance = advance; /* Finally, move the accent */ FT_Outline_Translate( cur, adx - asb, ady ); } + return T1_Err_Ok; } -/********************************************************************* - * - * - * t1operator_flex - * - * - * Implements the "flex" Type 1 operator for a Type 1 decoder - * - * - * decoder :: current Type 1 decoder - * threshold :: threshold - * end_x :: position of final flex point - * end_y :: position of final flex point - * - * - * Error code. 0 means success. - * - *********************************************************************/ + /*************************************************************************/ + /* */ + /* */ + /* t1operator_flex */ + /* */ + /* */ + /* Implements the `flex' Type 1 operator for a Type 1 decoder. */ + /* */ + /* */ + /* decoder :: The current Type 1 decoder. */ + /* threshold :: The threshold. */ + /* end_x :: The horizontal position of the final flex point. */ + /* end_y :: The vertical position of the final flex point. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ static FT_Error t1operator_flex( T1_Decoder* decoder, FT_Pos threshold, @@ -403,10 +430,15 @@ FT_Vector* flex = decoder->flex_vectors; FT_Int n; - /* we don't even try to test the threshold in the non-hinting */ + UNUSED( threshold ); + UNUSED( end_x ); + UNUSED( end_y ); + + + /* we don't even try to test the threshold in the non-hinting */ /* builder, even if the flex operator is said to be a path */ - /* construction statement in the specification. This is better */ - /* left to the hinter.. */ + /* construction statement in the specification. This is better */ + /* left to the hinter. */ flex = decoder->flex_vectors; vec = *flex++; @@ -419,11 +451,6 @@ vec = *flex++; } - - UNUSED(threshold); - UNUSED(end_x); - UNUSED(end_y); - flex = decoder->flex_vectors; return decoder->builder.funcs.rcurve_to( &decoder->builder, @@ -438,34 +465,37 @@ } -/********************************************************************* - * - * - * T1_Parse_CharStrings - * - * - * Parses a given Type 1 charstrings program - * - * - * decoder :: current Type 1 decoder - * charstring_base :: base of the charstring stream - * charstring_len :: length in bytes of the charstring stream - * num_subrs :: number of sub-routines - * subrs_base :: array of sub-routines addresses - * subrs_len :: array of sub-routines lengths - * - * - * Error code. 0 means success. - * - *********************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* T1_Parse_CharStrings */ + /* */ + /* */ + /* Parses a given Type 1 charstrings program. */ + /* */ + /* */ + /* decoder :: The current Type 1 decoder. */ + /* */ + /* charstring_base :: The base address of the charstring stream. */ + /* */ + /* charstring_len :: The length in bytes of the charstring stream. */ + /* */ + /* num_subrs :: The number of sub-routines. */ + /* */ + /* subrs_base :: An array of sub-routines addresses. */ + /* */ + /* subrs_len :: An array of sub-routines lengths. */ + /* */ + /* */ + /* Free error code. 0 means success. */ + /* */ LOCAL_FUNC - FT_Error T1_Parse_CharStrings( T1_Decoder* decoder, - FT_Byte* charstring_base, - FT_Int charstring_len, - FT_Int num_subrs, - FT_Byte** subrs_base, - FT_Int* subrs_len ) + FT_Error T1_Parse_CharStrings( T1_Decoder* decoder, + FT_Byte* charstring_base, + FT_Int charstring_len, + FT_Int num_subrs, + FT_Byte** subrs_base, + FT_Int* subrs_len ) { FT_Error error; T1_Decoder_Zone* zone; @@ -475,7 +505,7 @@ T1_Builder_Funcs* builds = &builder->funcs; T1_Hinter_Funcs* hints = &decoder->hinter; - static const FT_Int args_count[ op_max ] = + static const FT_Int args_count[op_max] = { 0, /* none */ 0, /* endchar */ @@ -505,7 +535,8 @@ 2 /* setcurrentpoint */ }; - /* First of all, initialise the decoder */ + + /* First of all, initialize the decoder */ decoder->top = decoder->stack; decoder->zone = decoder->zones; zone = decoder->zones; @@ -525,99 +556,146 @@ T1_Operator op = op_none; FT_Long value = 0; - /* First of all, decompress operator or value */ - switch (*ip++) + + /* Start with the decompression of operator or value */ + switch ( *ip++ ) { - case 1: op = op_hstem; break; + case 1: + op = op_hstem; + break; - case 3: op = op_vstem; break; - case 4: op = op_vmoveto; break; - case 5: op = op_rlineto; break; - case 6: op = op_hlineto; break; - case 7: op = op_vlineto; break; - case 8: op = op_rrcurveto; break; - case 9: op = op_closepath; break; - case 10: op = op_callsubr; break; - case 11: op = op_return; break; + case 3: + op = op_vstem; + break; + case 4: + op = op_vmoveto; + break; + case 5: + op = op_rlineto; + break; + case 6: + op = op_hlineto; + break; + case 7: + op = op_vlineto; + break; + case 8: + op = op_rrcurveto; + break; + case 9: + op = op_closepath; + break; + case 10: + op = op_callsubr; + break; + case 11: + op = op_return; + break; - case 13: op = op_hsbw; break; - case 14: op = op_endchar; break; + case 13: + op = op_hsbw; + break; + case 14: + op = op_endchar; + break; - case 21: op = op_rmoveto; break; - case 22: op = op_hmoveto; break; + case 21: + op = op_rmoveto; + break; + case 22: + op = op_hmoveto; + break; - case 30: op = op_vhcurveto; break; - case 31: op = op_hvcurveto; break; + case 30: + op = op_vhcurveto; + break; + case 31: + op = op_hvcurveto; + break; - case 12: - { - if (ip > limit) - { - FT_ERROR(( "T1.Parse_CharStrings : invalid escape (12+EOF)\n" )); - goto Syntax_Error; - } + case 12: + if ( ip > limit ) + { + FT_ERROR(( "T1_Parse_CharStrings: invalid escape (12+EOF)\n" )); + goto Syntax_Error; + } - switch (*ip++) - { - case 0: op = op_dotsection; break; - case 1: op = op_vstem3; break; - case 2: op = op_hstem3; break; - case 6: op = op_seac; break; - case 7: op = op_sbw; break; - case 12: op = op_div; break; - case 16: op = op_callothersubr; break; - case 17: op = op_pop; break; - case 33: op = op_setcurrentpoint; break; - - default: - FT_ERROR(( "T1.Parse_CharStrings : invalid escape (12+%d)\n", - ip[-1] )); - goto Syntax_Error; - } - } + switch ( *ip++ ) + { + case 0: + op = op_dotsection; break; - - case 255: /* four bytes integer */ - { - if (ip+4 > limit) - { - FT_ERROR(( "T1.Parse_CharStrings : unexpected EOF in integer\n" )); - goto Syntax_Error; - } - - value = ((long)ip[0] << 24) | - ((long)ip[1] << 16) | - ((long)ip[2] << 8) | - ip[3]; - ip += 4; - } + case 1: + op = op_vstem3; + break; + case 2: + op = op_hstem3; + break; + case 6: + op = op_seac; + break; + case 7: + op = op_sbw; + break; + case 12: + op = op_div; + break; + case 16: + op = op_callothersubr; + break; + case 17: + op = op_pop; + break; + case 33: + op = op_setcurrentpoint; break; default: - if (ip[-1] >= 32) - { - if (ip[-1] < 247) - value = (long)ip[-1] - 139; - else - { - if (++ip > limit) - { - FT_ERROR(( "T1.Parse_CharStrings : unexpected EOF in integer\n" )); - goto Syntax_Error; - } + FT_ERROR(( "T1_Parse_CharStrings: invalid escape (12+%d)\n", + ip[-1] )); + goto Syntax_Error; + } + break; - if (ip[-2] < 251) - value = ((long)(ip[-2]-247) << 8) + ip[-1] + 108; - else - value = -((((long)ip[-2]-251) << 8) + ip[-1] + 108 ); - } - } + case 255: /* four bytes integer */ + if ( ip + 4 > limit ) + { + FT_ERROR(( "T1_Parse_CharStrings: unexpected EOF in integer\n" )); + goto Syntax_Error; + } + + value = ( (FT_Long)ip[0] << 24 ) | + ( (FT_Long)ip[1] << 16 ) | + ( (FT_Long)ip[2] << 8 ) | + ip[3]; + ip += 4; + break; + + default: + if ( ip[-1] >= 32 ) + { + if ( ip[-1] < 247 ) + value = (FT_Long)ip[-1] - 139; else { - FT_ERROR(( "T1.Parse_CharStrings : invalid byte (%d)\n", - ip[-1] )); - goto Syntax_Error; + if ( ++ip > limit ) + { + FT_ERROR(( "T1_Parse_CharStrings: unexpected EOF in integer\n" )); + goto Syntax_Error; + } + + if ( ip[-2] < 251 ) + value = ( (FT_Long)( ip[-2] - 247 ) << 8 ) + ip[-1] + 108; + else + value = -( ( ( (FT_Long)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 ); } + } + else + { + FT_ERROR(( "T1_Parse_CharStrings: invalid byte (%d)\n", + ip[-1] )); + goto Syntax_Error; + } } /* push value if needed */ @@ -625,123 +703,120 @@ { if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS ) { - FT_ERROR(( "T1.Parse_CharStrings : Stack overflow !!\n" )); + FT_ERROR(( "T1_Parse_CharStrings: Stack overflow!\n" )); goto Syntax_Error; } *top++ = value; decoder->top = top; } - else if ( op == op_callothersubr ) /* check arguments differently */ { - if ( top - decoder->stack < 2) + if ( top - decoder->stack < 2 ) goto Stack_Underflow; top -= 2; - switch (top[1]) + switch ( top[1] ) { - case 1: /* start flex feature ----------------------------- */ + case 1: /* start flex feature ----------------------------- */ + if ( top[0] != 0 ) + goto Unexpected_OtherSubr; + + decoder->flex_state = 1; + decoder->num_flex_vectors = 0; + decoder->flex_vectors[0].x = 0; + decoder->flex_vectors[0].y = 0; + break; + + + case 2: /* add flex vector ------------------------------- */ + { + FT_Int index; + FT_Vector* flex; + + + if ( top[0] != 0 ) + goto Unexpected_OtherSubr; + + top -= 2; + if ( top < decoder->stack ) + goto Stack_Underflow; + + index = decoder->num_flex_vectors++; + if ( index >= 7 ) { - if (top[0] != 0) goto Unexpected_OtherSubr; - - decoder->flex_state = 1; - decoder->num_flex_vectors = 0; - decoder->flex_vectors[0].x = 0; - decoder->flex_vectors[0].y = 0; + FT_ERROR(( "T1_Parse_CharStrings: too many flex vectors!\n" )); + goto Syntax_Error; } - break; + flex = decoder->flex_vectors + index; + flex->x += top[0]; + flex->y += top[1]; + } + break; - case 2: /* add flex vector ------------------------------- */ - { - FT_Int index; - FT_Vector* flex; - - if (top[0] != 0) goto Unexpected_OtherSubr; - - top -= 2; - if (top < decoder->stack) goto Stack_Underflow; - - index = decoder->num_flex_vectors++; - if (index >= 7) - { - FT_ERROR(( "T1.Parse_CharStrings: too many flex vectors !\n" )); - goto Syntax_Error; - } - - flex = decoder->flex_vectors + index; - flex->x += top[0]; - flex->y += top[1]; - - } - break; - - - case 0: /* end flex feature ------------------------------ */ - { - if ( decoder->flex_state == 0 || - decoder->num_flex_vectors != 7 ) - { - FT_ERROR(( "T1.Parse_CharStrings: unexpected flex end\n" )); - goto Syntax_Error; - } - - if (top[0] != 3) goto Unexpected_OtherSubr; - - top -= 3; - if (top < decoder->stack) goto Stack_Underflow; - - /* now consume the remaining "pop pop setcurrentpoint" */ - if ( ip+6 > limit || - ip[0] != 12 || ip[1] != 17 || /* pop */ - ip[2] != 12 || ip[3] != 17 || /* pop */ - ip[4] != 12 || ip[5] != 33 ) /* setcurrentpoint */ - { - FT_ERROR(( "T1.Parse_CharStrings: invalid flex charstring\n" )); - goto Syntax_Error; - } - - decoder->flex_state = 0; - decoder->top = top; - - error = t1operator_flex( decoder, top[0], top[1], top[2] ); - } - break; - - - case 3: /* change hints ------------------------------------ */ - { - if (top[0] != 1) goto Unexpected_OtherSubr; - - /* eat the following "pop" */ - if (ip+2 > limit) - { - FT_ERROR(( "T1.Parse_CharStrings: invalid escape (12+%d)\n", - ip[-1] )); - goto Syntax_Error; - } - - if (ip[0] != 12 || ip[1] != 17) - { - FT_ERROR(( "T1.Parse_CharStrings: 'pop' expected, found (%d %d)\n", - ip[0], ip[1] )); - goto Syntax_Error; - } - - ip += 2; - error = hints->change_hints(builder); - } - break; - - - default: - /* invalid OtherSubrs call */ - Unexpected_OtherSubr: - FT_ERROR(( "T1.Parse_CharStrings: unexpected OtherSubrs [%d %d]\n", - top[0], top[1] )); + case 0: /* end flex feature ------------------------------ */ + if ( decoder->flex_state == 0 || + decoder->num_flex_vectors != 7 ) + { + FT_ERROR(( "T1_Parse_CharStrings: unexpected flex end\n" )); goto Syntax_Error; + } + + if ( top[0] != 3 ) + goto Unexpected_OtherSubr; + + top -= 3; + if ( top < decoder->stack ) + goto Stack_Underflow; + + /* now consume the remaining `pop pop setcurrentpoint' */ + if ( ip + 6 > limit || + ip[0] != 12 || ip[1] != 17 || /* pop */ + ip[2] != 12 || ip[3] != 17 || /* pop */ + ip[4] != 12 || ip[5] != 33 ) /* setcurrentpoint */ + { + FT_ERROR(( "T1_Parse_CharStrings: invalid flex charstring\n" )); + goto Syntax_Error; + } + + decoder->flex_state = 0; + decoder->top = top; + + error = t1operator_flex( decoder, top[0], top[1], top[2] ); + break; + + case 3: /* change hints ------------------------------------ */ + if ( top[0] != 1 ) + goto Unexpected_OtherSubr; + + /* eat the following `pop' */ + if ( ip + 2 > limit ) + { + FT_ERROR(( "T1_Parse_CharStrings: invalid escape (12+%d)\n", + ip[-1] )); + goto Syntax_Error; + } + + if (ip[0] != 12 || ip[1] != 17) + { + FT_ERROR(( "T1_Parse_CharStrings: `pop' expected, found (%d %d)\n", + ip[0], ip[1] )); + goto Syntax_Error; + } + + ip += 2; + + error = hints->change_hints( builder ); + break; + + default: + /* invalid OtherSubrs call */ + Unexpected_OtherSubr: + FT_ERROR(( "T1_Parse_CharStrings: unexpected OtherSubrs [%d %d]\n", + top[0], top[1] )); + goto Syntax_Error; } decoder->top = top; } @@ -749,177 +824,176 @@ { FT_Int num_args = args_count[op]; + if ( top - decoder->stack < num_args ) goto Stack_Underflow; top -= num_args; - switch (op) + switch ( op ) { - case op_endchar: - error = builds->end_char( builder ); - break; + case op_endchar: + error = builds->end_char( builder ); + break; - case op_hsbw: - error = builds->set_bearing_point( builder, top[0], 0, - top[1], 0 ); - break; + case op_hsbw: + error = builds->set_bearing_point( builder, top[0], 0, + top[1], 0 ); + break; - case op_seac: - /* return immediately after the processing */ - return t1operator_seac( decoder, top[0], top[1], - top[2], top[3], top[4] ); + case op_seac: + /* return immediately after the processing */ + return t1operator_seac( decoder, top[0], top[1], + top[2], top[3], top[4] ); - case op_sbw: - error = builds->set_bearing_point( builder, top[0], top[1], - top[2], top[3] ); - break; + case op_sbw: + error = builds->set_bearing_point( builder, top[0], top[1], + top[2], top[3] ); + break; - case op_closepath: - error = builds->close_path( builder ); - break; + case op_closepath: + error = builds->close_path( builder ); + break; - case op_hlineto: - error = builds->rline_to( builder, top[0], 0 ); - break; + case op_hlineto: + error = builds->rline_to( builder, top[0], 0 ); + break; - case op_hmoveto: - error = builds->rmove_to( builder, top[0], 0 ); - break; + case op_hmoveto: + error = builds->rmove_to( builder, top[0], 0 ); + break; - case op_hvcurveto: - error = builds->rcurve_to( builder, top[0], 0, - top[1], top[2], - 0, top[3] ); - break; + case op_hvcurveto: + error = builds->rcurve_to( builder, top[0], 0, + top[1], top[2], + 0, top[3] ); + break; - case op_rlineto: - error = builds->rline_to( builder, top[0], top[1] ); - break; + case op_rlineto: + error = builds->rline_to( builder, top[0], top[1] ); + break; - case op_rmoveto: - /* ignore operator when in flex mode */ - if (decoder->flex_state == 0) - error = builds->rmove_to( builder, top[0], top[1] ); - else - top += 2; - break; + case op_rmoveto: + /* ignore operator when in flex mode */ + if ( decoder->flex_state == 0 ) + error = builds->rmove_to( builder, top[0], top[1] ); + else + top += 2; + break; - case op_rrcurveto: - { - error = builds->rcurve_to( builder, top[0], top[1], - top[2], top[3], - top[4], top[5] ); - } - break; + case op_rrcurveto: + error = builds->rcurve_to( builder, top[0], top[1], + top[2], top[3], + top[4], top[5] ); + break; - case op_vhcurveto: - error = builds->rcurve_to( builder, 0, top[0], - top[1], top[2], - top[3], 0 ); - break; + case op_vhcurveto: + error = builds->rcurve_to( builder, 0, top[0], + top[1], top[2], + top[3], 0 ); + break; - case op_vlineto: - error = builds->rline_to( builder, 0, top[0] ); - break; + case op_vlineto: + error = builds->rline_to( builder, 0, top[0] ); + break; - case op_vmoveto: - error = builds->rmove_to( builder, 0, top[0] ); - break; + case op_vmoveto: + error = builds->rmove_to( builder, 0, top[0] ); + break; - case op_dotsection: - error = hints->dot_section( builder ); - break; + case op_dotsection: + error = hints->dot_section( builder ); + break; - case op_hstem: - error = hints->stem( builder, top[0], top[1], 0 ); - break; + case op_hstem: + error = hints->stem( builder, top[0], top[1], 0 ); + break; - case op_hstem3: - error = hints->stem3( builder, top[0], top[1], top[2], - top[3], top[4], top[5], 0 ); - break; + case op_hstem3: + error = hints->stem3( builder, top[0], top[1], top[2], + top[3], top[4], top[5], 0 ); + break; - case op_vstem: - error = hints->stem( builder, top[0], top[1], 1 ); - break; + case op_vstem: + error = hints->stem( builder, top[0], top[1], 1 ); + break; - case op_vstem3: - error = hints->stem3( builder, top[0], top[1], top[2], - top[3], top[4], top[5], 1 ); - break; + case op_vstem3: + error = hints->stem3( builder, top[0], top[1], top[2], + top[3], top[4], top[5], 1 ); + break; - case op_div: - if (top[1]) - *top++ = top[0] / top[1]; - else - { - FT_ERROR(( "T1.Parse_CHarStrings : division by 0\n" )); - goto Syntax_Error; - } - break; - - case op_callsubr: - { - FT_Int index = top[0]; - - if ( index < 0 || index >= num_subrs ) - { - FT_ERROR(( "T1.Parse_CharStrings : invalid subrs index\n" )); - goto Syntax_Error; - } - - if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS ) - { - FT_ERROR(( "T1.Parse_CharStrings : too many nested subrs\n" )); - goto Syntax_Error; - } - - zone->cursor = ip; /* save current instruction pointer */ - - zone++; - zone->base = subrs_base[index]; - zone->limit = zone->base + subrs_len[index]; - zone->cursor = zone->base; - - if (!zone->base) - { - FT_ERROR(( "T1.Parse_CharStrings : invoking empty subrs !!\n" )); - goto Syntax_Error; - } - - decoder->zone = zone; - ip = zone->base; - limit = zone->limit; - } - break; - - case op_pop: - FT_ERROR(( "T1.Parse_CharStrings : unexpected POP\n" )); + case op_div: + if ( top[1] ) + *top++ = top[0] / top[1]; + else + { + FT_ERROR(( "T1_Parse_CHarStrings: division by 0\n" )); goto Syntax_Error; + } + break; + + case op_callsubr: + { + FT_Int index = top[0]; - case op_return: - if ( zone <= decoder->zones ) + if ( index < 0 || index >= num_subrs ) { - FT_ERROR(( "T1.Parse_CharStrings : unexpected return\n" )); + FT_ERROR(( "T1_Parse_CharStrings: invalid subrs index\n" )); + goto Syntax_Error; + } + + if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS ) + { + FT_ERROR(( "T1_Parse_CharStrings: too many nested subrs\n" )); + goto Syntax_Error; + } + + zone->cursor = ip; /* save current instruction pointer */ + + zone++; + zone->base = subrs_base[index]; + zone->limit = zone->base + subrs_len[index]; + zone->cursor = zone->base; + + if ( !zone->base ) + { + FT_ERROR(( "T1_Parse_CharStrings: invoking empty subrs!\n" )); goto Syntax_Error; } - zone--; - ip = zone->cursor; - limit = zone->limit; decoder->zone = zone; - break; + ip = zone->base; + limit = zone->limit; + } + break; - case op_setcurrentpoint: - FT_ERROR(( "T1.Parse_CharStrings : unexpected SETCURRENTPOINT\n" )); - goto Syntax_Error; - break; + case op_pop: + FT_ERROR(( "T1_Parse_CharStrings: unexpected POP\n" )); + goto Syntax_Error; - default: - FT_ERROR(( "T1.Parse_CharStrings : unhandled opcode %d\n", op )); + case op_return: + if ( zone <= decoder->zones ) + { + FT_ERROR(( "T1_Parse_CharStrings: unexpected return\n" )); goto Syntax_Error; + } + + zone--; + ip = zone->cursor; + limit = zone->limit; + decoder->zone = zone; + break; + + case op_setcurrentpoint: + FT_ERROR(( "T1_Parse_CharStrings: unexpected `setcurrentpoint'\n" )); + goto Syntax_Error; + break; + + default: + FT_ERROR(( "T1_Parse_CharStrings : unhandled opcode %d\n", op )); + goto Syntax_Error; } decoder->top = top; @@ -936,34 +1010,36 @@ } - -/*************************************************************************/ -/* */ -/* T1_Add_Points */ -/* */ -/* */ -/* Checks that there is enough room in the current load glyph outline */ -/* to accept "num_points" additional outline points. If not, this */ -/* function grows the load outline's arrays accordingly.. */ -/* */ -/* */ -/* builder :: pointer to glyph builder object */ -/* num_points :: number of points that will be added later */ -/* */ -/* */ -/* Type1 error code. 0 means success */ -/* */ -/* */ -/* This function does NOT update the points count in the glyph builder*/ -/* This must be done by the caller itself, after this function is */ -/* invoked.. */ -/* */ + /*************************************************************************/ + /* */ + /* */ + /* T1_Add_Points */ + /* */ + /* */ + /* Checks that there is enough room in the current load glyph outline */ + /* to accept `num_points' additional outline points. If not, this */ + /* function grows the load outline's arrays accordingly. */ + /* */ + /* */ + /* builder :: A pointer to the glyph builder object. */ + /* */ + /* num_points :: The number of points that will be added later. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + /* */ + /* This function does NOT update the points count in the glyph */ + /* builder. This must be done by the caller itself, after this */ + /* function has been invoked. */ + /* */ LOCAL_FUNC FT_Error T1_Add_Points( T1_Builder* builder, FT_Int num_points ) { FT_Int new_points; + new_points = builder->base.n_points + builder->current.n_points + num_points; @@ -975,6 +1051,7 @@ FT_Int increment = builder->current.points - builder->base.points; FT_Int current = builder->max_points; + while ( builder->max_points < new_points ) builder->max_points += 16; @@ -986,39 +1063,43 @@ return error; builder->current.points = builder->base.points + increment; - builder->current.tags = builder->base.tags + increment; + builder->current.tags = builder->base.tags + increment; } return T1_Err_Ok; } -/*************************************************************************/ -/* */ -/* T1_Add_Contours */ -/* */ -/* */ -/* Checks that there is enough room in the current load glyph outline */ -/* to accept "num_contours" additional contours. If not, this func */ -/* the load outline's arrays accordingly.. */ -/* */ -/* */ -/* builder :: pointer to glyph builder object */ -/* num_contours :: number of contours that will be added later */ -/* */ -/* */ -/* Type1 error code. 0 means success */ -/* */ -/* */ -/* This function does NOT update the contours count in the load glyph */ -/* This must be done by the caller itself, after this function is */ -/* invoked.. */ -/* */ + + /*************************************************************************/ + /* */ + /* */ + /* T1_Add_Contours */ + /* */ + /* */ + /* Checks that there is enough room in the current load glyph outline */ + /* to accept `num_contours' additional contours. If not, this */ + /* function grows the load outline's arrays accordingly. */ + /* */ + /* */ + /* builder :: A pointer to the glyph builder object. */ + /* */ + /* num_contours :: The number of contours that will be added later. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + /* */ + /* This function does NOT update the contours count in the load glyph */ + /* This must be done by the caller itself, after this function is */ + /* invoked. */ + /* */ LOCAL_FUNC FT_Error T1_Add_Contours( T1_Builder* builder, FT_Int num_contours ) { FT_Int new_contours; + new_contours = builder->base.n_contours + builder->current.n_contours + num_contours; @@ -1027,9 +1108,11 @@ { FT_Error error; FT_Memory memory = builder->memory; - FT_Int increment = builder->current.contours - builder->base.contours; + FT_Int increment = builder->current.contours - + builder->base.contours; FT_Int current = builder->max_contours; + while ( builder->max_contours < new_contours ) builder->max_contours += 4; @@ -1044,23 +1127,21 @@ } - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ - /********** *********/ - /********** *********/ - /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/ - /********** *********/ - /********** The following code is in charge of computing *********/ - /********** the maximum advance width of the font. It *********/ - /********** quickly process each glyph charstring to *********/ - /********** extract the value from either a "sbw" or "seac" *********/ - /********** operator. *********/ - /********** *********/ - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ - + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********** *********/ + /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/ + /********** *********/ + /********** The following code is in charge of computing *********/ + /********** the maximum advance width of the font. It *********/ + /********** quickly processes each glyph charstring to *********/ + /********** extract the value from either a `sbw' or `seac' *********/ + /********** operator. *********/ + /********** *********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ static @@ -1070,12 +1151,13 @@ FT_Pos wx, FT_Pos wy ) { - if (wx > decoder->builder.advance.x) + UNUSED( sbx ); + UNUSED( sby ); + UNUSED( wy ); + + if ( wx > decoder->builder.advance.x ) decoder->builder.advance.x = wx; - UNUSED(sbx); - UNUSED(sby); - UNUSED(wy); return -1; /* return an error code to exit the Type 1 parser */ /* immediately. */ } @@ -1088,56 +1170,57 @@ return -2; } - /* the maxadv_gbuilder_interface is used when computing the maximum */ - /* advance width of all glyphs in a given font. We only process the */ - /* 'sbw' operator here, and return an error for all others.. */ - /* Note that "seac" is processed by the T1_Decoder */ + /* the maxadv_gbuilder_interface is used when computing the maximum */ + /* advance width of all glyphs in a given font. We only process the */ + /* `sbw' operator here, and return an error for all others. */ + + /* Note that `seac' is processed by the T1_Decoder. */ static const T1_Builder_Funcs maxadv_builder_interface = { - (T1_Builder_EndChar) maxadv_error, - (T1_Builder_Sbw) maxadv_sbw, - (T1_Builder_ClosePath) maxadv_error, - (T1_Builder_RLineTo) maxadv_error, - (T1_Builder_RMoveTo) maxadv_error, - (T1_Builder_RCurveTo) maxadv_error + (T1_Builder_EndChar) maxadv_error, + (T1_Builder_Sbw) maxadv_sbw, + (T1_Builder_ClosePath)maxadv_error, + (T1_Builder_RLineTo) maxadv_error, + (T1_Builder_RMoveTo) maxadv_error, + (T1_Builder_RCurveTo) maxadv_error }; - /* the maxadv_interface is used when computing the maximum advance */ - /* with of the set of glyphs in a given font file. We only process */ - /* the "seac" operator and return immediately.. */ + /* the maxadv_hinter_interface always return an error. */ + static const T1_Hinter_Funcs maxadv_hinter_interface = { - (T1_Hinter_DotSection) maxadv_error, - (T1_Hinter_ChangeHints) maxadv_error, - (T1_Hinter_Stem) maxadv_error, - (T1_Hinter_Stem3) maxadv_error, + (T1_Hinter_DotSection) maxadv_error, + (T1_Hinter_ChangeHints)maxadv_error, + (T1_Hinter_Stem) maxadv_error, + (T1_Hinter_Stem3) maxadv_error, }; - LOCAL_FUNC FT_Error T1_Compute_Max_Advance( T1_Face face, - FT_Int *max_advance ) + FT_Int* max_advance ) { FT_Error error; T1_Decoder decoder; FT_Int glyph_index; T1_Font* type1 = &face->type1; + *max_advance = 0; - /* Initialise load decoder */ + /* Initialize load decoder */ T1_Init_Decoder( &decoder, &maxadv_hinter_interface ); T1_Init_Builder( &decoder.builder, face, 0, 0, &maxadv_builder_interface ); /* For each glyph, parse the glyph charstring and extract */ - /* the advance width.. */ + /* the advance width. */ + for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ ) { /* now get load the unscaled outline */ @@ -1147,31 +1230,30 @@ type1->num_subrs, type1->subrs, type1->subrs_len ); - /* ignore the error if one occured - skip to next glyph */ + /* ignore error if one occured - skip to next glyph */ } *max_advance = decoder.builder.advance.x; + return T1_Err_Ok; } - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ - /********** *********/ - /********** *********/ - /********** UNHINTED GLYPH LOADER *********/ - /********** *********/ - /********** The following code is in charge of loading a *********/ - /********** single outline. It completely ignores hinting *********/ - /********** and is used when FT_LOAD_NO_HINTING is set. *********/ - /********** *********/ - /********** The Type 1 hinter is located in "t1hint.c" *********/ - /********** *********/ - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ - + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********** *********/ + /********** UNHINTED GLYPH LOADER *********/ + /********** *********/ + /********** The following code is in charge of loading a *********/ + /********** single outline. It completely ignores hinting *********/ + /********** and is used when FT_LOAD_NO_HINTING is set. *********/ + /********** *********/ + /********** The Type 1 hinter is located in `t1hint.c' *********/ + /********** *********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ static @@ -1182,14 +1264,15 @@ FT_Int num_points; FT_Int first_point; - /* Some fonts, like Hershey, are made of "open paths" which are */ - /* now managed directly by FreeType. In this case, it is necessary */ - /* to close the path by duplicating its points in reverse order, */ - /* which is precisely the purpose of this function */ - /* first compute the number of points to duplicate.. */ - if (cur->n_contours > 1) - first_point = cur->contours[ cur->n_contours-2 ]+1; + /* Some fonts, like Hershey, are made of `open paths' which are */ + /* now managed directly by FreeType. In this case, it is necessary */ + /* to close the path by duplicating its points in reverse order, */ + /* which is precisely the purpose of this function. */ + + /* first compute the number of points to duplicate. */ + if ( cur->n_contours > 1 ) + first_point = cur->contours[cur->n_contours - 2] + 1; else first_point = 0; @@ -1201,14 +1284,16 @@ FT_Vector* point; char* tags; + error = T1_Add_Points( builder, num_points ); - if (error) return error; + if ( error ) + return error; point = cur->points + cur->n_points; - tags = cur->tags + cur->n_points; + tags = cur->tags + cur->n_points; - source_point = point - 2; - source_tags = tags - 2; + source_point = point - 2; + source_tags = tags - 2; cur->n_points += num_points; @@ -1216,13 +1301,14 @@ do { *point++ = *source_point--; - *tags++ = *source_tags--; + *tags++ = *source_tags--; num_points--; } - while (num_points > 0); + while ( num_points > 0 ); } builder->path_begun = 0; + return T1_Err_Ok; } @@ -1232,34 +1318,39 @@ { FT_Outline* cur = &builder->current; + /* save current contour, if any */ if ( cur->n_contours > 0 ) - cur->contours[cur->n_contours-1] = cur->n_points-1; + cur->contours[cur->n_contours - 1] = cur->n_points - 1; #ifndef T1_CONFIG_OPTION_DISABLE_HINTER + /* hint latest points if needed - this is not strictly required */ /* there, but it helps for debugging, and doesn't affect performance */ if ( builder->pass == 1 ) T1_Hint_Points( builder ); -#endif + +#endif /* T1_CONFIG_OPTION_DISABLE_HINTER */ builder->path_begun = 0; + return T1_Err_Ok; } - static FT_Error gload_endchar( T1_Builder* builder ) { FT_Outline* cur = &builder->current; FT_Error error; + /* close path if needed */ - if (builder->path_begun) + if ( builder->path_begun ) { error = close_open_path( builder ); - if (error) return error; + if ( error ) + return error; } error = gload_closepath( builder ); @@ -1271,7 +1362,6 @@ } - static FT_Error gload_sbw( T1_Builder* builder, FT_Pos sbx, @@ -1286,12 +1376,11 @@ builder->last.x = sbx; builder->last.y = sby; + return 0; } - - static FT_Error gload_rlineto( T1_Builder* builder, FT_Pos dx, @@ -1301,9 +1390,11 @@ FT_Outline* cur = &builder->current; FT_Vector vec; + /* grow buffer if necessary */ - error = T1_Add_Points ( builder, 1 ); - if (error) return error; + error = T1_Add_Points( builder, 1 ); + if ( error ) + return error; if ( builder->load_points ) { @@ -1312,13 +1403,14 @@ vec.y = builder->last.y + dy; cur->points[cur->n_points] = vec; - cur->tags [cur->n_points] = FT_Curve_Tag_On; + cur->tags [cur->n_points] = FT_Curve_Tag_On; builder->last = vec; } cur->n_points++; - builder->path_begun = 1; + builder->path_begun = 1; + return T1_Err_Ok; } @@ -1332,28 +1424,32 @@ FT_Outline* cur = &builder->current; FT_Vector vec; - /* in the case where "path_begun" is set, we have a rmoveto */ - /* after some normal path definition. When the face's paint */ - /* type is set to 1, this means that we have an "open path", */ - /* also called a 'stroke'. The FreeType raster doesn't support */ - /* opened path, so we'll close it explicitely there.. */ + + /* in the case where `path_begun' is set, we have an `rmoveto' */ + /* after some normal path definition. If the face's paint type */ + /* is set to 1, this means that we have an `open path', also */ + /* called a `stroke'. The FreeType raster doesn't support */ + /* opened paths, so we'll close it explicitely there. */ + if ( builder->path_begun && builder->face->type1.paint_type == 1 ) { if ( builder->face->type1.paint_type == 1 ) { error = close_open_path( builder ); - if (error) return error; + if ( error ) + return error; } } /* grow buffer if necessary */ error = T1_Add_Contours( builder, 1 ) || T1_Add_Points ( builder, 1 ); - if (error) return error; + if ( error ) + return error; /* save current contour, if any */ if ( cur->n_contours > 0 ) - cur->contours[cur->n_contours-1] = cur->n_points-1; + cur->contours[cur->n_contours - 1] = cur->n_points - 1; if ( builder->load_points ) { @@ -1361,7 +1457,7 @@ vec.x = builder->last.x + dx; vec.y = builder->last.y + dy; cur->points[cur->n_points] = vec; - cur->tags [cur->n_points] = FT_Curve_Tag_On; + cur->tags [cur->n_points] = FT_Curve_Tag_On; builder->last = vec; } @@ -1389,26 +1485,30 @@ char* tags; /* grow buffer if necessary */ - error = T1_Add_Points ( builder, 3 ); - if (error) return error; + error = T1_Add_Points( builder, 3 ); + if ( error ) + return error; if ( builder->load_points ) { /* save point */ points = cur->points + cur->n_points; - tags = cur->tags + cur->n_points; + tags = cur->tags + cur->n_points; vec.x = builder->last.x + dx1; vec.y = builder->last.y + dy1; - points[0] = vec; tags[0] = FT_Curve_Tag_Cubic; + points[0] = vec; + tags[0] = FT_Curve_Tag_Cubic; vec.x += dx2; vec.y += dy2; - points[1] = vec; tags[1] = FT_Curve_Tag_Cubic; + points[1] = vec; + tags[1] = FT_Curve_Tag_Cubic; vec.x += dx3; vec.y += dy3; - points[2] = vec; tags[2] = FT_Curve_Tag_On; + points[2] = vec; + tags[2] = FT_Curve_Tag_On; builder->last = vec; } @@ -1419,8 +1519,6 @@ } - - static FT_Error gload_ignore( void ) { @@ -1443,31 +1541,30 @@ static const T1_Builder_Funcs gload_builder_interface_null = { - (T1_Builder_EndChar) gload_ignore, - (T1_Builder_Sbw) gload_sbw, /* record left bearing */ - (T1_Builder_ClosePath) gload_ignore, - (T1_Builder_RLineTo) gload_ignore, - (T1_Builder_RMoveTo) gload_ignore, - (T1_Builder_RCurveTo) gload_ignore + (T1_Builder_EndChar) gload_ignore, + (T1_Builder_Sbw) gload_sbw, /* record left bearing */ + (T1_Builder_ClosePath)gload_ignore, + (T1_Builder_RLineTo) gload_ignore, + (T1_Builder_RMoveTo) gload_ignore, + (T1_Builder_RCurveTo) gload_ignore }; static const T1_Hinter_Funcs gload_hinter_interface = { - (T1_Hinter_DotSection) gload_ignore, /* dotsection */ - (T1_Hinter_ChangeHints) gload_ignore, /* changehints */ - (T1_Hinter_Stem) gload_ignore, /* hstem & vstem */ - (T1_Hinter_Stem3) gload_ignore, /* hstem3 & vestem3 */ + (T1_Hinter_DotSection) gload_ignore, /* dotsection */ + (T1_Hinter_ChangeHints)gload_ignore, /* changehints */ + (T1_Hinter_Stem) gload_ignore, /* hstem & vstem */ + (T1_Hinter_Stem3) gload_ignore, /* hstem3 & vestem3 */ }; - /*****************************************************************/ /* */ /* Hinter overview : */ /* */ - /* This is a two-pass hinter. On the first pass, the hints */ + /* This is a two-pass hinter. On the first pass, the hints */ /* are all recorded by the hinter, and no point is loaded */ /* in the outline. */ /* */ @@ -1491,6 +1588,7 @@ FT_Outline old_base; FT_Error error; + /* Pass 1 - try to load first glyph, simply recording points */ old_base = builder->base; T1_Reset_Builder( builder, 0 ); @@ -1506,44 +1604,51 @@ type1->num_subrs, type1->subrs, type1->subrs_len ); - if (error) goto Exit; + if ( error ) + goto Exit; - /* check for composite (i.e. "seac" operator) */ + /* check for composite (i.e. `seac' operator) */ if ( glyph->root.format == ft_glyph_format_composite ) { /* this is a composite glyph, we must then load the first one, */ /* then load the second one on top of it and translate it by a */ - /* fixed amount.. */ - FT_Outline* cur = &builder->current; - FT_UInt n_base_points; - FT_SubGlyph* subglyph = glyph->root.subglyphs; - T1_Size size = builder->size; - FT_Pos dx, dy; - FT_Vector left_bearing, advance; + /* fixed amount. */ + + FT_Outline* cur = &builder->current; + FT_UInt n_base_points; + FT_SubGlyph* subglyph = glyph->root.subglyphs; + T1_Size size = builder->size; + FT_Pos dx, dy; + FT_Vector left_bearing, advance; + /* clean glyph format */ glyph->root.format = ft_glyph_format_none; - /* First load "bchar" in builder */ + /* First load `bchar' in builder */ builder->no_recurse = 0; error = t1_load_hinted_glyph( decoder, subglyph->index, 0 ); - if (error) goto Exit; + if ( error ) + goto Exit; /* save the left bearing and width of the base character */ - /* as they will be erased by the next load.. */ + /* as they will be erased by the next load. */ left_bearing = builder->left_bearing; advance = builder->advance; - /* Then load "achar" in builder */ + /* Then load `achar' in builder */ n_base_points = builder->base.n_points; subglyph++; + error = t1_load_hinted_glyph( decoder, subglyph->index, 0 ); - if (error) goto Exit; + if ( error ) + goto Exit; /* adjust contours in accented character outline */ { FT_Int n; + for ( n = 0; n < cur->n_contours; n++ ) cur->contours[n] += n_base_points; } @@ -1551,8 +1656,8 @@ /* Finally, move the accent */ dx = FT_MulFix( subglyph->arg1, size->root.metrics.x_scale ); dy = FT_MulFix( subglyph->arg2, size->root.metrics.y_scale ); - dx = (dx+32) & -64; - dy = (dy+32) & -64; + dx = ( dx + 32 ) & -64; + dy = ( dy + 32 ) & -64; FT_Outline_Translate( cur, dx, dy ); /* restore the left side bearing and */ @@ -1584,29 +1689,31 @@ } /* save new glyph tables */ - if (recurse) + if ( recurse ) T1_Done_Builder( builder ); Exit: return error; } -#endif - +#endif /* T1_CONFIG_OPTION_DISABLE_HINTER */ + + LOCAL_FUNC FT_Error T1_Load_Glyph( T1_GlyphSlot glyph, T1_Size size, FT_Int glyph_index, FT_Int load_flags ) { - FT_Error error; - T1_Decoder decoder; - T1_Face face = (T1_Face)glyph->root.face; - FT_Bool hinting; - T1_Font* type1 = &face->type1; + FT_Error error; + T1_Decoder decoder; + T1_Face face = (T1_Face)glyph->root.face; + FT_Bool hinting; + T1_Font* type1 = &face->type1; - if (load_flags & FT_LOAD_NO_RECURSE) + + if ( load_flags & FT_LOAD_NO_RECURSE ) load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; glyph->x_scale = size->root.metrics.x_scale; @@ -1621,7 +1728,7 @@ #ifndef T1_CONFIG_OPTION_DISABLE_HINTER - hinting = (load_flags & (FT_LOAD_NO_SCALE|FT_LOAD_NO_HINTING)) == 0; + hinting = ( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) == 0; if ( hinting ) { @@ -1632,7 +1739,8 @@ error = t1_load_hinted_glyph( &decoder, glyph_index, 1 ); } else -#endif + +#endif /* T1_CONFIG_OPTION_DISABLE_HINTER */ { T1_Init_Decoder( &decoder, &gload_hinter_interface ); @@ -1640,7 +1748,7 @@ T1_Init_Builder( &decoder.builder, face, size, glyph, &gload_builder_interface ); - decoder.builder.no_recurse = !!(load_flags & FT_LOAD_NO_RECURSE); + decoder.builder.no_recurse = ( load_flags & FT_LOAD_NO_RECURSE ) != 0; /* now load the unscaled outline */ error = T1_Parse_CharStrings( &decoder, @@ -1654,14 +1762,13 @@ T1_Done_Builder( &decoder.builder ); } - - /* Now, set the metrics.. - this is rather simple, as : */ - /* the left side bearing is the xMin, and the top side */ - /* bearing the yMax.. */ - if (!error) + /* Now, set the metrics - this is rather simple, as */ + /* the left side bearing is the xMin, and the top side */ + /* bearing the yMax. */ + if ( !error ) { /* for composite glyphs, return only the left side bearing and the */ - /* advance width.. */ + /* advance width. */ if ( load_flags & FT_LOAD_NO_RECURSE ) { glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x; @@ -1672,18 +1779,20 @@ FT_BBox cbox; FT_Glyph_Metrics* metrics = &glyph->root.metrics; + /* apply the font matrix */ - FT_Outline_Transform( &glyph->root.outline, &face->type1.font_matrix ); + FT_Outline_Transform( &glyph->root.outline, + &face->type1.font_matrix ); FT_Outline_Get_CBox( &glyph->root.outline, &cbox ); /* grid fit the bounding box if necessary */ - if (hinting) + if ( hinting ) { cbox.xMin &= -64; cbox.yMin &= -64; - cbox.xMax = ( cbox.xMax+63 ) & -64; - cbox.yMax = ( cbox.yMax+63 ) & -64; + cbox.xMax = ( cbox.xMax + 63 ) & -64; + cbox.yMax = ( cbox.yMax + 63 ) & -64; } metrics->width = cbox.xMax - cbox.xMin; @@ -1693,7 +1802,7 @@ metrics->horiBearingY = cbox.yMax; /* copy the _unscaled_ advance width */ - metrics->horiAdvance = decoder.builder.advance.x; + metrics->horiAdvance = decoder.builder.advance.x; /* make up vertical metrics */ metrics->vertBearingX = 0; @@ -1709,20 +1818,20 @@ glyph->root.outline.flags |= ft_outline_reverse_fill; - /* +#if 0 glyph->root.outline.second_pass = TRUE; - glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 ); + glyph->root.outline.high_precision = size->root.metrics.y_ppem < 24; glyph->root.outline.dropout_mode = 2; - */ +#endif if ( hinting ) { - /* adjust the advance width */ - /* XXX : TODO : consider stem hints grid-fit */ + /* adjust the advance width */ + /* XXX TODO: consider stem hints grid-fit */ metrics->horiAdvance = FT_MulFix( metrics->horiAdvance, glyph->x_scale ); } - else if ( (load_flags & FT_LOAD_NO_SCALE) == 0 ) + else if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 ) { /* scale the outline and the metrics */ FT_Int n; @@ -1731,6 +1840,7 @@ FT_Fixed x_scale = glyph->x_scale; FT_Fixed y_scale = glyph->y_scale; + /* First of all, scale the points */ for ( n = cur->n_points; n > 0; n--, vec++ ) { @@ -1749,7 +1859,6 @@ metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale ); metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale ); metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, x_scale ); - } } } @@ -1757,3 +1866,5 @@ return error; } + +/* END */ diff --git a/src/type1/t1gload.h b/src/type1/t1gload.h index d0f678fb2..5d21f2e0d 100644 --- a/src/type1/t1gload.h +++ b/src/type1/t1gload.h @@ -1,36 +1,20 @@ -/******************************************************************* - * - * t1gload.h 1.0 - * - * Type1 Glyph Loader. - * - * Copyright 1996-1998 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - * - * The Type 1 glyph loader uses three distinct objects to build - * scaled and hinted outlines from a charstrings program. These are : - * - * - a glyph builder, T1_Builder, used to store the built outline - * - * - a glyph hinter, T1_Hinter, used to record and apply the stem - * hints - * - * - a charstrings interpreter, T1_Decoder, used to parse the - * Type 1 charstrings stream, manage a stack and call the builder - * and/or hinter depending on the opcodes. - * - * Ideally, a Type 2 glyph loader would only need to have its own - * T2_Decoder object (assuming the hinter is able to manage all - * kinds of hints). - * - ******************************************************************/ +/***************************************************************************/ +/* */ +/* t1gload.h */ +/* */ +/* Type 1 Glyph Loader (specification). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + #ifndef T1GLOAD_H #define T1GLOAD_H @@ -42,25 +26,15 @@ #endif -/*************************************************************************/ -/* */ -/* T1_Builder_Funcs */ -/* */ -/* */ -/* a structure used to store the address of various functions */ -/* used by a glyph builder to implement the outline's "path */ -/* construction". */ -/* */ -/* */ typedef struct T1_Builder_ T1_Builder; typedef FT_Error (*T1_Builder_EndChar)( T1_Builder* loader ); - typedef FT_Error (*T1_Builder_Sbw) ( T1_Builder* loader, - FT_Pos sbx, - FT_Pos sby, - FT_Pos wx, - FT_Pos wy ); + typedef FT_Error (*T1_Builder_Sbw)( T1_Builder* loader, + FT_Pos sbx, + FT_Pos sby, + FT_Pos wx, + FT_Pos wy ); typedef FT_Error (*T1_Builder_ClosePath)( T1_Builder* loader ); @@ -80,7 +54,17 @@ FT_Pos dx3, FT_Pos dy3 ); - typedef struct T1_Builder_Funcs_ + + /*************************************************************************/ + /* */ + /* */ + /* T1_Builder_Funcs */ + /* */ + /* */ + /* A structure to store the address of various functions used by a */ + /* glyph builder to implement the outline's `path construction'. */ + /* */ + typedef struct T1_Builder_Funcs_ { T1_Builder_EndChar end_char; T1_Builder_Sbw set_bearing_point; @@ -92,51 +76,62 @@ } T1_Builder_Funcs; - -/*************************************************************************/ -/* */ -/* T1_Builder */ -/* */ -/* */ -/* a structure used during glyph loading to store its outline. */ -/* */ -/* */ -/* system :: current system object */ -/* face :: current face object */ -/* size :: current size object */ -/* glyph :: current glyph slot */ -/* */ -/* current :: current glyph outline */ -/* base :: base glyph outline */ -/* */ -/* max_points :: maximum points in builder outline */ -/* max_contours :: maximum contours in builder outline */ -/* */ -/* last :: last point position */ -/* */ -/* scale_x :: horizontal scale ( FUnits to sub-pixels ) */ -/* scale_y :: vertical scale ( FUnits to sub-pixels ) */ -/* pos_x :: horizontal translation (composite glyphs) */ -/* pos_y :: vertical translation (composite glyph) */ -/* */ -/* left_bearing :: left side bearing point */ -/* advance :: horizontal advance vector */ -/* */ -/* path_begun :: flag, indicates that a new path has begun */ -/* load_points :: flag, if not set, no points are loaded */ -/* */ -/* pass :: pass number for multi-pass hinters */ -/* */ -/* funcs :: table of builder functions used to perform */ -/* the outline's path construction */ -/* */ -/* hint_point :: index of next point to hint.. */ -/* */ -/* */ -/* */ -/* */ - - struct T1_Builder_ + /*************************************************************************/ + /* */ + /* */ + /* T1_Builder */ + /* */ + /* */ + /* A structure used during glyph loading to store its outline. */ + /* */ + /* */ + /* memory :: The current memory object. */ + /* */ + /* face :: The current face object. */ + /* */ + /* size :: The current size object. */ + /* */ + /* glyph :: The current glyph slot. */ + /* */ + /* current :: The current glyph outline. */ + /* */ + /* base :: The base glyph outline. */ + /* */ + /* max_points :: The maximum number of points in builder outline. */ + /* */ + /* max_contours :: The maximum number of contours in builder outline. */ + /* */ + /* last :: The last point position. */ + /* */ + /* scale_x :: The horizontal scale (FUnits to sub-pixels). */ + /* */ + /* scale_y :: The vertical scale (FUnits to sub-pixels). */ + /* */ + /* pos_x :: The horizontal translation (for composite glyphs). */ + /* */ + /* pos_y :: The vertical translation (for composite glyphs). */ + /* */ + /* left_bearing :: The left side bearing point. */ + /* */ + /* advance :: The horizontal advance vector. */ + /* */ + /* no_recurse :: */ + /* */ + /* bbox :: The glyph's bounding box. */ + /* */ + /* path_begun :: A flag which indicates that a new path has begun. */ + /* */ + /* load_points :: A flag which indicates, if not set, that no points */ + /* are loaded. */ + /* */ + /* pass :: The pass number for multi-pass hinters. */ + /* */ + /* hint_point :: The index of the next point to hint. */ + /* */ + /* funcs :: A table of builder functions used to perform the */ + /* outline's path construction. */ + /* */ + struct T1_Builder_ { FT_Memory memory; T1_Face face; @@ -173,15 +168,6 @@ }; -/*************************************************************************/ -/* */ -/* T1_Hinter_Funcs */ -/* */ -/* */ -/* a structure used to store the address of various functions */ -/* used by a Type 1 hinter to perform outline hinting. */ -/* */ - typedef FT_Error (*T1_Hinter_ChangeHints)( T1_Builder* builder ); typedef FT_Error (*T1_Hinter_DotSection)( T1_Builder* builder ); @@ -191,7 +177,6 @@ FT_Pos width, FT_Bool vertical ); - typedef FT_Error (*T1_Hinter_Stem3)( T1_Builder* builder, FT_Pos pos0, FT_Pos width0, @@ -201,18 +186,27 @@ FT_Pos width2, FT_Bool vertical ); + + /*************************************************************************/ + /* */ + /* */ + /* T1_Hinter_Funcs */ + /* */ + /* */ + /* A structure to store the address of various functions used by a */ + /* Type 1 hinter to perform outline hinting. */ + /* */ typedef struct T1_Hinter_Func_ { - T1_Hinter_ChangeHints change_hints; - T1_Hinter_DotSection dot_section; - T1_Hinter_Stem stem; - T1_Hinter_Stem3 stem3; + T1_Hinter_ChangeHints change_hints; + T1_Hinter_DotSection dot_section; + T1_Hinter_Stem stem; + T1_Hinter_Stem3 stem3; } T1_Hinter_Funcs; - - typedef enum T1_Operator_ + typedef enum T1_Operator_ { op_none = 0, op_endchar, @@ -246,10 +240,8 @@ } T1_Operator; - - /* execution context charstring zone */ - typedef struct T1_Decoder_Zone_ + typedef struct T1_Decoder_Zone_ { FT_Byte* base; FT_Byte* limit; @@ -258,166 +250,54 @@ } T1_Decoder_Zone; - typedef struct T1_Decoder_ + typedef struct T1_Decoder_ { - T1_Builder builder; - T1_Hinter_Funcs hinter; + T1_Builder builder; + T1_Hinter_Funcs hinter; - FT_Int stack[ T1_MAX_CHARSTRINGS_OPERANDS ]; - FT_Int* top; + FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS]; + FT_Int* top; - T1_Decoder_Zone zones[ T1_MAX_SUBRS_CALLS+1 ]; - T1_Decoder_Zone* zone; + T1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1]; + T1_Decoder_Zone* zone; - FT_Int flex_state; - FT_Int num_flex_vectors; - FT_Vector flex_vectors[7]; + FT_Int flex_state; + FT_Int num_flex_vectors; + FT_Vector flex_vectors[7]; } T1_Decoder; - -/********************************************************************* - * - * - * T1_Init_Builder - * - * - * Initialise a given glyph builder. - * - * - * builder :: glyph builder to initialise - * face :: current face object - * size :: current size object - * glyph :: current glyph object - * funcs :: glyph builder functions (or "methods"). - * - * - * This function is exported for now because it is used by the - * "t1dump" utility. Later, it will be accessed through a - * format-specific extension - * - *********************************************************************/ - LOCAL_DEF - void T1_Init_Builder( T1_Builder* builder, - T1_Face face, - T1_Size size, - T1_GlyphSlot glyph, - const T1_Builder_Funcs* funcs ); - -/********************************************************************* - * - * - * T1_Done_Builder - * - * - * Finalise a given glyph builder. Its content can still be - * used after the call, but the function saves important information - * within the corresponding glyph slot. - * - * - * builder :: glyph builder to initialise - * - * - * This function is exported for now because it is used by the - * "t1dump" utility. Later, it will be accessed through a - * format-specific extension - * - *********************************************************************/ + void T1_Init_Builder( T1_Builder* builder, + T1_Face face, + T1_Size size, + T1_GlyphSlot glyph, + const T1_Builder_Funcs* funcs ); LOCAL_DEF void T1_Done_Builder( T1_Builder* builder ); - -/********************************************************************* - * - * - * T1_Init_Decoder - * - * - * Initialise a given Type 1 decoder for parsing - * - * - * decoder :: Type 1 decoder to initialise - * funcs :: hinter functions interface - * - * - * This function is exported for now because it is used by the - * "t1dump" utility. Later, it will be accessed through a - * format-specific extension - * - *********************************************************************/ - LOCAL_DEF void T1_Init_Decoder( T1_Decoder* decoder, const T1_Hinter_Funcs* funcs ); - - - /* Compute the maximum advance width of a font through quick parsing */ LOCAL_DEF FT_Error T1_Compute_Max_Advance( T1_Face face, - FT_Int *max_advance ); + FT_Int* max_advance ); - - /* This function is exported, because it is used by the T1Dump utility */ LOCAL_DEF - FT_Error T1_Parse_CharStrings( T1_Decoder* decoder, - FT_Byte* charstring_base, - FT_Int charstring_len, - FT_Int num_subrs, - FT_Byte** subrs_base, - FT_Int* subrs_len ); + FT_Error T1_Parse_CharStrings( T1_Decoder* decoder, + FT_Byte* charstring_base, + FT_Int charstring_len, + FT_Int num_subrs, + FT_Byte** subrs_base, + FT_Int* subrs_len ); - - -/*************************************************************************/ -/* */ -/* T1_Add_Points */ -/* */ -/* */ -/* Checks that there is enough room in the current load glyph outline */ -/* to accept "num_points" additional outline points. If not, this */ -/* function grows the load outline's arrays accordingly.. */ -/* */ -/* */ -/* builder :: pointer to glyph builder object */ -/* num_points :: number of points that will be added later */ -/* */ -/* */ -/* Type1 error code. 0 means success */ -/* */ -/* */ -/* This function does NOT update the points count in the glyph loader */ -/* This must be done by the caller itself, after this function is */ -/* invoked.. */ -/* */ LOCAL_DEF FT_Error T1_Add_Points( T1_Builder* builder, FT_Int num_points ); -/*************************************************************************/ -/* */ -/* T1_Add_Contours */ -/* */ -/* */ -/* Checks that there is enough room in the current load glyph outline */ -/* to accept "num_contours" additional contours. If not, this func */ -/* the load outline's arrays accordingly.. */ -/* */ -/* */ -/* builder :: pointer to glyph builder object */ -/* num_contours :: number of contours that will be added later */ -/* */ -/* */ -/* Type1 error code. 0 means success */ -/* */ -/* */ -/* This function does NOT update the contours count in the load glyph */ -/* This must be done by the caller itself, after this function is */ -/* invoked.. */ -/* */ LOCAL_DEF FT_Error T1_Add_Contours( T1_Builder* builder, FT_Int num_contours ); @@ -434,4 +314,8 @@ } #endif + #endif /* T1GLOAD_H */ + + +/* END */ diff --git a/src/type1/t1hinter.c b/src/type1/t1hinter.c index ac13c2f57..a0081f965 100644 --- a/src/type1/t1hinter.c +++ b/src/type1/t1hinter.c @@ -1,151 +1,160 @@ -/******************************************************************* - * - * t1hinter.c 1.2 - * - * Type1 hinter. - * - * Copyright 1996-1999 by - * David Turner, Robert Wilhelm, and Werner Lemberg. - * - * This file is part of the FreeType project, and may only be used - * modified and distributed under the terms of the FreeType project - * license, LICENSE.TXT. By continuing to use, modify, or distribute - * this file you indicate that you have read the license and - * understand and accept it fully. - * - * - * The Hinter is in charge of fitting th scaled outline to the - * pixel grid in order to considerably improve the quality of - * the Type 1 font driver's output.. - * - ******************************************************************/ +/***************************************************************************/ +/* */ +/* t1hinter.c */ +/* */ +/* Type 1 hinter (body). */ +/* */ +/* Copyright 1996-2000 by */ +/* David Turner, Robert Wilhelm, and Werner Lemberg. */ +/* */ +/* This file is part of the FreeType project, and may only be used, */ +/* modified, and distributed under the terms of the FreeType project */ +/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ +/* this file you indicate that you have read the license and */ +/* understand and accept it fully. */ +/* */ +/***************************************************************************/ + + + /*************************************************************************/ + /* */ + /* The Hinter is in charge of fitting th scaled outline to the pixel */ + /* grid in order to considerably improve the quality of the Type 1 font */ + /* driver's output. */ + /* */ + /*************************************************************************/ + #include #include #include + /*************************************************************************/ + /* */ + /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ + /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ + /* messages during execution. */ + /* */ #undef FT_COMPONENT -#define FT_COMPONENT trace_t1hint /* for debugging/tracing */ +#define FT_COMPONENT trace_t1hint #undef ONE_PIXEL #define ONE_PIXEL 64 #undef ROUND -#define ROUND(x) (( x + ONE_PIXEL/2 ) & -ONE_PIXEL) +#define ROUND( x ) ( ( x + ONE_PIXEL / 2 ) & -ONE_PIXEL ) #undef SCALE -#define SCALE(val) FT_MulFix( val, scale ) +#define SCALE( val ) FT_MulFix( val, scale ) /* various constants used to describe the alignment of a horizontal */ /* stem with regards to the blue zones */ + #define T1_ALIGN_NONE 0 #define T1_ALIGN_BOTTOM 1 #define T1_ALIGN_TOP 2 #define T1_ALIGN_BOTH 3 -/************************************************************************ - * - * - * t1_set_blue_zones - * - * - * Set a size object's blue zones during reset. This will compute - * the "snap" zone corresponding to each blue zone. - * - * - * size :: handle to target size object - * - * - * Error code. 0 means success - * - * - * This functions does the following : - * - * 1. It extracts the bottom and top blue zones from the - * face object. - * - * 2. Each zone is then grown by BlueFuzz, overlapping - * is eliminated by adjusting the zone edges appropriately - * - * 3. For each zone, we keep its original font units position, its - * original scaled position, as well as its grown/adjusted - * edges. - * - ************************************************************************/ + /* very simple bubble sort (not a lot of elements, mostly */ + /* pre-sorted, no need for quicksort) */ - /* ultra simple bubble sort (not a lot of elements, mostly */ - /* pre-sorted, no need for quicksort) */ - static - void t1_sort_blues( FT_Int* blues, - FT_Int count ) + static + void t1_sort_blues( FT_Int* blues, + FT_Int count ) + { + FT_Int i, swap; + FT_Int* cur; + + + for ( i = 2; i < count; i += 2 ) + { + cur = blues + i; + do { - FT_Int i, swap; - FT_Int* cur; + if ( cur[-1] < cur[0] ) + break; - for ( i = 2; i < count; i += 2 ) - { - cur = blues + i; - do - { - if ( cur[-1] < cur[0] ) - break; - - swap = cur[-2]; cur[-2] = cur[0]; cur[0] = swap; - swap = cur[-1]; cur[-1] = cur[1]; cur[1] = swap; - cur -= 2; - } - while ( cur > blues ); - } - } + swap = cur[-2]; cur[-2] = cur[0]; cur[0] = swap; + swap = cur[-1]; cur[-1] = cur[1]; cur[1] = swap; + cur -= 2; + } while ( cur > blues ); + } + } + /*************************************************************************/ + /* */ + /* */ + /* t1_set_blue_zones */ + /* */ + /* */ + /* Sets a size object's blue zones during reset. This will compute */ + /* the `snap' zone corresponding to each blue zone. */ + /* */ + /* */ + /* size :: A handle to target size object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + /* */ + /* This functions does the following: */ + /* */ + /* 1. It extracts the bottom and top blue zones from the face object. */ + /* */ + /* 2. Each zone is then grown by `BlueFuzz', overlapping is */ + /* eliminated by adjusting the zone edges appropriately. */ + /* */ + /* 3. For each zone, we keep its original font units position, its */ + /* original scaled position, as well as its grown/adjusted edges. */ + /* */ static FT_Error t1_set_blue_zones( T1_Size size ) { - T1_Face face = (T1_Face)size->root.face; - T1_Private* priv = &face->type1.private_dict; - FT_Int n; - FT_Int blues[24]; - FT_Int num_bottom; - FT_Int num_top; - FT_Int num_blues; - T1_Size_Hints* hints = size->hints; - T1_Snap_Zone* zone; - FT_Pos pix, orus; - FT_Pos min, max, threshold; - FT_Fixed scale; - FT_Bool is_bottom; + T1_Face face = (T1_Face)size->root.face; + T1_Private* priv = &face->type1.private_dict; + FT_Int n; + FT_Int blues[24]; + FT_Int num_bottom; + FT_Int num_top; + FT_Int num_blues; + T1_Size_Hints* hints = size->hints; + T1_Snap_Zone* zone; + FT_Pos pix, orus; + FT_Pos min, max, threshold; + FT_Fixed scale; + FT_Bool is_bottom; - /**********************************************************************/ - /* */ - /* COPY BOTTOM AND TOP BLUE ZONES IN LOCAL ARRAYS */ - /* */ - /* */ + + /***********************************************************************/ + /* */ + /* copy bottom and top blue zones in local arrays */ + /* */ /* First of all, check the sizes of the /BlueValues and /OtherBlues */ - /* tables. They all must contain an even number of arguments */ + /* tables. They all must contain an even number of arguments. */ if ( priv->num_other_blues & 1 || priv->num_blue_values & 1 ) { - FT_ERROR(( "T1.Copy_Blues : odd number of blue values\n" )); + FT_ERROR(( "t1_set_blue_zones: odd number of blue values\n" )); return T1_Err_Syntax_Error; } - /* copy the bottom blue zones from /OtherBlues */ + /* copy the bottom blue zones from /OtherBlues */ num_top = 0; num_bottom = priv->num_other_blues; for ( n = 0; n < num_bottom; n ++ ) blues[n] = priv->other_blues[n]; - /* Add the first blue zone in /BlueValues to the table */ + /* add the first blue zone in /BlueValues to the table */ num_top = priv->num_blue_values - 2; if ( num_top >= 0 ) { - blues[ num_bottom ] = priv->blue_values[0]; - blues[num_bottom+1] = priv->blue_values[1]; + blues[num_bottom ] = priv->blue_values[0]; + blues[num_bottom + 1] = priv->blue_values[1]; num_bottom += 2; } @@ -159,7 +168,7 @@ if ( num_top > 0 ) { for ( n = 0; n < num_top; n++ ) - blues[ num_bottom+n ] = priv->blue_values[n+2]; + blues[num_bottom + n] = priv->blue_values[n + 2]; /* sort the top blue zones */ t1_sort_blues( blues + num_bottom, num_top ); @@ -170,28 +179,29 @@ num_blues = num_top + num_bottom; hints->num_blue_zones = ( num_blues ) >> 1; - /**********************************************************************/ - /* */ - /* BUILD BLUE SNAP ZONES FROM THE LOCAL BLUES ARRAYS */ - /* */ - /* */ + /***********************************************************************/ + /* */ + /* build blue snap zones from the local blues arrays */ + /* */ scale = size->root.metrics.y_scale; zone = hints->blue_zones; - threshold = ONE_PIXEL/4; /* 0.25 pixels */ + threshold = ONE_PIXEL / 4; /* 0.25 pixels */ for ( n = 0; n < num_blues; n += 2, zone ++ ) { - is_bottom = ( n < num_bottom ? 1 : 0 ); + is_bottom = n < num_bottom ? 1 : 0; - orus = blues[n+is_bottom]; /* get alignement coordinate */ - pix = SCALE( orus ); /* scale it */ + orus = blues[n + is_bottom]; /* get alignement coordinate */ + pix = SCALE( orus ); /* scale it */ - min = SCALE( blues[ n ] - priv->blue_fuzz ); - max = SCALE( blues[n+1] + priv->blue_fuzz ); + min = SCALE( blues[n ] - priv->blue_fuzz ); + max = SCALE( blues[n + 1] + priv->blue_fuzz ); - if ( min > pix - threshold ) min = pix - threshold; - if ( max < pix + threshold ) max = pix + threshold; + if ( min > pix - threshold ) + min = pix - threshold; + if ( max < pix + threshold ) + max = pix + threshold; zone->orus = orus; zone->pix = pix; @@ -203,24 +213,22 @@ zone = hints->blue_zones; for ( n = 0; n < num_blues-2; n += 2, zone ++ ) { - if ( n != num_bottom-2 && + if ( n != num_bottom - 2 && zone[0].max > zone[1].min ) - { - zone[0].max = zone[1].min = (zone[0].pix+zone[1].pix)/2; - } + zone[0].max = zone[1].min = ( zone[0].pix + zone[1].pix ) / 2; } - /* Compare the current pixel size with the BlueScale value */ - /* to know wether to supress overshoots.. */ + /* to know whether to supress overshoots. */ hints->supress_overshoots = - ( size->root.metrics.y_ppem < FT_MulFix(1000,priv->blue_scale) ); + size->root.metrics.y_ppem < FT_MulFix( 1000, priv->blue_scale ); - /* Now print the new blue values in tracing mode */ #ifdef FT_DEBUG_LEVEL_TRACE - FT_TRACE2(( "Blue Zones for size object at $%08lx :\n", (long)size )); + /* Now print the new blue values in tracing mode */ + + FT_TRACE2(( "Blue Zones for size object at $%08lx:\n", (long)size )); FT_TRACE2(( " orus pix min max\n" )); FT_TRACE2(( "-------------------------------\n" )); @@ -228,14 +236,14 @@ for ( n = 0; n < hints->num_blue_zones; n++ ) { FT_TRACE2(( " %3d %.2f %.2f %.2f\n", - zone->orus, - zone->pix/64.0, - zone->min/64.0, - zone->max/64.0 )); + zone->orus, + zone->pix / 64.0, + zone->min / 64.0, + zone->max / 64.0 )); zone++; } - FT_TRACE2(( "\nOver shoots are %s\n\n", - hints->supress_overshoots ? "supressed" : "active" )); + FT_TRACE2(( "\nOvershoots are %s\n\n", + hints->supress_overshoots ? "supressed" : "active" )); #endif /* DEBUG_LEVEL_TRACE */ @@ -243,38 +251,35 @@ } - -/************************************************************************ - * - * - * t1_set_snap_zones - * - * - * This function set a size object's stem snap zones. - * - * - * size :: handle to target size object - * - * - * Error code. 0 means success - * - * - * This function performs the following : - * - * 1. It reads and scales the stem snap widths from the parent face - * - * 2. A "snap zone" is computed for each snap width, by "growing" - * it with a threshold of a 1/2 pixel. Overlapping is avoided - * through proper edge adjustment. - * - * 3. Each width whose zone contain the scaled standard set width - * is removed from the table - * - * 4. Finally, the standard set width is scaled, and its correponding - * "snap zone" is inserted into the sorted snap zones table - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* t1_set_snap_zones */ + /* */ + /* */ + /* This function set a size object's stem snap zones. */ + /* */ + /* */ + /* size :: A handle to the target size object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ + /* */ + /* This function performs the following: */ + /* */ + /* 1. It reads and scales the stem snap widths from the parent face. */ + /* */ + /* 2. A `snap zone' is computed for each snap width, by `growing' it */ + /* with a threshold of 1/2 pixel. Overlapping is avoided through */ + /* proper edge adjustment. */ + /* */ + /* 3. Each width whose zone contain the scaled standard set width is */ + /* removed from the table. */ + /* */ + /* 4. Finally, the standard set width is scaled, and its correponding */ + /* `snap zone' is inserted into the sorted snap zones table. */ + /* */ static FT_Error t1_set_snap_zones( T1_Size size ) { @@ -285,10 +290,11 @@ FT_Pos standard_width; FT_Fixed scale; - T1_Face face = (T1_Face)size->root.face; - T1_Private* priv = &face->type1.private_dict; + T1_Face face = (T1_Face)size->root.face; + T1_Private* priv = &face->type1.private_dict; T1_Size_Hints* hints = size->hints; + /* start with horizontal snap zones */ direction = 0; standard_width = priv->standard_width[0]; @@ -297,24 +303,26 @@ orgs = priv->snap_widths; scale = size->root.metrics.x_scale; - while (direction < 2) + while ( direction < 2 ) { - /*****************************************************************/ - /* */ - /* Read and scale stem snap widths table from the physical */ - /* font record. */ - /* */ + /*********************************************************************/ + /* */ + /* Read and scale stem snap widths table from the physical font */ + /* record. */ + /* */ + FT_Pos prev, orus, pix, min, max, threshold; - threshold = ONE_PIXEL/4; + + threshold = ONE_PIXEL / 4; zone = base_zone; if ( n_zones > 0 ) { orus = *orgs++; pix = SCALE( orus ); - min = pix-threshold; - max = pix+threshold; + min = pix - threshold; + max = pix + threshold; zone->orus = orus; zone->pix = pix; @@ -326,12 +334,12 @@ orus = *orgs++; pix = SCALE( orus ); - if ( pix-prev < 2*threshold ) + if ( pix - prev < 2 * threshold ) { - min = max = (pix+prev)/2; + min = max = ( pix + prev ) / 2; } else - min = pix-threshold; + min = pix - threshold; zone->max = max; zone++; @@ -339,49 +347,52 @@ zone->pix = pix; zone->min = min; - max = pix+threshold; + max = pix + threshold; prev = pix; } zone->max = max; } - /* print the scaled stem snap values in tracing modes */ #ifdef FT_DEBUG_LEVEL_TRACE - FT_TRACE2(( "Set_Snap_Zones : first %s pass\n", - direction ? "vertical" : "horizontal" )); + /* print the scaled stem snap values in tracing mode */ - FT_TRACE2(( "Scaled original stem snap zones :\n" )); + FT_TRACE2(( "Set_Snap_Zones: first %s pass\n", + direction ? "vertical" : "horizontal" )); + + FT_TRACE2(( "Scaled original stem snap zones:\n" )); FT_TRACE2(( " orus pix min max\n" )); FT_TRACE2(( "-----------------------------\n" )); zone = base_zone; for ( n = 0; n < n_zones; n++, zone++ ) FT_TRACE2(( " %3d %.2f %.2f %.2f\n", - zone->orus, - zone->pix/64.0, - zone->min/64.0, - zone->max/64.0 )); - FT_TRACE2(( "\n" )); + zone->orus, + zone->pix / 64.0, + zone->min / 64.0, + zone->max / 64.0 )); + FT_TRACE2(( "\n" )); - FT_TRACE2(( "Standard width = %d\n", standard_width )); -#endif + FT_TRACE2(( "Standard width = %d\n", standard_width )); - /*****************************************************************/ - /* */ - /* Now, each snap width which is in the range of the standard */ - /* set width will be removed from the list.. */ - /* */ +#endif /* FT_DEBUG_LEVEL_TRACE */ + + /*********************************************************************/ + /* */ + /* Now, each snap width which is in the range of the standard set */ + /* width will be removed from the list. */ + /* */ if ( standard_width > 0 ) { T1_Snap_Zone* parent; FT_Pos std_pix, std_min, std_max; + std_pix = SCALE( standard_width ); - std_min = std_pix-threshold; - std_max = std_pix+threshold; + std_min = std_pix - threshold; + std_max = std_pix + threshold; num_zones = 0; zone = base_zone; @@ -392,8 +403,10 @@ if ( zone->pix >= std_min && zone->pix <= std_max ) { /* this zone must be removed from the list */ - if ( std_min > zone->min ) std_min = zone->min; - if ( std_max < zone->max ) std_max = zone->max; + if ( std_min > zone->min ) + std_min = zone->min; + if ( std_max < zone->max ) + std_max = zone->max; } else { @@ -403,21 +416,23 @@ zone++; } - /**********************************************/ - /* Now, insert the standard width zone */ + /*******************************************************************/ + /* */ + /* Now, insert the standard width zone */ + /* */ - zone = base_zone+num_zones; + zone = base_zone + num_zones; while ( zone > base_zone && zone[-1].pix > std_max ) { zone[0] = zone[-1]; - zone --; + zone--; } /* check border zones */ if ( zone > base_zone && zone[-1].max > std_min ) zone[-1].max = std_min; - if ( zone < base_zone+num_zones && zone[1].min < std_max ) + if ( zone < base_zone + num_zones && zone[1].min < std_max ) zone[1].min = std_max; zone->orus = standard_width; @@ -431,30 +446,34 @@ num_zones = n_zones; /* save total number of stem snaps now */ - if (direction) hints->num_snap_heights = num_zones; - else hints->num_snap_widths = num_zones; + if ( direction ) + hints->num_snap_heights = num_zones; + else + hints->num_snap_widths = num_zones; - /* print the scaled stem snap values in tracing modes */ #ifdef FT_DEBUG_LEVEL_TRACE - FT_TRACE2(( "Set_Snap_Zones : second %s pass\n", - direction ? "vertical" : "horizontal" )); + /* print the scaled stem snap values in tracing mode */ - FT_TRACE2(( "Scaled clipped stem snap zones :\n" )); + FT_TRACE2(( "Set_Snap_Zones: second %s pass\n", + direction ? "vertical" : "horizontal" )); + + FT_TRACE2(( "Scaled clipped stem snap zones:\n" )); FT_TRACE2(( " orus pix min max\n" )); FT_TRACE2(( "-----------------------------\n" )); zone = base_zone; for ( n = 0; n < num_zones; n++, zone++ ) FT_TRACE2(( " %3d %.2f %.2f %.2f\n", - zone->orus, - zone->pix/64.0, - zone->min/64.0, - zone->max/64.0 )); + zone->orus, + zone->pix / 64.0, + zone->min / 64.0, + zone->max / 64.0 )); FT_TRACE2(( "\n" )); FT_TRACE2(( "Standard width = %d\n", standard_width )); -#endif + +#endif /* FT_DEBUG_LEVEL_TRACE */ /* continue with vertical snap zone */ direction++; @@ -469,153 +488,145 @@ } -/************************************************************************ - * - * - * T1_New_Size_Hinter - * - * - * Allocates a new hinter structure for a given size object - * - * - * size :: handle to target size object - * - * - * Error code. 0 means success - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* T1_New_Size_Hinter */ + /* */ + /* */ + /* Allocates a new hinter structure for a given size object. */ + /* */ + /* */ + /* size :: A handle to the target size object. */ + /* */ + /* */ + /* FreeType Error code. 0 means success. */ + /* */ LOCAL_FUNC FT_Error T1_New_Size_Hinter( T1_Size size ) { FT_Memory memory = size->root.face->memory; - return MEM_Alloc( size->hints, sizeof(*size->hints) ); + + return MEM_Alloc( size->hints, sizeof ( *size->hints ) ); } -/************************************************************************ - * - * - * T1_Done_Size_Hinter - * - * - * Releases a given size object's hinter structure - * - * - * size :: handle to target size object - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* T1_Done_Size_Hinter */ + /* */ + /* */ + /* Releases a given size object's hinter structure. */ + /* */ + /* */ + /* size :: A handle to the target size object. */ + /* */ LOCAL_FUNC - void T1_Done_Size_Hinter( T1_Size size ) + void T1_Done_Size_Hinter( T1_Size size ) { FT_Memory memory = size->root.face->memory; + FREE( size->hints ); } - -/************************************************************************ - * - * - * T1_Reset_Size_Hinter - * - * - * Recomputes hinting information when a given size object has - * changed its resolutions/char sizes/pixel sizes - * - * - * size :: handle to size object - * - * - * Error code. 0 means success - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* T1_Reset_Size_Hinter */ + /* */ + /* */ + /* Recomputes hinting information when a given size object has */ + /* changed its resolutions/char sizes/pixel sizes. */ + /* */ + /* */ + /* size :: A handle to the size object. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ LOCAL_FUNC FT_Error T1_Reset_Size_Hinter( T1_Size size ) { - return t1_set_blue_zones(size) || t1_set_snap_zones(size); + return t1_set_blue_zones( size ) || t1_set_snap_zones( size ); } - -/************************************************************************ - * - * - * T1_New_Glyph_Hinter - * - * - * Allocates a new hinter structure for a given glyph slot - * - * - * glyph :: handle to target glyph slot - * - * - * Error code. 0 means success - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* T1_New_Glyph_Hinter */ + /* */ + /* */ + /* Allocates a new hinter structure for a given glyph slot. */ + /* */ + /* */ + /* glyph :: A handle to the target glyph slot. */ + /* */ + /* */ + /* FreeType error code. 0 means success. */ + /* */ LOCAL_FUNC FT_Error T1_New_Glyph_Hinter( T1_GlyphSlot glyph ) { FT_Memory memory = glyph->root.face->memory; - return MEM_Alloc( glyph->hints, sizeof(*glyph->hints) ); + + return MEM_Alloc( glyph->hints, sizeof ( *glyph->hints ) ); } -/************************************************************************ - * - * - * T1_Done_Glyph_Hinter - * - * - * Releases a given glyph slot's hinter structure - * - * - * glyph :: handle to glyph slot - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* T1_Done_Glyph_Hinter */ + /* */ + /* */ + /* Releases a given glyph slot's hinter structure. */ + /* */ + /* */ + /* glyph :: A handle to the glyph slot. */ + /* */ LOCAL_FUNC void T1_Done_Glyph_Hinter( T1_GlyphSlot glyph ) { FT_Memory memory = glyph->root.face->memory; + FREE( glyph->hints ); } + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********** **********/ + /********** HINTED GLYPH LOADER **********/ + /********** **********/ + /********** The following code is in charge of the first **********/ + /********** and second pass when loading a single outline **********/ + /********** **********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ - /********** *********/ - /********** *********/ - /********** HINTED GLYPH LOADER *********/ - /********** *********/ - /********** The following code is in charge of the first *********/ - /********** and second pass when loading a single outline *********/ - /********** *********/ - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ static - FT_Error t1_hinter_ignore( void ) + FT_Error t1_hinter_ignore( void ) { - /* do nothing, used for "dotsection" which is unsupported for now */ + /* do nothing, used for `dotsection' which is unsupported for now */ return 0; } + static - FT_Error t1_hinter_stem( T1_Builder* builder, - FT_Pos pos, - FT_Int width, - FT_Bool vertical ) + FT_Error t1_hinter_stem( T1_Builder* builder, + FT_Pos pos, + FT_Int width, + FT_Bool vertical ) { T1_Stem_Table* stem_table; T1_Stem_Hint* stems; @@ -624,15 +635,15 @@ FT_Bool new_stem; T1_Glyph_Hints* hinter = builder->glyph->hints; + /* select the appropriate stem array */ stem_table = vertical ? &hinter->vert_stems : &hinter->hori_stems; stems = stem_table->stems; num_stems = stem_table->num_stems; /* Compute minimum and maximum coord for the stem */ - min = pos + ( vertical - ? builder->left_bearing.x - : builder->left_bearing.y ); + min = pos + ( vertical ? builder->left_bearing.x + : builder->left_bearing.y ); if ( width >= 0 ) max = min + width; @@ -645,8 +656,8 @@ max = min; } - /* now scan the array. If we find a stem with the same borders */ - /* simply activate it.. */ + /* now scan the array. If we find a stem with the same borders */ + /* simply activate it. */ cur_stem = stems; new_stem = 1; @@ -656,10 +667,10 @@ cur_stem->max_edge.orus == max ) { /* This stem is already in the table, simply activate it */ - if ( (cur_stem->hint_flags & T1_HINT_FLAG_ACTIVE) == 0) + if ( ( cur_stem->hint_flags & T1_HINT_FLAG_ACTIVE ) == 0 ) { - cur_stem->hint_flags |= T1_HINT_FLAG_ACTIVE; - stem_table->num_active ++; + cur_stem->hint_flags |= T1_HINT_FLAG_ACTIVE; + stem_table->num_active++; } new_stem = 0; break; @@ -667,16 +678,16 @@ } /* add a new stem to the array when necessary */ - if (new_stem) + if ( new_stem ) { - if (cur_stem >= stems + T1_HINTER_MAX_EDGES) + if ( cur_stem >= stems + T1_HINTER_MAX_EDGES ) { - FT_ERROR(( "T1.Hinter : too many stems in glyph charstring\n" )); + FT_ERROR(( "t1_hinter_stem: : too many stems in glyph charstring\n" )); return T1_Err_Syntax_Error; } /* on the first pass, we record the stem, otherwise, this is */ - /* a bug in the glyph loader !! */ + /* a bug in the glyph loader! */ if ( builder->pass == 0 ) { cur_stem->min_edge.orus = min; @@ -688,7 +699,7 @@ } else { - FT_ERROR(( "T1.Hinter : fatal glyph loader bug - pass2-stem\n" )); + FT_ERROR(( "t1_hinter_stem: fatal glyph loader bug - pass2-stem\n" )); return T1_Err_Syntax_Error; } } @@ -698,16 +709,16 @@ static - FT_Error t1_hinter_stem3( T1_Builder* builder, - FT_Pos pos0, - FT_Int width0, - FT_Pos pos1, - FT_Int width1, - FT_Pos pos2, - FT_Int width2, - FT_Bool vertical ) + FT_Error t1_hinter_stem3( T1_Builder* builder, + FT_Pos pos0, + FT_Int width0, + FT_Pos pos1, + FT_Int width1, + FT_Pos pos2, + FT_Int width2, + FT_Bool vertical ) { - /* For now, don't be elitist and simply call "stem" 3 times */ + /* For now, simply call `stem' 3 times */ return t1_hinter_stem( builder, pos0, width0, vertical ) || t1_hinter_stem( builder, pos1, width1, vertical ) || t1_hinter_stem( builder, pos2, width2, vertical ); @@ -721,9 +732,10 @@ T1_Stem_Table* stem_table; T1_Glyph_Hints* hinter = builder->glyph->hints; - /* if we're in the second pass of glyph hinting, we must */ - /* call the function T1_Hint_Points on the builder in order */ - /* to force the fit the latest points to the pixel grid */ + + /* If we are in the second pass of glyph hinting, we must */ + /* call the function T1_Hint_Points() on the builder in order */ + /* to force the fit the latest points to the pixel grid. */ if ( builder->pass == 1 ) T1_Hint_Points( builder ); @@ -735,6 +747,7 @@ T1_Stem_Hint* cur = stem_table->stems; T1_Stem_Hint* limit = cur + stem_table->num_stems; + for ( ; cur < limit; cur++ ) cur->hint_flags &= ~T1_HINT_FLAG_ACTIVE; @@ -749,41 +762,40 @@ LOCAL_FUNC const T1_Hinter_Funcs t1_hinter_funcs = { - (T1_Hinter_ChangeHints) t1_hinter_changehints, - (T1_Hinter_DotSection) t1_hinter_ignore, - (T1_Hinter_Stem) t1_hinter_stem, - (T1_Hinter_Stem3) t1_hinter_stem3 + (T1_Hinter_ChangeHints)t1_hinter_changehints, + (T1_Hinter_DotSection) t1_hinter_ignore, + (T1_Hinter_Stem) t1_hinter_stem, + (T1_Hinter_Stem3) t1_hinter_stem3 }; - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ - /********** *********/ - /********** *********/ - /********** STEM HINTS MANAGEMENT *********/ - /********** *********/ - /********** The following code is in charge of computing *********/ - /********** the placement of each scaled stem hint.. *********/ - /********** *********/ - /**********************************************************************/ - /**********************************************************************/ - /**********************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ + /********** *********/ + /********** *********/ + /********** STEM HINTS MANAGEMENT *********/ + /********** *********/ + /********** The following code is in charge of computing *********/ + /********** the placement of each scaled stem hint. *********/ + /********** *********/ + /*************************************************************************/ + /*************************************************************************/ + /*************************************************************************/ -/************************************************************************ - * - * - * t1_sort_hints - * - * - * Sort the list of active stems in increasing order, through - * the "sort" indexing table - * - * - * table :: a stem hints table - * - ************************************************************************/ + /*************************************************************************/ + /* */ + /* */ + /* t1_sort_hints */ + /* */ + /* */ + /* Sorta the list of active stems in increasing order, through the */ + /* `sort' indexing table. */ + /* */ + /* */ + /* table :: A stem hints table. */ + /* */ static void t1_sort_hints( T1_Stem_Table* table ) { @@ -793,6 +805,7 @@ T1_Stem_Hint* stems = table->stems; FT_Int n; + /* record active stems in sort table */ for ( n = 0; n < num_stems; n++ ) { @@ -800,64 +813,65 @@ sort[num_active++] = n; } - /* now sort the indices. There are usually very few stems, */ - /* and they are pre-sorted in 90% cases, so we choose a */ - /* simple bubble sort (quicksort would be slower).. */ + /* now sort the indices. There are usually very few stems, */ + /* and they are pre-sorted in 90% cases, so we choose a */ + /* simple bubble sort (quicksort would be slower). */ for ( n = 1; n < num_active; n++ ) { - FT_Int p = n-1; - T1_Stem_Hint* cur = stems + sort[n]; + FT_Int p = n - 1; + T1_Stem_Hint* cur = stems + sort[n]; + do { FT_Int swap; T1_Stem_Hint* prev = stems + sort[p]; - /* note that by definition, the active stems cannot overlap */ - /* so we simply compare their "min" to sort them.. */ - /* (we could compare their max, this wouldn't change anything) */ + + /* note that by definition, the active stems cannot overlap */ + /* so we simply compare their `min' to sort them (we could compare */ + /* their max values also; this wouldn't change anything). */ if ( prev->min_edge.orus <= cur->min_edge.orus ) break; /* swap elements */ - swap = sort[ p ]; - sort[ p ] = sort[p+1]; - sort[p+1] = swap; + swap = sort[p ]; + sort[p ] = sort[p + 1]; + sort[p + 1] = swap; p--; - } - while ( p >= 0 ); + } while ( p >= 0 ); } table->num_active = num_active; } -/************************************************************************ - * - * - * t1_hint_horizontal_stems - * - * - * Compute the location of each scaled horizontal stem hint. - * This takes care of the blue zones and the horizontal stem - * snap table - * - * - * table :: the horizontal stem hints table - * hints :: the current size's hint structure - * blueShift :: the value of the /BlueShift as taken from the - * face object. - * scale :: the 16.16 scale used to convert outline - * units to 26.6 pixels - * - * - * For now, all stems are hinted independently from each other. - * It might be necessary, for better performance, to introduce - * the notion of "controlled" hints describing things like - * counter-stems, stem3 as well as overlapping stems control. - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* t1_hint_horizontal_stems */ + /* */ + /* */ + /* Computes the location of each scaled horizontal stem hint. This */ + /* takes care of the blue zones and the horizontal stem snap table. */ + /* */ + /* */ + /* table :: The horizontal stem hints table. */ + /* */ + /* hints :: The current size's hint structure. */ + /* */ + /* blueShift :: The value of the /BlueShift as taken from the face */ + /* object. */ + /* */ + /* scale :: The 16.16 scale used to convert outline units to */ + /* 26.6 pixels. */ + /* */ + /* */ + /* For now, all stems are hinted independently from each other. It */ + /* might be necessary, for better performance, to introduce the */ + /* notion of `controlled' hints describing things like counter-stems, */ + /* stem3, as well as overlapping stems control. */ + /* */ static void t1_hint_horizontal_stems( T1_Stem_Table* table, T1_Size_Hints* hints, @@ -867,8 +881,9 @@ T1_Stem_Hint* stem = table->stems; T1_Stem_Hint* limit = stem + table->num_stems; + /* first of all, scale the blueShift */ - blueShift = SCALE(blueShift); + blueShift = SCALE( blueShift ); /* then scan the horizontal stem table */ for ( ; stem < limit; stem++ ) @@ -884,56 +899,71 @@ FT_Pos top = top_pix; FT_Int align = T1_ALIGN_NONE; - /******************************************************************/ - /* Snap pixel width if in stem snap range */ + + /*********************************************************************/ + /* */ + /* Snap pixel width if in stem snap range */ + /* */ + { T1_Snap_Zone* zone = hints->snap_heights; T1_Snap_Zone* zone_limit = zone + hints->num_snap_heights; - FT_Pos best_dist = 32000; - T1_Snap_Zone* best_zone = 0; + FT_Pos best_dist = 32000; + T1_Snap_Zone* best_zone = 0; + for ( ; zone < zone_limit; zone++ ) { FT_Pos dist; - dist = width_pix - zone->min; if (dist < 0) dist = -dist; - if (dist < best_dist) + + dist = width_pix - zone->min; + if ( dist < 0 ) + dist = -dist; + if ( dist < best_dist ) { best_zone = zone; best_dist = dist; } } - if (best_zone) + if ( best_zone ) { - if (width_pix > best_zone->pix) + if ( width_pix > best_zone->pix ) { width_pix -= 0x20; - if (width_pix < best_zone->pix) + if ( width_pix < best_zone->pix ) width_pix = best_zone->pix; } else { width_pix += 0x20; - if (width_pix > best_zone->pix) + if ( width_pix > best_zone->pix ) width_pix = best_zone->pix; } } } - /******************************************************************/ - /* round width - minimum 1 pixel if this isn't a ghost stem */ + /*********************************************************************/ + /* */ + /* round width - minimum 1 pixel if this isn't a ghost stem */ + /* */ + if ( width_pix > 0 ) - width_pix = ( width_pix < ONE_PIXEL ? ONE_PIXEL : ROUND(width_pix) ); + width_pix = width_pix < ONE_PIXEL ? ONE_PIXEL : ROUND( width_pix ); - /******************************************************************/ - /* Now check for bottom blue zones alignement */ + /*********************************************************************/ + /* */ + /* Now check for bottom blue zones alignement */ + /* */ + { FT_Int num_blues = hints->num_bottom_zones; T1_Snap_Zone* blue = hints->blue_zones; T1_Snap_Zone* blue_limit = blue + num_blues; + for ( ; blue < blue_limit; blue++ ) { if ( bottom_pix < blue->min ) @@ -944,21 +974,24 @@ align = T1_ALIGN_BOTTOM; bottom = ROUND( blue->pix ); - /* implements blue shift */ - if (!hints->supress_overshoots) + /* implement blue shift */ + if ( !hints->supress_overshoots ) { FT_Pos delta = blue->pix - bottom_pix; - delta = ( delta < blueShift ? 0 : ROUND( delta ) ); + + delta = delta < blueShift ? 0 : ROUND( delta ); bottom -= delta; } } } } + /*********************************************************************/ + /* */ + /* check for top blue zones alignement */ + /* */ - /******************************************************************/ - /* Check for top blue zones alignement */ { FT_Int num_blues = hints->num_blue_zones - hints->num_bottom_zones; @@ -968,6 +1001,7 @@ T1_Snap_Zone* blue_limit = blue + num_blues; + for ( ; blue < blue_limit; blue++ ) { if ( top_pix < blue->min ) @@ -975,49 +1009,50 @@ if ( top_pix <= blue->max ) { - align |= T1_ALIGN_TOP; - top = ROUND( blue->pix ); + align |= T1_ALIGN_TOP; + top = ROUND( blue->pix ); - /* implements blue shift */ - if (!hints->supress_overshoots) + /* implement blue shift */ + if ( !hints->supress_overshoots ) { FT_Pos delta = top - blue->pix; - delta = ( delta < blueShift ? 0 : ROUND( delta ) ); + + delta = delta < blueShift ? 0 : ROUND( delta ); top += delta; } } } } + /*********************************************************************/ + /* */ + /* compute the hinted stem position, according to its alignment */ + /* */ - /******************************************************************/ - /* compute the hinted stem position, according to its alignment */ - switch (align) + switch ( align ) { - case T1_ALIGN_BOTTOM: /* bottom zone alignement */ - bottom_pix = bottom; - top_pix = bottom + width_pix; - break; + case T1_ALIGN_BOTTOM: /* bottom zone alignment */ + bottom_pix = bottom; + top_pix = bottom + width_pix; + break; - case T1_ALIGN_TOP: /* top zone alignement */ - top_pix = top; - bottom_pix = top - width_pix; + case T1_ALIGN_TOP: /* top zone alignment */ + top_pix = top; + bottom_pix = top - width_pix; + break; - break; + case T1_ALIGN_BOTH: /* bottom+top zone alignment */ + bottom_pix = bottom; + top_pix = top; + break; - case T1_ALIGN_BOTH: /* bottom+top zone alignement */ - bottom_pix = bottom; - top_pix = top; - break; + default: /* no alignment */ + /* XXXX : TODO : Add management of controlled stems */ + bottom = ( SCALE( bottom_orus + top_orus ) - width_pix ) / 2; - default: /* no alignement */ - - /* XXXX : TODO : Add management of controlled stems */ - bottom = ( SCALE(bottom_orus+top_orus) - width_pix )/2; - - bottom_pix = ROUND(bottom); - top_pix = bottom_pix + width_pix; + bottom_pix = ROUND( bottom ); + top_pix = bottom_pix + width_pix; } stem->min_edge.pix = bottom_pix; @@ -1026,33 +1061,27 @@ } - - -/************************************************************************ - * - * - * t1_hint_vertical_stems - * - * - * Compute the location of each scaled vertical stem hint. - * This takes care of the vertical stem snap table - * - * - * table :: the vertical stem hints table - * hints :: the current size's hint structure - * scale :: the 16.16 scale used to convert outline - * units to 26.6 pixels - * - * - * For now, all stems are hinted independently from each other. - * It might be necessary, for better performance, to introduce - * the notion of "controlled" hints describing things like - * counter-stems, stem3 as well as overlapping stems control. - * - ************************************************************************/ - - /* compute the location of each scaled vertical stem hint. */ - /* Take care of blue zones and stem snap table */ + /*************************************************************************/ + /* */ + /* */ + /* t1_hint_vertical_stems */ + /* */ + /* */ + /* Computes the location of each scaled vertical stem hint. This */ + /* takes care of the vertical stem snap table. */ + /* */ + /* */ + /* table :: The vertical stem hints table. */ + /* hints :: The current size's hint structure. */ + /* scale :: The 16.16 scale used to convert outline units to */ + /* 26.6 pixels. */ + /* */ + /* */ + /* For now, all stems are hinted independently from each other. It */ + /* might be necessary, for better performance, to introduce the */ + /* notion of `controlled' hints describing things like counter-stems, */ + /* stem3 as well as overlapping stems control. */ + /* */ static void t1_hint_vertical_stems( T1_Stem_Table* table, T1_Size_Hints* hints, @@ -1061,45 +1090,51 @@ T1_Stem_Hint* stem = table->stems; T1_Stem_Hint* limit = stem + table->num_stems; + for ( ; stem < limit; stem++ ) { FT_Pos stem_left = stem->min_edge.orus; FT_Pos stem_right = stem->max_edge.orus; FT_Pos width_pix, left; + width_pix = SCALE( stem_right - stem_left ); /* Snap pixel width if in stem snap range */ { T1_Snap_Zone* zone = hints->snap_heights; T1_Snap_Zone* zone_limit = zone + hints->num_snap_heights; - FT_Pos best_dist = 32000; - T1_Snap_Zone* best_zone = 0; + FT_Pos best_dist = 32000; + T1_Snap_Zone* best_zone = 0; + for ( ; zone < zone_limit; zone++ ) { FT_Pos dist; - dist = width_pix - zone->min; if (dist < 0) dist = -dist; - if (dist < best_dist) + + dist = width_pix - zone->min; + if ( dist < 0 ) + dist = -dist; + if ( dist < best_dist ) { best_zone = zone; best_dist = dist; } } - if (best_zone) + if ( best_zone ) { - if (width_pix > best_zone->pix) + if ( width_pix > best_zone->pix ) { width_pix -= 0x20; - if (width_pix < best_zone->pix) + if ( width_pix < best_zone->pix ) width_pix = best_zone->pix; } else { width_pix += 0x20; - if (width_pix > best_zone->pix) + if ( width_pix > best_zone->pix ) width_pix = best_zone->pix; } } @@ -1107,49 +1142,44 @@ /* round width - minimum 1 pixel if this isn't a ghost stem */ if ( width_pix > 0 ) - width_pix = ( width_pix < ONE_PIXEL ? ONE_PIXEL : - ROUND( width_pix ) ); + width_pix = width_pix < ONE_PIXEL ? ONE_PIXEL + : ROUND( width_pix ); - /* now place the snapped and rounded stem */ + /* now place the snapped and rounded stem */ + /* XXX TODO: implement controlled stems for the overlapping */ + /* cases. */ - /* XXXX : TODO : implement controlled stems for the overlapping */ - /* cases.. */ + left = ( SCALE( stem_left + stem_right ) - width_pix ) / 2; - left = ( SCALE(stem_left+stem_right) - width_pix )/2; - - stem->min_edge.pix = ROUND(left); + stem->min_edge.pix = ROUND( left ); stem->max_edge.pix = stem->min_edge.pix + width_pix; } } - - -/************************************************************************ - * - * - * t1_hint_point - * - * - * Grid-fit a coordinate with regards to a given stem hints table - * - * - * table :: the source stem hints table - * coord :: original coordinate, expressed in font units - * scale :: the 16.16 scale used to convert font units into - * 26.6 pixels - * - * - * the hinted/scaled value in 26.6 pixels - * - * - * For now, all stems are hinted independently from each other. - * It might be necessary, for better performance, to introduce - * the notion of "controlled" hints describing things like - * counter-stems, stem3 as well as overlapping stems control. - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* t1_hint_point */ + /* */ + /* */ + /* Grid-fit a coordinate with regards to a given stem hints table. */ + /* */ + /* */ + /* table :: The source stem hints table. */ + /* coord :: The original coordinate, expressed in font units. */ + /* scale :: The 16.16 scale used to convert font units into */ + /* 26.6 pixels. */ + /* */ + /* */ + /* The hinted/scaled value in 26.6 pixels. */ + /* */ + /* */ + /* For now, all stems are hinted independently from each other. It */ + /* might be necessary, for better performance, to introduce the */ + /* notion of `controlled' hints describing things like counter-stems, */ + /* stem3 as well as overlapping stems control. */ + /* */ static FT_Pos t1_hint_point( T1_Stem_Table* table, FT_Pos coord, @@ -1163,9 +1193,10 @@ T1_Edge* max; FT_Pos delta; + /* only hint when there is at least one stem defined */ - if (num_active <= 0) - return SCALE(coord); + if ( num_active <= 0 ) + return SCALE( coord ); /* scan the stem table to determine placement of coordinate */ /* relative to the list of sorted and stems */ @@ -1173,14 +1204,16 @@ { cur = table->stems + table->sort[n]; - /* is it on the left of the current edge ? */ + /* is it on the left of the current edge? */ delta = cur->min_edge.orus - coord; - if ( delta == 0 ) return cur->min_edge.pix; + if ( delta == 0 ) + return cur->min_edge.pix; - if (delta > 0) + if ( delta > 0 ) { /* if this is the left of the first edge, simply shift */ - if (!prev) return cur->min_edge.pix - SCALE(delta); + if ( !prev ) + return cur->min_edge.pix - SCALE( delta ); /* otherwise, interpolate between the maximum of the */ /* previous stem, and the minimum of the current one */ @@ -1189,11 +1222,12 @@ goto Interpolate; } - /* is it within the current edge ? */ + /* is it within the current edge? */ delta = cur->max_edge.orus - coord; - if ( delta == 0 ) return cur->max_edge.pix; + if ( delta == 0 ) + return cur->max_edge.pix; - if (delta > 0) + if ( delta > 0 ) { /* interpolate within the stem */ min = &cur->min_edge; @@ -1204,38 +1238,35 @@ /* apparently, this coordinate is on the right of the last stem */ delta = coord - cur->max_edge.orus; - return cur->max_edge.pix + SCALE(delta); + return cur->max_edge.pix + SCALE( delta ); Interpolate: return min->pix + - FT_MulDiv( coord - min->orus, - max->pix - min->pix, - max->orus - min->orus ); + FT_MulDiv( coord - min->orus, + max->pix - min->pix, + max->orus - min->orus ); } - - - - #if 1 -/************************************************************************ - * - * - * T1_Hint_Points - * - * - * this function grid-fits several points in a given Type 1 builder - * at once. - * - * - * builder :: handle to target Type 1 builder - * first :: first point to hint in builder's current outline - * last :: last point to hint in builder's current outline - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* T1_Hint_Points */ + /* */ + /* */ + /* this function grid-fits several points in a given Type 1 builder */ + /* at once. */ + /* */ + /* */ + /* builder :: A handle to target Type 1 builder. */ + /* */ + /* first :: The first point to hint in the builder's current */ + /* outline. */ + /* */ + /* last :: The last point to hint in the builder's current outline. */ + /* */ LOCAL_FUNC void T1_Hint_Points( T1_Builder* builder ) { @@ -1253,6 +1284,7 @@ FT_Vector* cur = builder->current.points + first; FT_Vector* limit = cur + last - first + 1; + /* first of all, sort the active stem hints */ t1_sort_hints( hori_stems ); t1_sort_hints( vert_stems ); @@ -1267,21 +1299,19 @@ } -/************************************************************************ - * - * - * T1_Hint_Stems - * - * - * This function is used to compute the location of each stem hint - * between the first and second passes of the glyph loader on the - * charstring. - * - * - * builder :: handle to target builder - * - ************************************************************************/ - + /*************************************************************************/ + /* */ + /* */ + /* T1_Hint_Stems */ + /* */ + /* */ + /* This function is used to compute the location of each stem hint */ + /* between the first and second passes of the glyph loader on the */ + /* charstring. */ + /* */ + /* */ + /* builder :: A handle to the target builder. */ + /* */ LOCAL_FUNC void T1_Hint_Stems( T1_Builder* builder ) { @@ -1292,6 +1322,7 @@ FT_Fixed scale_x = size->root.metrics.x_scale; FT_Fixed scale_y = size->root.metrics.y_scale; + t1_hint_horizontal_stems( &hints->hori_stems, builder->size->hints, priv->blue_shift, @@ -1302,4 +1333,7 @@ scale_x ); } -#endif +#endif /* 1 */ + + +/* END */