vgui2/vgui_surfacelib/linuxfont: fix incorrect variadic casts

backport from MainUI C++
Ref: fad4805fab
This commit is contained in:
r-a-sattarov 2022-01-28 23:49:27 +03:00
parent d947e5e20e
commit 2ad3bc4a66

View file

@ -166,44 +166,40 @@ void CLinuxFont::CreateFontList()
} }
#ifndef ANDROID #ifndef ANDROID
static FcPattern* FontMatch(const char* type, FcType vtype, const void* value, static FcPattern* FontMatch(const char* type, ...)
...)
{ {
FcValue fcvalue;
va_list ap; va_list ap;
va_start(ap, value); va_start(ap, type);
FcPattern* pattern = FcPatternCreate(); FcPattern* pattern = FcPatternCreate();
for (;;) for (;;) {
{ // FcType is promoted to int when passed through ...
FcValue fcvalue; fcvalue.type = static_cast<FcType>(va_arg(ap, int));
fcvalue.type = vtype; switch (fcvalue.type) {
switch (vtype) {
case FcTypeString: case FcTypeString:
fcvalue.u.s = (FcChar8*) value; fcvalue.u.s = va_arg(ap, const FcChar8 *);
break; break;
case FcTypeInteger: case FcTypeInteger:
fcvalue.u.i = (int) value; fcvalue.u.i = va_arg(ap, int);
break; break;
default: default:
Assert(!"FontMatch unhandled type"); Assert(!"FontMatch unhandled type");
} }
FcPatternAdd(pattern, type, fcvalue, 0); FcPatternAdd(pattern, type, fcvalue, FcFalse);
type = va_arg(ap, const char *); type = va_arg(ap, const char *);
if (!type) if (!type)
break; break;
// FcType is promoted to int when passed through ...
vtype = static_cast<FcType>(va_arg(ap, int));
value = va_arg(ap, const void *);
}; };
va_end(ap); va_end(ap);
FcConfigSubstitute(0, pattern, FcMatchPattern); FcConfigSubstitute(NULL, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern); FcDefaultSubstitute(pattern);
FcResult result; FcResult result;
FcPattern* match = FcFontMatch(0, pattern, &result); FcPattern* match = FcFontMatch(NULL, pattern, &result);
FcPatternDestroy(pattern); FcPatternDestroy(pattern);
return match; return match;