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);
|
wxArrayString facenames = wxFontEnumerator::GetFacenames(font_encoding);
|
||||||
std::vector<wxString> bad_fonts;
|
std::vector<wxString> bad_fonts;
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "init_fonts_names start";
|
||||||
|
|
||||||
// validation lambda
|
// validation lambda
|
||||||
auto is_valid_font = [coding = font_encoding, bad = bad_fonts](const wxString &name) {
|
auto is_valid_font = [coding = font_encoding, bad = bad_fonts](const wxString &name) {
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
|
@ -83,6 +85,8 @@ std::vector<std::string> init_face_names()
|
||||||
}
|
}
|
||||||
assert(std::is_sorted(bad_fonts.begin(), bad_fonts.end()));
|
assert(std::is_sorted(bad_fonts.begin(), bad_fonts.end()));
|
||||||
|
|
||||||
|
BOOST_LOG_TRIVIAL(info) << "init_fonts_names end";
|
||||||
|
|
||||||
return valid_font_names;
|
return valid_font_names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,16 @@ bool load_hfont(void *hfont, DWORD &dwTable, DWORD &dwOffset, size_t &size, HDC
|
||||||
if (hdc == nullptr) {
|
if (hdc == nullptr) {
|
||||||
del_hdc = true;
|
del_hdc = true;
|
||||||
hdc = ::CreateCompatibleDC(NULL);
|
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
|
// 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 (size == 0 || size == GDI_ERROR) {
|
||||||
if (del_hdc) ::DeleteDC(hdc);
|
if (del_hdc)
|
||||||
|
::DeleteDC(hdc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (del_hdc)
|
||||||
|
::DeleteDC(hdc);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +202,13 @@ std::unique_ptr<FontFile> create_font_file(void *hfont)
|
||||||
HDC hdc = ::CreateCompatibleDC(NULL);
|
HDC hdc = ::CreateCompatibleDC(NULL);
|
||||||
if (hdc == NULL) {
|
if (hdc == NULL) {
|
||||||
assert(false);
|
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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue