FIX: add log for load font
jira: none Change-Id: I30d652525bb2f6917a2ed6b59408fe93459ad4bf
This commit is contained in:
parent
a89df79068
commit
92e6de4961
|
@ -45,6 +45,8 @@ std::vector<std::string> init_face_names()
|
|||
wxArrayString facenames = wxFontEnumerator::GetFacenames(font_encoding);
|
||||
std::vector<wxString> bad_fonts;
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "init_fonts_names start";
|
||||
|
||||
// validation lambda
|
||||
auto is_valid_font = [coding = font_encoding, bad = bad_fonts](const wxString &name) {
|
||||
if (name.empty())
|
||||
|
@ -70,7 +72,7 @@ std::vector<std::string> init_face_names()
|
|||
return false;
|
||||
|
||||
return true;
|
||||
};
|
||||
};
|
||||
|
||||
std::sort(facenames.begin(), facenames.end());
|
||||
for (const wxString &name : facenames) {
|
||||
|
@ -83,6 +85,8 @@ std::vector<std::string> init_face_names()
|
|||
}
|
||||
assert(std::is_sorted(bad_fonts.begin(), bad_fonts.end()));
|
||||
|
||||
BOOST_LOG_TRIVIAL(info) << "init_fonts_names end";
|
||||
|
||||
return valid_font_names;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,16 @@ bool load_hfont(void *hfont, DWORD &dwTable, DWORD &dwOffset, size_t &size, HDC
|
|||
if (hdc == nullptr) {
|
||||
del_hdc = true;
|
||||
hdc = ::CreateCompatibleDC(NULL);
|
||||
if (hdc == NULL) return false;
|
||||
if (hdc == NULL) {
|
||||
DWORD errorCode = GetLastError();
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &lpMsgBuf, 0, NULL);
|
||||
|
||||
BOOST_LOG_TRIVIAL(error) << "CreateCompatibleDC failed in load_hfont : "
|
||||
<< "Error: " << reinterpret_cast<LPTSTR>(lpMsgBuf);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// To retrieve the data from the beginning of the file for TrueType
|
||||
|
@ -177,9 +186,14 @@ bool load_hfont(void *hfont, DWORD &dwTable, DWORD &dwOffset, size_t &size, HDC
|
|||
}
|
||||
|
||||
if (size == 0 || size == GDI_ERROR) {
|
||||
if (del_hdc) ::DeleteDC(hdc);
|
||||
if (del_hdc)
|
||||
::DeleteDC(hdc);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (del_hdc)
|
||||
::DeleteDC(hdc);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -188,7 +202,13 @@ std::unique_ptr<FontFile> create_font_file(void *hfont)
|
|||
HDC hdc = ::CreateCompatibleDC(NULL);
|
||||
if (hdc == NULL) {
|
||||
assert(false);
|
||||
BOOST_LOG_TRIVIAL(error) << "Can't create HDC by CreateCompatibleDC(NULL).";
|
||||
DWORD errorCode = GetLastError();
|
||||
LPVOID lpMsgBuf;
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
|
||||
|
||||
BOOST_LOG_TRIVIAL(error) << "CreateCompatibleDC failed in create_font_file : "
|
||||
<< "Error: " << reinterpret_cast<LPTSTR>(lpMsgBuf);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue