Fix UnicodeDoubleWidthTest font name output.

This commit is contained in:
Ryan Prichard 2015-10-10 02:22:53 -05:00
parent fe26bfda5f
commit f5b15bf274
2 changed files with 21 additions and 1 deletions

View File

@ -5,6 +5,7 @@
#include <string.h>
#include <wchar.h>
#include <vector>
#include <string>
#include "../shared/DebugClient.h"
@ -120,3 +121,22 @@ static void cprintf(const wchar_t *fmt, ...) {
cvprintf(fmt, ap);
va_end(ap);
}
std::string narrowString(const std::wstring &input)
{
int mblen = WideCharToMultiByte(
CP_UTF8, 0,
input.data(), input.size(),
NULL, 0, NULL, NULL);
if (mblen <= 0) {
return std::string();
}
std::vector<char> tmp(mblen);
int mblen2 = WideCharToMultiByte(
CP_UTF8, 0,
input.data(), input.size(),
tmp.data(), tmp.size(),
NULL, NULL);
assert(mblen2 == mblen);
return std::string(tmp.data(), tmp.size());
}

View File

@ -88,7 +88,7 @@ int main(int argc, char *argv[]) {
for (int px = 1; px < 50; ++px) {
setFont(kFaceName, px);
if (!performTest()) {
trace("FAILURE: %ls %dpx", kFaceName, px);
trace("FAILURE: %s %dpx", narrowString(kFaceName).c_str(), px);
}
}
trace("Test complete");