Accept NULL in for spacing in FcFreeTypeCharSetAndSpacing()

This commit is contained in:
Behdad Esfahbod 2017-09-12 18:00:43 -04:00
parent 0757556ddf
commit 6eb7e5ae81
1 changed files with 16 additions and 13 deletions

View File

@ -2140,8 +2140,8 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
FcCharSet *fcs; FcCharSet *fcs;
int o; int o;
FT_Int load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING; FT_Int load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH | FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
FT_Pos advances[3]; FT_Pos advances[3] = {};
unsigned int num_advances = 0; unsigned int num_advances = spacing ? 0 : 3;
fcs = FcCharSetCreate (); fcs = FcCharSetCreate ();
if (!fcs) if (!fcs)
@ -2265,14 +2265,19 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
#endif #endif
break; break;
} }
if (num_advances <= 1)
*spacing = FC_MONO; if (spacing)
else if (num_advances == 2 && {
fc_approximately_equal (fc_min (advances[0], advances[1]) * 2, if (num_advances <= 1)
fc_max (advances[0], advances[1]))) *spacing = FC_MONO;
*spacing = FC_DUAL; else if (num_advances == 2 &&
else fc_approximately_equal (fc_min (advances[0], advances[1]) * 2,
*spacing = FC_PROPORTIONAL; fc_max (advances[0], advances[1])))
*spacing = FC_DUAL;
else
*spacing = FC_PROPORTIONAL;
}
return fcs; return fcs;
bail1: bail1:
FcCharSetDestroy (fcs); FcCharSetDestroy (fcs);
@ -2283,9 +2288,7 @@ bail0:
FcCharSet * FcCharSet *
FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks FC_UNUSED) FcFreeTypeCharSet (FT_Face face, FcBlanks *blanks FC_UNUSED)
{ {
int spacing; return FcFreeTypeCharSetAndSpacing (face, blanks, NULL);
return FcFreeTypeCharSetAndSpacing (face, blanks, &spacing);
} }