From a519b3b7a34a75fae18e4fb2acd054bbeb80104a Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Mon, 29 May 2000 20:46:12 +0000 Subject: [PATCH] Formatting, fixing descriptions. --- include/freetype/freetype.h | 22 ++-- src/base/ftcalc.c | 197 +++++++++++++++++++----------------- 2 files changed, 117 insertions(+), 102 deletions(-) diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index 470083031..ca99034c0 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -458,9 +458,9 @@ /* glyph from the font. Thus, bbox.yMax can */ /* be seen as the `maximal ascender', */ /* bbox.yMin as the `minimal descender', and */ - /* the maximum glyph width is given by */ + /* the maximal glyph width is given by */ /* `bbox.xMax-bbox.xMin' (not to be confused */ - /* with the maximum _advance_width_). Only */ + /* with the maximal _advance_width_). Only */ /* relevant for scalable formats. */ /* */ /* units_per_EM :: The number of font units per EM square for */ @@ -496,13 +496,13 @@ /* `external leading'. Only relevant for */ /* scalable formats. */ /* */ - /* max_advance_width :: The maximum advance width, in font units, */ + /* max_advance_width :: The maximal advance width, in font units, */ /* for all glyphs in this face. This can be */ /* used to make word wrapping computations */ /* faster. Only relevant for scalable */ /* formats. */ /* */ - /* max_advance_height :: The maximum advance height, in font units, */ + /* max_advance_height :: The maximal advance height, in font units, */ /* for all glyphs in this face. This is only */ /* relevant for vertical layouts, and should */ /* be set to the `height' for fonts that do */ @@ -536,14 +536,14 @@ /* */ /* sizes_list :: The list of child sizes for this face. */ /* */ - /* max_points :: The maximum number of points used to store */ + /* max_points :: The maximal number of points used to store */ /* the vectorial outline of any glyph in this */ /* face. If this value cannot be known in */ /* advance, or if the face isn't scalable, */ /* this should be set to 0. Only relevant for */ /* scalable formats. */ /* */ - /* max_contours :: The maximum number of contours used to */ + /* max_contours :: The maximal number of contours used to */ /* store the vectorial outline of any glyph in */ /* this face. If this value cannot be known */ /* in advance, or if the face isn't scalable, */ @@ -1730,7 +1730,7 @@ /* */ /* */ /* A very simple function used to perform the computation `(A*B)/C' */ - /* with maximum accuracy (it uses a 64-bit intermediate integer */ + /* with maximal accuracy (it uses a 64-bit intermediate integer */ /* whenever necessary). */ /* */ /* This function isn't necessarily as fast as some processor specific */ @@ -1758,7 +1758,7 @@ /* */ /* */ /* A very simple function used to perform the computation */ - /* `(A*B)/0x10000' with maximum accuracy. Most of the time, this is */ + /* `(A*B)/0x10000' with maximal accuracy. Most of the time, this is */ /* used to multiply a given value by a 16.16 fixed float factor. */ /* */ /* */ @@ -1791,7 +1791,7 @@ /* */ /* */ /* A very simple function used to perform the computation */ - /* `(A*0x10000)/B' with maximum accuracy. Most of the time, this is */ + /* `(A*0x10000)/B' with maximal accuracy. Most of the time, this is */ /* used to divide a given value by a 16.16 fixed float factor. */ /* */ /* */ @@ -1921,9 +1921,9 @@ /* outline will NOT necessarily be FREED when */ /* destroying the library, by FT_Done_FreeType(). */ /* */ - /* numPoints :: The maximum number of points within the outline. */ + /* numPoints :: The maximal number of points within the outline. */ /* */ - /* numContours :: The maximum number of contours within the outline. */ + /* numContours :: The maximal number of contours within the outline. */ /* */ /* */ /* outline :: A handle to the new outline. NULL in case of */ diff --git a/src/base/ftcalc.c b/src/base/ftcalc.c index 33b96651c..ddc694606 100644 --- a/src/base/ftcalc.c +++ b/src/base/ftcalc.c @@ -30,6 +30,7 @@ /* */ /*************************************************************************/ + #include #include #include /* for ABS() */ @@ -53,7 +54,9 @@ 536870912, 759250125, 1073741824, 1518500250, 2147483647 }; + #else + /*************************************************************************/ /* */ /* */ @@ -69,13 +72,13 @@ /* */ /* The result of `sqrt(x)'. */ /* */ - FT_EXPORT_FUNC(FT_Int32) FT_Sqrt32( FT_Int32 x ) + FT_EXPORT_FUNC( FT_Int32 ) FT_Sqrt32( FT_Int32 x ) { FT_ULong val, root, newroot, mask; root = 0; - mask = 0x40000000; + mask = 0x40000000L; val = (FT_ULong)x; do @@ -94,10 +97,11 @@ return root; } + #endif /* OLD_CALCS */ -#ifdef LONG64 +#ifdef LONG64 /*************************************************************************/ /* */ @@ -106,7 +110,7 @@ /* */ /* */ /* A very simple function used to perform the computation `(a*b)/c' */ - /* with maximum accuracy (it uses a 64-bit intermediate integer */ + /* with maximal accuracy (it uses a 64-bit intermediate integer */ /* whenever necessary). */ /* */ /* This function isn't necessarily as fast as some processor specific */ @@ -119,12 +123,12 @@ /* */ /* */ /* The result of `(a*b)/c'. This function never traps when trying to */ - /* divide by zero, it simply returns `MaxInt' or `MinInt' depending */ + /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ /* on the signs of `a' and `b'. */ /* */ - FT_EXPORT_FUNC(FT_Long) FT_MulDiv( FT_Long a, - FT_Long b, - FT_Long c ) + FT_EXPORT_FUNC( FT_Long ) FT_MulDiv( FT_Long a, + FT_Long b, + FT_Long c ) { FT_Int s; @@ -145,7 +149,7 @@ /* */ /* */ /* A very simple function used to perform the computation */ - /* `(a*b)/0x10000' with maximum accuracy. Most of the time this is */ + /* `(a*b)/0x10000' with maximal accuracy. Most of the time this is */ /* used to multiply a given value by a 16.16 fixed float factor. */ /* */ /* */ @@ -167,8 +171,8 @@ /* _second_ argument of this function; this can make a great */ /* difference. */ /* */ - FT_EXPORT_FUNC(FT_Long) FT_MulFix( FT_Long a, - FT_Long b ) + FT_EXPORT_FUNC( FT_Long ) FT_MulFix( FT_Long a, + FT_Long b ) { FT_Int s; @@ -188,7 +192,7 @@ /* */ /* */ /* A very simple function used to perform the computation */ - /* `(a*0x10000)/b' with maximum accuracy. Most of the time, this is */ + /* `(a*0x10000)/b' with maximal accuracy. Most of the time, this is */ /* used to divide a given value by a 16.16 fixed float factor. */ /* */ /* */ @@ -204,8 +208,8 @@ /* 32 bits, then the division is computed directly. Otherwise, we */ /* use a specialized version of the old FT_MulDiv64(). */ /* */ - FT_EXPORT_FUNC(FT_Long) FT_DivFix( FT_Long a, - FT_Long b ) + FT_EXPORT_FUNC( FT_Long ) FT_DivFix( FT_Long a, + FT_Long b ) { FT_Int32 s; FT_Word32 q; @@ -216,8 +220,7 @@ if ( b == 0 ) /* check for divide by 0 */ - q = 0x7FFFFFFF; - + q = 0x7FFFFFFFL; else /* compute result directly */ q = ((FT_Int64)a << 16) / b; @@ -227,41 +230,45 @@ #ifdef FT_CONFIG_OPTION_OLD_CALCS + + /* a helper function for FT_Sqrt64() */ + + static + int ft_order64( FT_Int64 z ) + { + int j = 0; + + + while ( z ) + { + z = (unsigned INT64)z >> 1; + j++; + } + return j - 1; + } + + /*************************************************************************/ /* */ /* */ /* FT_Sqrt64 */ /* */ /* */ - /* Computes the square root of a 64-bits value ! Yeah, that sounds */ - /* stupid, but it's needed to obtain maximum accuracy in the */ - /* TrueType bytecode interpreter.. */ + /* Computes the square root of a 64-bit value. That sounds stupid, */ + /* but it is needed to obtain maximal accuracy in the TrueType */ + /* bytecode interpreter. */ /* */ /* */ - /* l :: 64-bits integer */ + /* l :: 64-bit integer */ /* */ /* */ /* The 32-bit square-root. */ /* */ - - static - int ft_order64( FT_Int64 z ) - { - int j = 0; - - while ( z ) - { - z = (unsigned INT64)z >> 1; - j++; - } - return j - 1; - } - - - FT_EXPORT_FUNC(FT_Int32) FT_Sqrt64( FT_Int64 l ) + FT_EXPORT_FUNC( FT_Int32 ) FT_Sqrt64( FT_Int64 l ) { FT_Int64 r, s; + if ( l <= 0 ) return 0; if ( l == 1 ) return 1; @@ -276,7 +283,8 @@ return r; } -#endif + +#endif /* FT_CONFIG_OPTION_OLD_CALCS */ #else /* LONG64 */ @@ -289,7 +297,7 @@ /* */ /* */ /* A very simple function used to perform the computation `(a*b)/c' */ - /* with maximum accuracy (it uses a 64-bit intermediate integer */ + /* with maximal accuracy (it uses a 64-bit intermediate integer */ /* whenever necessary). */ /* */ /* This function isn't necessarily as fast as some processor specific */ @@ -302,7 +310,7 @@ /* */ /* */ /* The result of `(a*b)/c'. This function never traps when trying to */ - /* divide by zero, it simply returns `MaxInt' or `MinInt' depending */ + /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ /* on the signs of `a' and `b'. */ /* */ /* */ @@ -322,9 +330,9 @@ /* */ /* and 2*0x157F0 = 176096. */ /* */ - FT_EXPORT_FUNC(FT_Long) FT_MulDiv( FT_Long a, - FT_Long b, - FT_Long c ) + FT_EXPORT_FUNC( FT_Long ) FT_MulDiv( FT_Long a, + FT_Long b, + FT_Long c ) { long s; @@ -363,7 +371,7 @@ /* */ /* */ /* A very simple function used to perform the computation */ - /* `(a*b)/0x10000' with maximum accuracy. Most of the time, this is */ + /* `(a*b)/0x10000' with maximal accuracy. Most of the time, this is */ /* used to multiply a given value by a 16.16 fixed float factor. */ /* */ /* */ @@ -387,12 +395,13 @@ /* idea is to use bounds like 2048 and 1048576 (=floor((2^31-1)/2048) */ /* for `a' and `b', respectively. */ /* */ - FT_EXPORT_FUNC(FT_Long) FT_MulFix( FT_Long a, - FT_Long b ) + FT_EXPORT_FUNC( FT_Long ) FT_MulFix( FT_Long a, + FT_Long b ) { FT_Long s; FT_ULong ua, ub; + if ( a == 0 || b == 0x10000L ) return a; @@ -425,8 +434,8 @@ /* */ /* */ /* A very simple function used to perform the computation */ - /* `(a*0x10000)/b' with maximum accuracy. Most of the time, this is */ - /* used to divide a given value by a 16.16 fixed float factor. */ + /* `(a*0x10000)/b' with maximal accuracy. Most of the time, this is */ + /* used to divide a given value by a 16.16 fixed float factor. */ /* */ /* */ /* a :: The first multiplier. */ @@ -441,8 +450,8 @@ /* 32 bits, then the division is computed directly. Otherwise, we */ /* use a specialized version of the old FT_MulDiv64(). */ /* */ - FT_EXPORT_FUNC(FT_Long) FT_DivFix( FT_Long a, - FT_Long b ) + FT_EXPORT_FUNC( FT_Long ) FT_DivFix( FT_Long a, + FT_Long b ) { FT_Int32 s; FT_Word32 q; @@ -453,8 +462,7 @@ if ( b == 0 ) /* check for divide by 0 */ - q = 0x7FFFFFFF; - + q = 0x7FFFFFFFL; else if ( (a >> 16) == 0 ) { /* compute result directly */ @@ -502,12 +510,13 @@ /* */ /* Will be wrapped by the ADD_64() macro. */ /* */ - FT_EXPORT_FUNC(void) FT_Add64( FT_Int64* x, - FT_Int64* y, - FT_Int64* z ) + FT_EXPORT_FUNC( void ) FT_Add64( FT_Int64* x, + FT_Int64* y, + FT_Int64* z ) { register FT_Word32 lo, hi; + lo = x->lo + y->lo; hi = x->hi + y->hi + ( lo < x->lo ); @@ -522,7 +531,7 @@ /* FT_MulTo64 */ /* */ /* */ - /* Multiplies two Int32 integers. Returns a Int64 integer. */ + /* Multiplies two Int32 integers. Returns an Int64 integer. */ /* */ /* */ /* x :: The first multiplier. */ @@ -534,9 +543,9 @@ /* */ /* Will be wrapped by the MUL_64() macro. */ /* */ - FT_EXPORT_FUNC(void) FT_MulTo64( FT_Int32 x, - FT_Int32 y, - FT_Int64* z ) + FT_EXPORT_FUNC( void ) FT_MulTo64( FT_Int32 x, + FT_Int32 y, + FT_Int64* z ) { FT_Int32 s; @@ -599,8 +608,8 @@ /* */ /* Will be wrapped by the DIV_64() macro. */ /* */ - FT_EXPORT_FUNC(FT_Int32) FT_Div64by32( FT_Int64* x, - FT_Int32 y ) + FT_EXPORT_FUNC( FT_Int32 ) FT_Div64by32( FT_Int64* x, + FT_Int32 y ) { FT_Int32 s; FT_Word32 q, r, i, lo; @@ -649,8 +658,13 @@ #ifdef FT_CONFIG_OPTION_OLD_CALCS + + /* two helper functions for FT_Sqrt64() */ + static - void FT_Sub64( FT_Int64* x, FT_Int64* y, FT_Int64* z ) + void FT_Sub64( FT_Int64* x, + FT_Int64* y, + FT_Int64* z ) { register FT_Word32 lo, hi; @@ -662,53 +676,54 @@ z->hi = hi; } + static + int ft_order64( FT_Int64* z ) + { + FT_Word32 i; + int j; + + + i = z->lo; + j = 0; + if ( z->hi ) + { + i = z->hi; + j = 32; + } + + while ( i > 0 ) + { + i >>= 1; + j++; + } + return j - 1; + } + /*************************************************************************/ /* */ /* */ /* FT_Sqrt64 */ /* */ /* */ - /* Computes the square root of a 64-bits value ! Yeah, that sounds */ - /* stupid, but it's needed to obtain maximum accuracy in the */ - /* TrueType bytecode interpreter.. */ + /* Computes the square root of a 64-bits value. That sounds stupid, */ + /* but it is needed to obtain maximal accuracy in the TrueType */ + /* bytecode interpreter. */ /* */ /* */ - /* z :: pointer to 64-bits integer */ + /* z :: A pointer to a 64-bit integer. */ /* */ /* */ /* The 32-bit square-root. */ /* */ - - static - int ft_order64( FT_Int64* z ) - { - FT_Word32 i; - int j; - - i = z->lo; - j = 0; - if ( z->hi ) - { - i = z->hi; - j = 32; - } - - while ( i > 0 ) - { - i >>= 1; - j++; - } - return j-1; - } - - FT_EXPORT_FUNC(FT_Int32) FT_Sqrt64( FT_Int64* l ) + FT_EXPORT_FUNC( FT_Int32 ) FT_Sqrt64( FT_Int64* l ) { FT_Int64 l2; FT_Int32 r, s; - if ( (FT_Int32)l->hi < 0 || - (l->hi == 0 && l->lo == 0) ) return 0; + if ( (FT_Int32)l->hi < 0 || + (l->hi == 0 && l->lo == 0) ) + return 0; s = ft_order64( l ); if ( s == 0 ) return 1;