ref: a519b3b7a34a75fae18e4fb2acd054bbeb80104a
parent: b1677a87caccc71b462dbdc6895aecea0d7e2e04
author: Werner Lemberg <[email protected]>
date: Mon May 29 16:46:12 EDT 2000
Formatting, fixing descriptions.
--- 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,7 +536,7 @@
/* */
/* 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, */
@@ -543,7 +543,7 @@
/* 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 @@
/* */
/* <Description> */
/* 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 @@
/* */
/* <Description> */
/* 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. */
/* */
/* <Input> */
@@ -1791,7 +1791,7 @@
/* */
/* <Description> */
/* 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. */
/* */
/* <Input> */
@@ -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. */
/* */
/* <Output> */
/* outline :: A handle to the new outline. NULL in case of */
--- a/src/base/ftcalc.c
+++ b/src/base/ftcalc.c
@@ -30,6 +30,7 @@
/* */
/*************************************************************************/
+
#include <freetype/internal/ftcalc.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftobjs.h> /* for ABS() */
@@ -53,7 +54,9 @@
536870912, 759250125, 1073741824, 1518500250,
2147483647
};
+
#else
+
/*************************************************************************/
/* */
/* <Function> */
@@ -69,13 +72,13 @@
/* <Return> */
/* 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,11 +97,12 @@
return root;
}
+
#endif /* OLD_CALCS */
+
#ifdef LONG64
-
/*************************************************************************/
/* */
/* <Function> */
@@ -106,7 +110,7 @@
/* */
/* <Description> */
/* 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 @@
/* */
/* <Return> */
/* 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 @@
/* */
/* <Description> */
/* 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. */
/* */
/* <Input> */
@@ -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 @@
/* */
/* <Description> */
/* 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. */
/* */
/* <Input> */
@@ -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,6 +230,24 @@
#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;
+ }
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -233,35 +254,21 @@
/* FT_Sqrt64 */
/* */
/* <Description> */
- /* 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. */
/* */
/* <Input> */
- /* l :: 64-bits integer */
+ /* l :: 64-bit integer */
/* */
/* <Return> */
/* 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,9 +283,10 @@
return r;
}
-#endif
+#endif /* FT_CONFIG_OPTION_OLD_CALCS */
+
#else /* LONG64 */
@@ -289,7 +297,7 @@
/* */
/* <Description> */
/* 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 @@
/* */
/* <Return> */
/* 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'. */
/* */
/* <Note> */
@@ -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 @@
/* */
/* <Description> */
/* 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. */
/* */
/* <Input> */
@@ -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 @@
/* */
/* <Description> */
/* 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. */
/* */
/* <Input> */
/* 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 @@
/* <Note> */
/* 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 */
/* */
/* <Description> */
- /* Multiplies two Int32 integers. Returns a Int64 integer. */
+ /* Multiplies two Int32 integers. Returns an Int64 integer. */
/* */
/* <Input> */
/* x :: The first multiplier. */
@@ -534,9 +543,9 @@
/* <Note> */
/* 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 @@
/* <Note> */
/* 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,6 +676,29 @@
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;
+ }
+
/*************************************************************************/
/* */
/* <Function> */
@@ -668,47 +705,25 @@
/* FT_Sqrt64 */
/* */
/* <Description> */
- /* 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. */
/* */
/* <Input> */
- /* z :: pointer to 64-bits integer */
+ /* z :: A pointer to a 64-bit integer. */
/* */
/* <Return> */
/* 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;