Simplify advance-width calculations
This commit is contained in:
parent
6f98286e15
commit
1af7518583
|
@ -2112,8 +2112,8 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
|
||||||
{
|
{
|
||||||
FcCharSet *fcs;
|
FcCharSet *fcs;
|
||||||
int o;
|
int o;
|
||||||
FT_Pos advance, advance_one = 0, advance_two = 0;
|
FT_Pos advance, advances[3];
|
||||||
FcBool has_advance = FcFalse, fixed_advance = FcTrue, dual_advance = FcFalse;
|
unsigned int num_advances = 0;
|
||||||
|
|
||||||
fcs = FcCharSetCreate ();
|
fcs = FcCharSetCreate ();
|
||||||
if (!fcs)
|
if (!fcs)
|
||||||
|
@ -2157,24 +2157,14 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
|
||||||
{
|
{
|
||||||
if (FcFreeTypeCheckGlyph (face, ucs4, glyph, &advance))
|
if (FcFreeTypeCheckGlyph (face, ucs4, glyph, &advance))
|
||||||
{
|
{
|
||||||
if (advance)
|
if (num_advances < 3 && advance)
|
||||||
{
|
{
|
||||||
if (!has_advance)
|
unsigned int i;
|
||||||
{
|
for (i = 0; i < num_advances; i++)
|
||||||
has_advance = FcTrue;
|
if (fc_approximately_equal (advance, advances[i]))
|
||||||
advance_one = advance;
|
break;
|
||||||
}
|
if (i == num_advances)
|
||||||
else if (!fc_approximately_equal (advance, advance_one))
|
advances[num_advances++] = advance;
|
||||||
{
|
|
||||||
if (fixed_advance)
|
|
||||||
{
|
|
||||||
dual_advance = FcTrue;
|
|
||||||
fixed_advance = FcFalse;
|
|
||||||
advance_two = advance;
|
|
||||||
}
|
|
||||||
else if (!fc_approximately_equal (advance, advance_two))
|
|
||||||
dual_advance = FcFalse;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ucs4 >> 8) != page)
|
if ((ucs4 >> 8) != page)
|
||||||
|
@ -2221,9 +2211,11 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fixed_advance)
|
if (num_advances <= 1)
|
||||||
*spacing = FC_MONO;
|
*spacing = FC_MONO;
|
||||||
else if (dual_advance && fc_approximately_equal (2 * fc_min (advance_one, advance_two), fc_max (advance_one, advance_two)))
|
else if (num_advances == 2 &&
|
||||||
|
fc_approximately_equal (fc_min (advances[0], advances[1]) * 2,
|
||||||
|
fc_max (advances[0], advances[1])))
|
||||||
*spacing = FC_DUAL;
|
*spacing = FC_DUAL;
|
||||||
else
|
else
|
||||||
*spacing = FC_PROPORTIONAL;
|
*spacing = FC_PROPORTIONAL;
|
||||||
|
|
Loading…
Reference in New Issue