ReactOS 0.4.16-dev-2354-g16de117
ftcalc.c File Reference
Include dependency graph for ftcalc.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FT_Int64_
 

Macros

#define FT_COMPONENT   calc
 
#define FT_MOVE_SIGN(x, x_unsigned, s)
 

Typedefs

typedef struct FT_Int64_ FT_Int64
 

Functions

 FT_RoundFix (FT_Fixed a)
 
 FT_CeilFix (FT_Fixed a)
 
 FT_FloorFix (FT_Fixed a)
 
 FT_MSB (FT_UInt32 z)
 
 FT_Hypot (FT_Fixed x, FT_Fixed y)
 
static void ft_multo64 (FT_UInt32 x, FT_UInt32 y, FT_Int64 *z)
 
static FT_UInt32 ft_div64by32 (FT_UInt32 hi, FT_UInt32 lo, FT_UInt32 y)
 
static void FT_Add64 (FT_Int64 *x, FT_Int64 *y, FT_Int64 *z)
 
 FT_MulDiv (FT_Long a_, FT_Long b_, FT_Long c_)
 
 FT_MulDiv_No_Round (FT_Long a_, FT_Long b_, FT_Long c_)
 
 FT_MulFix (FT_Long a_, FT_Long b_)
 
 FT_DivFix (FT_Long a_, FT_Long b_)
 
 FT_Matrix_Multiply (const FT_Matrix *a, FT_Matrix *b)
 
 FT_Matrix_Invert (FT_Matrix *matrix)
 
 FT_Matrix_Multiply_Scaled (const FT_Matrix *a, FT_Matrix *b, FT_Long scaling)
 
 FT_Matrix_Check (const FT_Matrix *matrix)
 
 FT_Vector_Transform_Scaled (FT_Vector *vector, const FT_Matrix *matrix, FT_Long scaling)
 
 FT_Vector_NormLen (FT_Vector *vector)
 
 ft_corner_orientation (FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
 
 ft_corner_is_flat (FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   calc

Definition at line 67 of file ftcalc.c.

◆ FT_MOVE_SIGN

#define FT_MOVE_SIGN (   x,
  x_unsigned,
  s 
)
Value:
FT_BEGIN_STMNT \
if ( x < 0 ) \
{ \
x_unsigned = 0U - (x_unsigned); \
s = -s; \
} \
#define U(x)
Definition: wordpad.c:45
#define FT_END_STMNT
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble s
Definition: gl.h:2039

Definition at line 72 of file ftcalc.c.

Typedef Documentation

◆ FT_Int64

Function Documentation

◆ FT_Add64()

static void FT_Add64 ( FT_Int64 x,
FT_Int64 y,
FT_Int64 z 
)
static

Definition at line 350 of file ftcalc.c.

353 {
354 FT_UInt32 lo, hi;
355
356
357 lo = x->lo + y->lo;
358 hi = x->hi + y->hi + ( lo < x->lo );
359
360 z->lo = lo;
361 z->hi = hi;
362 }
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874

Referenced by FT_DivFix(), and FT_MulDiv().

◆ FT_CeilFix()

FT_CeilFix ( FT_Fixed  a)

Definition at line 96 of file ftcalc.c.

97 {
98 return ( ADD_LONG( a, 0xFFFFL ) ) & ~0xFFFFL;
99 }
#define ADD_LONG(a, b)
Definition: ftcalc.h:472
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ ft_corner_is_flat()

ft_corner_is_flat ( FT_Pos  in_x,
FT_Pos  in_y,
FT_Pos  out_x,
FT_Pos  out_y 
)

Definition at line 1046 of file ftcalc.c.

1050 {
1051 FT_Pos ax = in_x + out_x;
1052 FT_Pos ay = in_y + out_y;
1053
1054 FT_Pos d_in, d_out, d_hypot;
1055
1056
1057 /* The idea of this function is to compare the length of the */
1058 /* hypotenuse with the `in' and `out' length. The `corner' */
1059 /* represented by `in' and `out' is flat if the hypotenuse's */
1060 /* length isn't too large. */
1061 /* */
1062 /* This approach has the advantage that the angle between */
1063 /* `in' and `out' is not checked. In case one of the two */
1064 /* vectors is `dominant', this is, much larger than the */
1065 /* other vector, we thus always have a flat corner. */
1066 /* */
1067 /* hypotenuse */
1068 /* x---------------------------x */
1069 /* \ / */
1070 /* \ / */
1071 /* in \ / out */
1072 /* \ / */
1073 /* o */
1074 /* Point */
1075
1076 d_in = FT_HYPOT( in_x, in_y );
1077 d_out = FT_HYPOT( out_x, out_y );
1078 d_hypot = FT_HYPOT( ax, ay );
1079
1080 /* now do a simple length comparison: */
1081 /* */
1082 /* d_in + d_out < 17/16 d_hypot */
1083
1084 return ( d_in + d_out - d_hypot ) < ( d_hypot >> 4 );
1085 }
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:57
#define FT_HYPOT(x, y)
Definition: ftobjs.h:80
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx testl eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx shrl ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 psrlq mm1 psrlq mm5 paddd mm0 paddd mm4 psrad mm0 psrad mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx andl ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 psrlq mm1 paddd mm0 psrad mm0 packssdw mm0 movd eax movw ax
Definition: synth_sse3d.h:180

Referenced by af_glyph_hints_reload().

◆ ft_corner_orientation()

ft_corner_orientation ( FT_Pos  in_x,
FT_Pos  in_y,
FT_Pos  out_x,
FT_Pos  out_y 
)

Definition at line 980 of file ftcalc.c.

984 {
985 /* we silently ignore overflow errors since such large values */
986 /* lead to even more (harmless) rendering errors later on */
987
988#ifdef FT_LONG64
989
990 FT_Int64 delta = SUB_INT64( MUL_INT64( in_x, out_y ),
991 MUL_INT64( in_y, out_x ) );
992
993
994 return ( delta > 0 ) - ( delta < 0 );
995
996#else
997
999
1000
1001 if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L &&
1002 ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L )
1003 {
1004 FT_Long z1 = MUL_LONG( in_x, out_y );
1005 FT_Long z2 = MUL_LONG( in_y, out_x );
1006
1007
1008 if ( z1 > z2 )
1009 result = +1;
1010 else if ( z1 < z2 )
1011 result = -1;
1012 else
1013 result = 0;
1014 }
1015 else /* products might overflow 32 bits */
1016 {
1017 FT_Int64 z1, z2;
1018
1019
1020 /* XXX: this function does not allow 64-bit arguments */
1021 ft_multo64( (FT_UInt32)in_x, (FT_UInt32)out_y, &z1 );
1022 ft_multo64( (FT_UInt32)in_y, (FT_UInt32)out_x, &z2 );
1023
1024 if ( z1.hi > z2.hi )
1025 result = +1;
1026 else if ( z1.hi < z2.hi )
1027 result = -1;
1028 else if ( z1.lo > z2.lo )
1029 result = +1;
1030 else if ( z1.lo < z2.lo )
1031 result = -1;
1032 else
1033 result = 0;
1034 }
1035
1036 /* XXX: only the sign of return value, +1/0/-1 must be used */
1037 return result;
1038
1039#endif
1040 }
static void ft_multo64(FT_UInt32 x, FT_UInt32 y, FT_Int64 *z)
Definition: ftcalc.c:279
#define MUL_LONG(a, b)
Definition: ftcalc.h:476
#define FT_ABS(a)
Definition: ftobjs.h:73
signed long FT_Long
Definition: fttypes.h:242
signed int FT_Int
Definition: fttypes.h:220
GLuint64EXT * result
Definition: glext.h:11304
static double float double int float z1
Definition: server.c:81
static double float double int float double float z2
Definition: server.c:81

◆ ft_div64by32()

static FT_UInt32 ft_div64by32 ( FT_UInt32  hi,
FT_UInt32  lo,
FT_UInt32  y 
)
static

Definition at line 311 of file ftcalc.c.

314 {
315 FT_UInt32 r, q;
316 FT_Int i;
317
318
319 if ( hi >= y )
320 return (FT_UInt32)0x7FFFFFFFL;
321
322 /* We shift as many bits as we can into the high register, perform */
323 /* 32-bit division with modulo there, then work through the remaining */
324 /* bits with long division. This optimization is especially noticeable */
325 /* for smaller dividends that barely use the high register. */
326
327 i = 31 - FT_MSB( hi );
328 r = ( hi << i ) | ( lo >> ( 32 - i ) ); lo <<= i; /* left 64-bit shift */
329 q = r / y;
330 r -= q * y; /* remainder */
331
332 i = 32 - i; /* bits remaining in low register */
333 do
334 {
335 q <<= 1;
336 r = ( r << 1 ) | ( lo >> 31 ); lo <<= 1;
337
338 if ( r >= y )
339 {
340 r -= y;
341 q |= 1;
342 }
343 } while ( --i );
344
345 return q;
346 }
FT_MSB(FT_UInt32 z)
Definition: ftcalc.c:113
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by FT_DivFix(), FT_MulDiv(), and FT_MulDiv_No_Round().

