Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 16 additions & 20 deletions cocos/platform/win32/CCDevice-win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,18 +173,16 @@ class BitmapDC
if (fontPath.size() > 0)
{
_curFontPath = fontPath;
std::thread([fontPath, wnd = _wnd, this]() {
wchar_t * pwszBuffer = utf8ToUtf16(fontPath);
if (pwszBuffer)
wchar_t * pwszBuffer = utf8ToUtf16(fontPath);
if (pwszBuffer)
{
if (AddFontResource(pwszBuffer))
{
if (AddFontResource(pwszBuffer))
{
PostMessage(wnd, WM_FONTCHANGE, 0, 0);
}
delete[] pwszBuffer;
pwszBuffer = nullptr;
PostMessage(_wnd, WM_FONTCHANGE, 0, 0);
}
}).detach();
delete[] pwszBuffer;
pwszBuffer = nullptr;
}
}

_font = nullptr;
Expand Down Expand Up @@ -432,16 +430,14 @@ class BitmapDC
// release temp font resource
if (_curFontPath.size() > 0)
{
std::thread([curFontPath = _curFontPath, wnd = _wnd, this]() {
wchar_t * pwszBuffer = utf8ToUtf16(curFontPath);
if (pwszBuffer)
{
RemoveFontResource(pwszBuffer);
PostMessage(wnd, WM_FONTCHANGE, 0, 0);
delete[] pwszBuffer;
pwszBuffer = nullptr;
}
}).detach();
wchar_t * pwszBuffer = utf8ToUtf16(_curFontPath);
if (pwszBuffer)
{
RemoveFontResource(pwszBuffer);
PostMessage(_wnd, WM_FONTCHANGE, 0, 0);
delete[] pwszBuffer;
pwszBuffer = nullptr;
}
_curFontPath.clear();
}
}
Expand Down