From 7916beb314ed2947959c98fefd82d7c98e88e31e Mon Sep 17 00:00:00 2001 From: Jeff Wang Date: Fri, 8 Dec 2017 18:18:04 +0800 Subject: [PATCH] fix : win32 system label has wrong scale factor (#18520) * Update UIEditBoxImpl-win32.cpp * Fix a fixme --- cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp | 8 +++----- cocos/ui/UIEditBox/UIEditBoxImpl-win32.h | 2 -- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp index 7c730ee3ed..010645d3ce 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.cpp @@ -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(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) */ \ No newline at end of file +#endif /* (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) */ diff --git a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h index c3340b545b..4cae897fa5 100644 --- a/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h +++ b/cocos/ui/UIEditBox/UIEditBoxImpl-win32.h @@ -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;