◆ FT_DivFix()

FT_DivFix ( FT_Long  a_,
FT_Long  b_ 
)

Definition at line 607 of file ftcalc.c.

609 {
610 FT_Int s = 1;
611 FT_UInt32 a, b, q;
612 FT_Long q_;
613
614
615 /* XXX: this function does not allow 64-bit arguments */
616
617 a = (FT_UInt32)a_;
618 b = (FT_UInt32)b_;
619
620 FT_MOVE_SIGN( a_, a, s );
621 FT_MOVE_SIGN( b_, b, s );
622
623 if ( b == 0 )
624 {
625 /* check for division by 0 */
626 q = 0x7FFFFFFFUL;
627 }
628 else if ( a <= 65535UL - ( b >> 17 ) )
629 {
630 /* compute result directly */
631 q = ( ( a << 16 ) + ( b >> 1 ) ) / b;
632 }
633 else
634 {
635 /* we need more bits; we have to do it by hand */
636 FT_Int64 temp, temp2;
637
638
639 temp.hi = a >> 16;
640 temp.lo = a << 16;
641 temp2.hi = 0;
642 temp2.lo = b >> 1;
643
644 FT_Add64( &temp, &temp2, &temp );
645 q = ft_div64by32( temp.hi, temp.lo, b );
646 }
647
648 q_ = (FT_Long)q;
649
650 return s < 0 ? NEG_LONG( q_ ) : q_;
651 }
static void FT_Add64(FT_Int64 *x, FT_Int64 *y, FT_Int64 *z)
Definition: ftcalc.c:350
#define FT_MOVE_SIGN(x, x_unsigned, s)
Definition: ftcalc.c:72
static FT_UInt32 ft_div64by32(FT_UInt32 hi, FT_UInt32 lo, FT_UInt32 y)
Definition: ftcalc.c:311
#define NEG_LONG(a)
Definition: ftcalc.h:478
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
static calc_node_t temp
Definition: rpn_ieee.c:38
FT_UInt32 lo
Definition: ftcalc.c:52
FT_UInt32 hi
Definition: ftcalc.c:53

Referenced by af_glyph_hints_align_strong_points(), af_iup_interp(), af_latin_hints_compute_edges(), af_loader_compute_darkening(), af_loader_embolden_glyph_in_slot(), af_loader_load_glyph(), cf2_blues_init(), cf2_checkTransform(), cf2_computeDarkening(), cf2_font_setup(), cf2_getBlueMetrics(), cf2_glyphpath_computeIntersection(), cf2_hintmap_adjustHints(), cf2_interpT2CharString(), cff_blend_build_vector(), cff_face_init(), cff_parse_fixed_dynamic(), cff_parse_real(), cid_parse_font_matrix(), compute_glyph_metrics(), FT_Matrix_Check(), FT_Matrix_Invert(), FT_Request_Metrics(), FT_Select_Metrics(), FT_Stroker_ConicTo(), FT_Stroker_CubicTo(), ft_stroker_inside(), ft_stroker_outside(), FT_Tan(), mm_axis_unmap(), pfr_get_metrics(), PS_Conv_ToFixed(), psh_globals_new(), psh_glyph_find_strong_points(), psh_glyph_interpolate_other_points(), t1_decoder_parse_metrics(), t1_parse_font_matrix(), t42_parse_font_matrix(), and tt_size_reset().

◆ FT_FloorFix()

FT_FloorFix ( FT_Fixed  a)

Definition at line 105 of file ftcalc.c.

106 {
107 return a & ~0xFFFFL;
108 }

◆ FT_Hypot()

FT_Hypot ( FT_Fixed  x,
FT_Fixed  y 
)

Definition at line 154 of file ftcalc.c.

156 {
157 FT_Vector v;
158
159
160 v.x = x;
161 v.y = y;
162
163 return FT_Vector_Length( &v );
164 }
FT_Vector_Length(FT_Vector *vec)
Definition: fttrigon.c:417
const GLdouble * v
Definition: gl.h:2040

Referenced by TT_Process_Composite_Component().

