int main()

in misc/FontSurvey.cc [46:100]


int main(int argc, char *argv[]) {
    if (argc != 2) {
        printf("Usage: %s \"arguments for SetFont.exe\"\n", argv[0]);
        return 1;
    }

    const char *setFontArgs = argv[1];

    const wchar_t testLine[] = { 0xA2, 0xA3, 0x2014, 0x3044, 0x30FC, 0x4000, 0 };
    const HANDLE conout = openConout();

    char setFontCmd[1024];
    for (int h = 1; h <= 100; ++h) {
        sprintf(setFontCmd, ".\\SetFont.exe %s -h %d && cls", setFontArgs, h);
        system(setFontCmd);

        CONSOLE_FONT_INFOEX infoex = {};
        infoex.cbSize = sizeof(infoex);
        BOOL success = GetCurrentConsoleFontEx(conout, FALSE, &infoex);
        ASSERT(success && "GetCurrentConsoleFontEx failed");

        DWORD actual = 0;
        success = WriteConsoleW(conout, testLine, wcslen(testLine), &actual, nullptr);
        ASSERT(success && actual == wcslen(testLine));

        std::vector<CHAR_INFO> readBuf(14);
        const SMALL_RECT readRegion = {0, 0, static_cast<short>(readBuf.size() - 1), 0};
        SMALL_RECT readRegion2 = readRegion;
        success = ReadConsoleOutputW(
            conout, readBuf.data(), 
            {static_cast<short>(readBuf.size()), 1}, 
            {0, 0},
            &readRegion2);
        ASSERT(success && !memcmp(&readRegion, &readRegion2, sizeof(readRegion)));

        const auto widths = condense(readBuf);
        std::string widthsStr;
        for (bool width : widths) {
            widthsStr.append(width ? "F" : "H");
        }
        char size[16];
        sprintf(size, "%d,%d", infoex.dwFontSize.X, infoex.dwFontSize.Y);
        const char *status = "";
        if (widthsStr == "HHFFFF") {
            status = "GOOD";
        } else if (widthsStr == "HHHFFF") {
            status = "OK";
        } else {
            status = "BAD";
        }
        trace("Size %3d: %-7s %-4s (%s)", h, size, status, widthsStr.c_str());
    }
    sprintf(setFontCmd, ".\\SetFont.exe %s -h 14", setFontArgs);
    system(setFontCmd);
}