字体点阵库导出map变量(方便添加到代码)

This commit is contained in:
gb 2024-02-02 16:54:48 +08:00
parent c469f37194
commit 928433f71a
2 changed files with 13 additions and 6 deletions

View File

@ -101,21 +101,28 @@ void CDlgZk::regen(void)
std::string ansi(util::u2a(text)); std::string ansi(util::u2a(text));
ansi = hz_2_py::getLetter(ansi); ansi = hz_2_py::getLetter(ansi);
std::transform(ansi.begin(), ansi.end(), ansi.begin(), tolower); std::transform(ansi.begin(), ansi.end(), ansi.begin(), tolower);
sep += util::a2u(ansi.c_str()) + L"[] = {" + std::to_wstring(out.cx) + L", " + std::to_wstring(out.cy) + L"\r\n\t\t"; fs = util::a2u(ansi.c_str());
swprintf_s(text, L", 0x%02X", ptr[0]); sep += fs + L"[] = {" + std::to_wstring(out.cx) + L", " + std::to_wstring(out.cy) + L"\r\n\t\t";
{
ansi = util::u2a(text, true);
uint8_t* p = (uint8_t*)&ansi[0];
swprintf_s(text, _countof(text) - 1, L"\\%03o\\%03o\\%03o", p[0], p[1], p[2]);
os = std::wstring(L"font_map_[\"") + text + L"\"] = " + fs + L";";
}
swprintf_s(text, _countof(text) - 1, L", 0x%02X", ptr[0]);
sep += text; sep += text;
for (int i = 1; i < out.cx * out.cy / 8; ++i) for (int i = 1; i < out.cx * out.cy / 8; ++i)
{ {
if (i % 16 == 0) if (i % 16 == 0)
swprintf_s(text, L"\r\n\t\t, 0x%02X", ptr[i]); swprintf_s(text, _countof(text) - 1, L"\r\n\t\t, 0x%02X", ptr[i]);
else if (i % 8 == 0) else if (i % 8 == 0)
swprintf_s(text, L", 0x%02X", ptr[i]); swprintf_s(text, _countof(text) - 1, L", 0x%02X", ptr[i]);
else else
swprintf_s(text, L", 0x%02X", ptr[i]); swprintf_s(text, _countof(text) - 1, L", 0x%02X", ptr[i]);
sep += text; sep += text;
} }
delete[] ptr; delete[] ptr;
sep += L"\r\n\t};\r\n\r\n"; sep += L"\r\n\t};\r\n" + os + L"\r\n\r\n";
} }
::ReleaseDC(hwnd, hdc); ::ReleaseDC(hwnd, hdc);

Binary file not shown.