◆ FT_Matrix_Check()

FT_Matrix_Check ( const FT_Matrix matrix)

Definition at line 750 of file ftcalc.c.

751 {
752 FT_Matrix m;
753 FT_Fixed val[4];
754 FT_Fixed nonzero_minval, maxval;
755 FT_Fixed temp1, temp2;
756 FT_UInt i;
757
758
759 if ( !matrix )
760 return 0;
761
762 val[0] = FT_ABS( matrix->xx );
763 val[1] = FT_ABS( matrix->xy );
764 val[2] = FT_ABS( matrix->yx );
765 val[3] = FT_ABS( matrix->yy );
766
767 /*
768 * To avoid overflow, we ensure that each value is not larger than
769 *
770 * int(sqrt(2^31 / 4)) = 23170 ;
771 *
772 * we also check that no value becomes zero if we have to scale.
773 */
774
775 maxval = 0;
776 nonzero_minval = FT_LONG_MAX;
777
778 for ( i = 0; i < 4; i++ )
779 {
780 if ( val[i] > maxval )
781 maxval = val[i];
782 if ( val[i] && val[i] < nonzero_minval )
783 nonzero_minval = val[i];
784 }
785
786 /* we only handle 32bit values */
787 if ( maxval > 0x7FFFFFFFL )
788 return 0;
789
790 if ( maxval > 23170 )
791 {
792 FT_Fixed scale = FT_DivFix( maxval, 23170 );
793
794
795 if ( !FT_DivFix( nonzero_minval, scale ) )
796 return 0; /* value range too large */
797
798 m.xx = FT_DivFix( matrix->xx, scale );
799 m.xy = FT_DivFix( matrix->xy, scale );
800 m.yx = FT_DivFix( matrix->yx, scale );
801 m.yy = FT_DivFix( matrix->yy, scale );
802 }
803 else
804 m = *matrix;
805
806 temp1 = FT_ABS( m.xx * m.yy - m.xy * m.yx );
807 temp2 = m.xx * m.xx + m.xy * m.xy + m.yx * m.yx + m.yy * m.yy;
808
809 if ( temp1 == 0 ||
810 temp2 / temp1 > 50 )
811 return 0;
812
813 return 1;
814 }
FT_DivFix(FT_Long a_, FT_Long b_)
Definition: ftcalc.c:607
#define FT_LONG_MAX
Definition: ftstdlib.h:67
signed long FT_Fixed
Definition: fttypes.h:287
unsigned int FT_UInt
Definition: fttypes.h:231
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:9032
GLuint GLenum matrix
Definition: glext.h:9407
GLuint GLfloat * val
Definition: glext.h:7180
const GLfloat * m
Definition: glext.h:10848

Referenced by cff_parse_font_matrix(), cid_parse_font_matrix(), t1_parse_font_matrix(), and t42_parse_font_matrix().

◆ FT_Matrix_Invert()

FT_Matrix_Invert ( FT_Matrix matrix)

Definition at line 688 of file ftcalc.c.

689 {
690 FT_Pos delta, xx, yy;
691
692
693 if ( !matrix )
694 return FT_THROW( Invalid_Argument );
695
696 /* compute discriminant */
697 delta = FT_MulFix( matrix->xx, matrix->yy ) -
698 FT_MulFix( matrix->xy, matrix->yx );
699
700 if ( !delta )
701 return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */
702
703 matrix->xy = -FT_DivFix( matrix->xy, delta );
704 matrix->yx = -FT_DivFix( matrix->yx, delta );
705
706 xx = matrix->xx;
707 yy = matrix->yy;
708
709 matrix->xx = FT_DivFix( yy, delta );
710 matrix->yy = FT_DivFix( xx, delta );
711
712 return FT_Err_Ok;
713 }
return FT_Err_Ok
Definition: ftbbox.c:526
FT_MulFix(FT_Long a_, FT_Long b_)
Definition: ftcalc.c:508
#define FT_THROW(e)
Definition: ftdebug.h:243
int xx
Definition: npserver.c:29

Referenced by af_loader_load_glyph().

◆ FT_Matrix_Multiply()

FT_Matrix_Multiply ( const FT_Matrix a,
FT_Matrix b 
)

Definition at line 660 of file ftcalc.c.

