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,6 +2265,9 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
#endif #endif
break; break;
} }
if (spacing)
{
if (num_advances <= 1) if (num_advances <= 1)
*spacing = FC_MONO; *spacing = FC_MONO;
else if (num_advances == 2 && else if (num_advances == 2 &&
@ -2273,6 +2276,8 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks FC_UNUSED, int *spac
*spacing = FC_DUAL; *spacing = FC_DUAL;
else else
*spacing = FC_PROPORTIONAL; *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);
} }