PATH:
opt
/
bitninja-threat-hunting
/
node_modules
/
node-pty
/
deps
/
winpty
/
misc
#include <windows.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <vector> #include "TestUtil.cc" #define COUNT_OF(array) (sizeof(array) / sizeof((array)[0])) // See https://en.wikipedia.org/wiki/List_of_CJK_fonts const wchar_t kMSGothic[] = { 0xff2d, 0xff33, 0x0020, 0x30b4, 0x30b7, 0x30c3, 0x30af, 0 }; // Japanese const wchar_t kNSimSun[] = { 0x65b0, 0x5b8b, 0x4f53, 0 }; // Simplified Chinese const wchar_t kMingLight[] = { 0x7d30, 0x660e, 0x9ad4, 0 }; // Traditional Chinese const wchar_t kGulimChe[] = { 0xad74, 0xb9bc, 0xccb4, 0 }; // Korean std::vector<bool> condense(const std::vector<CHAR_INFO> &buf) { std::vector<bool> ret; size_t i = 0; while (i < buf.size()) { if (buf[i].Char.UnicodeChar == L' ' && ((buf[i].Attributes & 0x300) == 0)) { // end of line break; } else if (i + 1 < buf.size() && ((buf[i].Attributes & 0x300) == 0x100) && ((buf[i + 1].Attributes & 0x300) == 0x200) && buf[i].Char.UnicodeChar != L' ' && buf[i].Char.UnicodeChar == buf[i + 1].Char.UnicodeChar) { // double-width ret.push_back(true); i += 2; } else if ((buf[i].Attributes & 0x300) == 0) { // single-width ret.push_back(false); i++; } else { ASSERT(false && "unexpected output"); } } return ret; } 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); }
[-] DebugServer.py
[edit]
[+]
Font-Report-June2016
[-] Win32Echo1.cc
[edit]
[-] font-notes.txt
[edit]
[-] ShowArgv.cc
[edit]
[-] SetCursorPos.cc
[edit]
[-] UnicodeDoubleWidthTest.cc
[edit]
[-] SetBufferSize.cc
[edit]
[-] GetFont.cc
[edit]
[-] FreezePerfTest.cc
[edit]
[-] color-test.sh
[edit]
[+]
..
[-] ShowConsoleInput.cc
[edit]
[-] MouseInputNotes.txt
[edit]
[-] DebugClient.py
[edit]
[-] ScreenBufferTest2.cc
[edit]
[-] Win10WrapTest1.cc
[edit]
[-] VeryLargeRead.cc
[edit]
[-] FormatChar.h
[edit]
[-] ChangeScreenBuffer.cc
[edit]
[-] IdentifyConsoleWindow.ps1
[edit]
[-] DumpLines.py
[edit]
[-] EnableExtendedFlags.txt
[edit]
[-] TestUtil.cc
[edit]
[-] MoveConsoleWindow.cc
[edit]
[-] ClearConsole.cc
[edit]
[-] IsNewConsole.cc
[edit]
[-] ConoutMode.cc
[edit]
[-] SetWindowRect.cc
[edit]
[-] ConinMode.cc
[edit]
[-] WindowsBugCrashReader.cc
[edit]
[-] WriteConsole.cc
[edit]
[-] UnicodeWideTest1.cc
[edit]
[-] Notes.txt
[edit]
[-] Win32Test2.cc
[edit]
[-] ScreenBufferFreezeInactive.cc
[edit]
[-] GetConsolePos.cc
[edit]
[-] VkEscapeTest.cc
[edit]
[-] Win32Test1.cc
[edit]
[-] winbug-15048.cc
[edit]
[-] Win32Write1.cc
[edit]
[-] ScreenBufferTest.cc
[edit]
[-] OSVersion.cc
[edit]
[-] BufferResizeTests.cc
[edit]
[-] Spew.py
[edit]
[-] build32.sh
[edit]
[-] build64.sh
[edit]
[-] SetFont.cc
[edit]
[-] SelectAllTest.cc
[edit]
[-] UnixEcho.cc
[edit]
[-] ConinMode.ps1
[edit]
[-] Utf16Echo.cc
[edit]
[-] UnicodeWideTest2.cc
[edit]
[-] FontSurvey.cc
[edit]
[-] GetCh.cc
[edit]
[-] Win10WrapTest2.cc
[edit]
[-] Win32Echo2.cc
[edit]
[-] Win32Test3.cc
[edit]
[-] Win10ResizeWhileFrozen.cc
[edit]