662 {
663 FT_Fixed xx, xy, yx, yy;
664
665
666 if ( !a || !b )
667 return;
668
669 xx = ADD_LONG( FT_MulFix( a->xx, b->xx ),
670 FT_MulFix( a->xy, b->yx ) );
671 xy = ADD_LONG( FT_MulFix( a->xx, b->xy ),
672 FT_MulFix( a->xy, b->yy ) );
673 yx = ADD_LONG( FT_MulFix( a->yx, b->xx ),
674 FT_MulFix( a->yy, b->yx ) );
675 yy = ADD_LONG( FT_MulFix( a->yx, b->xy ),
676 FT_MulFix( a->yy, b->yy ) );
677
678 b->xx = xx;
679 b->xy = xy;
680 b->yx = yx;
681 b->yy = yy;
682 }

Referenced by ftGdiGetGlyphOutline(), and IntExtTextOutW().

◆ FT_Matrix_Multiply_Scaled()

FT_Matrix_Multiply_Scaled ( const FT_Matrix a,
FT_Matrix b,
FT_Long  scaling 
)

Definition at line 719 of file ftcalc.c.

722 {
723 FT_Fixed xx, xy, yx, yy;
724
725 FT_Long val = 0x10000L * scaling;
726
727
728 if ( !a || !b )
729 return;
730
731 xx = ADD_LONG( FT_MulDiv( a->xx, b->xx, val ),
732 FT_MulDiv( a->xy, b->yx, val ) );
733 xy = ADD_LONG( FT_MulDiv( a->xx, b->xy, val ),
734 FT_MulDiv( a->xy, b->yy, val ) );
735 yx = ADD_LONG( FT_MulDiv( a->yx, b->xx, val ),
736 FT_MulDiv( a->yy, b->yx, val ) );
737 yy = ADD_LONG( FT_MulDiv( a->yx, b->xy, val ),
738 FT_MulDiv( a->yy, b->yy, val ) );
739
740 b->xx = xx;
741 b->xy = xy;
742 b->yx = yx;
743 b->yy = yy;
744 }
FT_MulDiv(FT_Long a_, FT_Long b_, FT_Long c_)
Definition: ftcalc.c:415

Referenced by cff_face_init().

◆ FT_MSB()

FT_MSB ( FT_UInt32  z)

Definition at line 113 of file ftcalc.c.

114 {
115 FT_Int shift = 0;
116
117
118 /* determine msb bit index in `shift' */
119 if ( z & 0xFFFF0000UL )
120 {
121 z >>= 16;
122 shift += 16;
123 }
124 if ( z & 0x0000FF00UL )
125 {
126 z >>= 8;
127 shift += 8;
128 }
129 if ( z & 0x000000F0UL )
130 {
131 z >>= 4;
132 shift += 4;
133 }
134 if ( z & 0x0000000CUL )
135 {
136 z >>= 2;
137 shift += 2;
138 }
139 if ( z & 0x00000002UL )
140 {
141 /* z >>= 1; */
142 shift += 1;
143 }
144
145 return shift;
146 }
#define shift
Definition: input.c:1755

Referenced by af_loader_compute_darkening(), cf2_computeDarkening(), cubic_peak(), ft_div64by32(), FT_Outline_Get_Orientation(), ft_trig_prenorm(), FT_Vector_NormLen(), and pfr_face_get_kerning().

◆ FT_MulDiv()

FT_MulDiv ( FT_Long  a_,
FT_Long  b_,
FT_Long  c_ 
)

Definition at line 415 of file ftcalc.c.

418 {
419 FT_Int s = 1;
420 FT_UInt32 a, b, c;
421
422
423 /* XXX: this function does not allow 64-bit arguments */
424
425 a = (FT_UInt32)a_;
426 b = (FT_UInt32)b_;
427 c = (FT_UInt32)c_;
428
429 FT_MOVE_SIGN( a_, a, s );
430 FT_MOVE_SIGN( b_, b, s );
431 FT_MOVE_SIGN( c_, c, s );
432
433 if ( c == 0 )
434 a = 0x7FFFFFFFUL;
435
436 else if ( a + b <= 129894UL - ( c >> 17 ) )
437 a = ( a * b + ( c >> 1 ) ) / c;
438
439 else
440 {
441 FT_Int64 temp, temp2;
442
443
444 ft_multo64( a, b, &temp );
445
446 temp2.hi = 0;
447 temp2.lo = c >> 1;
448
449 FT_Add64( &temp, &temp2, &temp );
450
451 /* last attempt to ditch long division */
452 a = ( temp.hi == 0 ) ? temp.lo / c
453 : ft_div64by32( temp.hi, temp.lo, c );
454 }
455
456 a_ = (FT_Long)a;
457
458 return s < 0 ? NEG_LONG( a_ ) : a_;
459 }
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80

