Use inline functions instead of macros for a couple of things

This commit is contained in:
Behdad Esfahbod 2017-08-04 17:07:23 +01:00
parent 15eba74ffe
commit 6f98286e15
2 changed files with 7 additions and 5 deletions

View File

@ -2102,7 +2102,10 @@ FcFreeTypeCheckGlyph (FT_Face face,
return FcTrue;
}
#define APPROXIMATELY_EQUAL(x,y) (FC_ABS ((x) - (y)) * 33 <= FC_MAX (FC_ABS (x), FC_ABS (y)))
static inline int fc_min (int a, int b) { return a <= b ? a : b; }
static inline int fc_max (int a, int b) { return a >= b ? a : b; }
static inline FcBool fc_approximately_equal (int x, int y)
{ return abs (x - y) * 33 <= fc_max (abs (x), abs (y)); }
FcCharSet *
FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spacing)
@ -2161,7 +2164,7 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
has_advance = FcTrue;
advance_one = advance;
}
else if (!APPROXIMATELY_EQUAL (advance, advance_one))
else if (!fc_approximately_equal (advance, advance_one))
{
if (fixed_advance)
{
@ -2169,7 +2172,7 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
fixed_advance = FcFalse;
advance_two = advance;
}
else if (!APPROXIMATELY_EQUAL (advance, advance_two))
else if (!fc_approximately_equal (advance, advance_two))
dual_advance = FcFalse;
}
}
@ -2220,7 +2223,7 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
}
if (fixed_advance)
*spacing = FC_MONO;
else if (dual_advance && APPROXIMATELY_EQUAL (2 * FC_MIN (advance_one, advance_two), FC_MAX (advance_one, advance_two)))
else if (dual_advance && fc_approximately_equal (2 * fc_min (advance_one, advance_two), fc_max (advance_one, advance_two)))
*spacing = FC_DUAL;
else
*spacing = FC_PROPORTIONAL;

View File

@ -101,7 +101,6 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
#define FC_MIN(a,b) ((a) < (b) ? (a) : (b))
#define FC_MAX(a,b) ((a) > (b) ? (a) : (b))
#define FC_ABS(a) ((a) < 0 ? -(a) : (a))
/* slim_internal.h */
#if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__) && !defined(__sun)