fix : win32 system label has wrong scale factor (#18520)

* Update UIEditBoxImpl-win32.cpp

* Fix a fixme
This commit is contained in:
Jeff Wang 2017-12-08 18:18:04 +08:00 committed by minggo
parent 78f2d9940a
commit 7916beb314
2 changed files with 3 additions and 7 deletions

View File

@ -72,7 +72,6 @@ namespace ui {
EditBoxImplWin::EditBoxImplWin(EditBox* pEditText)
: EditBoxImplCommon(pEditText),
_fontSize(40),
_changedTextManually(false),
_hasFocus(false)
{
@ -174,9 +173,8 @@ namespace ui {
void EditBoxImplWin::setNativeFont(const char * pFontName, int fontSize)
{
//not implemented yet
this->_fontSize = fontSize;
HFONT hFont = CreateFontW(fontSize, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
auto glView = Director::getInstance()->getOpenGLView();
HFONT hFont = CreateFontW(static_cast<int>(fontSize * glView->getScaleX()), 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_OUTLINE_PRECIS,
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
SendMessage(hwndEdit, // Handle of edit control
@ -434,4 +432,4 @@ namespace ui {
NS_CC_END
#endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) */
#endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) */

View File

@ -75,8 +75,6 @@ namespace ui {
static LRESULT CALLBACK hookGLFWWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
HWND hwndEdit;
//FIXME: fontSize should be in parent class
int _fontSize;
bool _changedTextManually;
bool _hasFocus;
static WNDPROC s_prevCocosWndProc;