Referenced by _bdf_parse_glyphs(), _ft_face_scale_advances(), af_latin_hint_edges(), af_latin_metrics_scale_dim(), af_loader_compute_darkening(), BBox_Conic_Check(), BDF_Face_Init(), cf2_blues_init(), cf2_computeDarkening(), cff_face_init(), cff_size_request(), cff_slot_load(), FNT_Face_Init(), FT_Get_Kerning(), FT_Load_Glyph(), FT_Matrix_Multiply_Scaled(), FT_Outline_EmboldenXY(), FT_Request_Metrics(), FT_Stroker_ConicTo(), FT_Stroker_CubicTo(), ft_stroker_inside(), ft_stroker_outside(), FT_Vector_Transform_Scaled(), IntRequestFontSize(), pcf_load_font(), pfr_get_kerning(), pfr_slot_load(), ps_hints_apply(), psh_glyph_interpolate_normal_points(), psh_glyph_interpolate_strong_points(), T1_Get_Track_Kerning(), T1_Set_MM_Design(), TT_Process_Simple_Glyph(), and tt_size_request().

◆ FT_MulDiv_No_Round()

FT_MulDiv_No_Round ( FT_Long  a_,
FT_Long  b_,
FT_Long  c_ 
)

Definition at line 463 of file ftcalc.c.

466 {
467 FT_Int s = 1;
468 FT_UInt32 a, b, c;
469
470
471 /* XXX: this function does not allow 64-bit arguments */
472
473 a = (FT_UInt32)a_;
474 b = (FT_UInt32)b_;
475 c = (FT_UInt32)c_;
476
477 FT_MOVE_SIGN( a_, a, s );
478 FT_MOVE_SIGN( b_, b, s );
479 FT_MOVE_SIGN( c_, c, s );
480
481 if ( c == 0 )
482 a = 0x7FFFFFFFUL;
483
484 else if ( a + b <= 131071UL )
485 a = a * b / c;
486
487 else
488 {
490
491
492 ft_multo64( a, b, &temp );
493
494 /* last attempt to ditch long division */
495 a = ( temp.hi == 0 ) ? temp.lo / c
496 : ft_div64by32( temp.hi, temp.lo, c );
497 }
498
499 a_ = (FT_Long)a;
500
501 return s < 0 ? NEG_LONG( a_ ) : a_;
502 }

◆ FT_MulFix()

FT_MulFix ( FT_Long  a_,
FT_Long  b_ 
)

Definition at line 508 of file ftcalc.c.

510 {
511#ifdef FT_MULFIX_ASSEMBLER
512
513 return FT_MULFIX_ASSEMBLER( a_, b_ );
514
515#elif 0
516
517 /*
518 * This code is nonportable. See comment below.
519 *
520 * However, on a platform where right-shift of a signed quantity fills
521 * the leftmost bits by copying the sign bit, it might be faster.
522 */
523
524 FT_Long sa, sb;
525 FT_UInt32 a, b;
526
527
528 /*
529 * This is a clever way of converting a signed number `a' into its
530 * absolute value (stored back into `a') and its sign. The sign is
531 * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a'
532 * was negative. (Similarly for `b' and `sb').
533 *
534 * Unfortunately, it doesn't work (at least not portably).
535 *
536 * It makes the assumption that right-shift on a negative signed value
537 * fills the leftmost bits by copying the sign bit. This is wrong.
538 * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206,
539 * the result of right-shift of a negative signed value is
540 * implementation-defined. At least one implementation fills the
541 * leftmost bits with 0s (i.e., it is exactly the same as an unsigned
542 * right shift). This means that when `a' is negative, `sa' ends up
543 * with the value 1 rather than -1. After that, everything else goes
544 * wrong.
545 */
546 sa = ( a_ >> ( sizeof ( a_ ) * 8 - 1 ) );
547 a = ( a_ ^ sa ) - sa;
548 sb = ( b_ >> ( sizeof ( b_ ) * 8 - 1 ) );
549 b = ( b_ ^ sb ) - sb;
550
551 a = (FT_UInt32)a_;
552 b = (FT_UInt32)b_;
553
554 if ( a + ( b >> 8 ) <= 8190UL )
555 a = ( a * b + 0x8000U ) >> 16;
556 else
557 {
558 FT_UInt32 al = a & 0xFFFFUL;
559
560
561 a = ( a >> 16 ) * b + al * ( b >> 16 ) +
562 ( ( al * ( b & 0xFFFFUL ) + 0x8000UL ) >> 16 );
563 }
564
565 sa ^= sb;
566 a = ( a ^ sa ) - sa;
567
568 return (FT_Long)a;
569
570#else /* 0 */
571
572 FT_Int s = 1;
573 FT_UInt32 a, b;
574
575
576 /* XXX: this function does not allow 64-bit arguments */
577
578 a = (FT_UInt32)a_;
579 b = (FT_UInt32)b_;
580
581 FT_MOVE_SIGN( a_, a, s );
582 FT_MOVE_SIGN( b_, b, s );
583
584 if ( a + ( b >> 8 ) <= 8190UL )
585 a = ( a * b + 0x8000UL ) >> 16;
586 else
587 {
588 FT_UInt32 al = a & 0xFFFFUL;
589
590
591 a = ( a >> 16 ) * b + al * ( b >> 16 ) +
592 ( ( al * ( b & 0xFFFFUL ) + 0x8000UL ) >> 16 );
593 }
594
595 a_ = (FT_Long)a;
596
597 return s < 0 ? NEG_LONG( a_ ) : a_;
598
599#endif /* 0 */
600
601 }
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
superblock * sb
Definition: btrfs.c:4261

Referenced by af_glyph_hints_align_strong_points(), af_glyph_hints_reload(), af_iup_interp(), af_latin_hints_compute_blue_edges(), af_latin_hints_compute_edges(), af_latin_metrics_scale_dim(), af_loader_compute_darkening(), af_loader_embolden_glyph_in_slot(), af_loader_load_glyph(), cf2_blues_init(), cf2_computeDarkening(), cf2_doBlend(), cf2_glyphpath_computeIntersection(), cf2_glyphpath_computeOffset(), cf2_glyphpath_hintPoint(), cf2_hint_init(), cf2_hintmap_insertHint(), cf2_hintmap_map(), cf2_interpT2CharString(), cff_blend_build_vector(), cff_slot_load(), cid_slot_load_glyph(), compute_glyph_metrics(), FillTM(), FT_Get_Kerning(), FT_GlyphSlot_Embolden(), FT_Matrix_Invert(), FT_Matrix_Multiply(), FT_Outline_EmboldenXY(), ft_recompute_scaled_metrics(), FT_Request_Metrics(), ft_stroke_border_arcto(), ft_stroker_outside(), FT_Vector_Transform(), load_truetype_glyph(), pfr_glyph_load_rec(), pfr_slot_load(), ps_hints_apply(), psh_blues_scale_zones(), psh_globals_scale_widths(), psh_glyph_interpolate_normal_points(), psh_glyph_interpolate_other_points(), psh_glyph_interpolate_strong_points(), psh_hint_align(), T1_Load_Glyph(), t1_set_mm_blend(), TT_Load_Glyph(), TT_Process_Composite_Component(), TT_Process_Simple_Glyph(), and tt_size_reset().

◆ ft_multo64()

static void ft_multo64 ( FT_UInt32  x,
FT_UInt32  y,
FT_Int64 z 
)
static

Definition at line 279 of file ftcalc.c.

282 {
283 FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
284
285
286 lo1 = x & 0x0000FFFFU; hi1 = x >> 16;
287 lo2 = y & 0x0000FFFFU; hi2 = y >> 16;
288
289 lo = lo1 * lo2;
290 i1 = lo1 * hi2;
291 i2 = lo2 * hi1;
292 hi = hi1 * hi2;
293
294 /* Check carry overflow of i1 + i2 */
295 i1 += i2;
296 hi += (FT_UInt32)( i1 < i2 ) << 16;
297
298 hi += i1 >> 16;
299 i1 = i1 << 16;
300
301 /* Check carry overflow of i1 + lo */
302 lo += i1;
303 hi += ( lo < i1 );
304
305 z->lo = lo;
306 z->hi = hi;
307 }

Referenced by ft_corner_orientation(), FT_MulDiv(), and FT_MulDiv_No_Round().

◆ FT_RoundFix()

FT_RoundFix ( FT_Fixed  a)

Definition at line 87 of file ftcalc.c.

88 {
89 return ( ADD_LONG( a, 0x8000L - ( a < 0 ) ) ) & ~0xFFFFL;
90 }

Referenced by cff_parse_font_bbox(), and ps_parser_load_field().

◆ FT_Vector_NormLen()

FT_Vector_NormLen ( FT_Vector vector)

Definition at line 845 of file ftcalc.c.

846 {
847 FT_Int32 x_ = vector->x;
848 FT_Int32 y_ = vector->y;
849 FT_Int32 b, z;
850 FT_UInt32 x, y, u, v, l;
851 FT_Int sx = 1, sy = 1, shift;
852
853
854 x = (FT_UInt32)x_;
855 y = (FT_UInt32)y_;
856
857 FT_MOVE_SIGN( x_, x, sx );
858 FT_MOVE_SIGN( y_, y, sy );
859
860 /* trivial cases */
861 if ( x == 0 )
862 {
863 if ( y > 0 )
864 vector->y = sy * 0x10000;
865 return y;
866 }
867 else if ( y == 0 )
868 {
869 if ( x > 0 )
870 vector->x = sx * 0x10000;
871 return x;
872 }
873
874 /* Estimate length and prenormalize by shifting so that */
875 /* the new approximate length is between 2/3 and 4/3. */
876 /* The magic constant 0xAAAAAAAAUL (2/3 of 2^32) helps */
877 /* achieve this in 16.16 fixed-point representation. */
878 l = x > y ? x + ( y >> 1 )
879 : y + ( x >> 1 );
880
881 shift = 31 - FT_MSB( l );
882 shift -= 15 + ( l >= ( 0xAAAAAAAAUL >> shift ) );
883
884 if ( shift > 0 )
885 {
886 x <<= shift;
887 y <<= shift;
888
889 /* re-estimate length for tiny vectors */
890 l = x > y ? x + ( y >> 1 )
891 : y + ( x >> 1 );
892 }
893 else
894 {
895 x >>= -shift;
896 y >>= -shift;
897 l >>= -shift;
898 }
899
900 /* lower linear approximation for reciprocal length minus one */
901 b = 0x10000 - (FT_Int32)l;
902
903 x_ = (FT_Int32)x;
904 y_ = (FT_Int32)y;
905
906 /* Newton's iterations */
907 do
908 {
909 u = (FT_UInt32)( x_ + ( x_ * b >> 16 ) );
910 v = (FT_UInt32)( y_ + ( y_ * b >> 16 ) );
911
912 /* Normalized squared length in the parentheses approaches 2^32. */
913 /* On two's complement systems, converting to signed gives the */
914 /* difference with 2^32 even if the expression wraps around. */
915 z = -(FT_Int32)( u * u + v * v ) / 0x200;
916 z = z * ( ( 0x10000 + b ) >> 8 ) / 0x10000;
917
918 b += z;
919
920 } while ( z > 0 );
921
922 vector->x = sx < 0 ? -(FT_Pos)u : (FT_Pos)u;
923 vector->y = sy < 0 ? -(FT_Pos)v : (FT_Pos)v;
924
925 /* Conversion to signed helps to recover from likely wrap around */
926 /* in calculating the prenormalized length, because it gives the */
927 /* correct difference with 2^32 on two's complement systems. */
928 l = (FT_UInt32)( 0x10000 + (FT_Int32)( u * x + v * y ) / 0x10000 );
929 if ( shift > 0 )
930 l = ( l + ( 1 << ( shift - 1 ) ) ) >> shift;
931 else
932 l <<= -shift;
933
934 return l;
935 }
r l[0]
Definition: byte_order.h:168
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240

Referenced by FT_Outline_EmboldenXY().

◆ FT_Vector_Transform_Scaled()

FT_Vector_Transform_Scaled ( FT_Vector vector,
const FT_Matrix matrix,
FT_Long  scaling 
)

Definition at line 820 of file ftcalc.c.

823 {
824 FT_Pos xz, yz;
825
826 FT_Long val = 0x10000L * scaling;
827
828
829 if ( !vector || !matrix )
830 return;
831
832 xz = ADD_LONG( FT_MulDiv( vector->x, matrix->xx, val ),
833 FT_MulDiv( vector->y, matrix->xy, val ) );
834 yz = ADD_LONG( FT_MulDiv( vector->x, matrix->yx, val ),
835 FT_MulDiv( vector->y, matrix->yy, val ) );
836
837 vector->x = xz;
838 vector->y = yz;
839 }

Referenced by cff_face_init().