Skip to content

Conversation

gestern
Copy link
Contributor

@gestern gestern commented Sep 24, 2018

  1. when using setTitleLabel() the button didn't resolve the corresponded parameters;
  2. bug with measurement accuracy (ignores the fractional part) of the system font and ttf-fonts sizes;
  3. bug with the size of the button title (by default) did not match the value size of the label's typeface;
  4. removes high coupling the typeface parameters of button because it already contains the used label.

Tested on existing cpp-tests

(a)when using setTitleLabel() the button didn't resolve the corresponded parameters;
(b)bug with measurement accuracy (ignores the fractional part) of the system font and ttf-fonts sizes;
(c)bug with the size of the button title (by default) did not match the value size of the label's typeface;
(d)removes high coupling the typeface parameters of button because it already contains the used label
@drelaptop drelaptop merged commit 085ae26 into cocos2d:v3 Sep 29, 2018
@drelaptop drelaptop added this to the 3.18 milestone Sep 29, 2018
stevetranby added a commit to stevetranby/cocos2d-x that referenced this pull request Oct 1, 2018
…v3-merging

* commit 'a59519a4ef567df7aabac77646d49baa4709ff01': (65 commits)
  [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#19082)
  Fix several bugs with button's title (cocos2d#19073)
  [android] fix crash when point JNIEnv is a nullptr in getStringUTFCharsJNI func. (cocos2d#19079)
  [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#19074)
  refactor cmake on use libs (cocos2d#19054)
  [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#19068)
  [linux] CCFileUtils::isFileExistInternal should reject a folder (cocos2d#19062)
  Correct last delta time (cocos2d#18898)
  Add missing <functional> header which the standard requires and will be necessary to use std::function in VS2019. (cocos2d#18989)
  fix wrong parameter (cocos2d#19060)
  DrawNode add isolate flag (cocos2d#19056)
  Android: CCFileUtils listFiles impl (cocos2d#19044)
  CameraBackgroundDepthBrush should handle opengl recreate event. (cocos2d#19037)
  [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#19052)
  shorten the android build path, reduce long path error (cocos2d#19045)
  CCFileUtils: improve thread safety (use single recursive_mutex) (cocos2d#19046)
  remove assert (cocos2d#19047)
  [ci skip][AUTO]: updating luabinding & jsbinding & cocos_file.json automatically (cocos2d#19048)
  Android: Adds supporting edge screens (cocos2d#19043)
  cocos2d::Data: prevent use after free. (cocos2d#19034)
  ...

# Conflicts:
#	build/cocos2d_libs.xcodeproj/project.pbxproj
#	cocos/3d/Android.mk
#	cocos/Android.mk
#	cocos/deprecated/CCDeprecated.h
#	cocos/editor-support/cocostudio/Android.mk
#	cocos/editor-support/spine/Android.mk
#	cocos/platform/android/libcocos2dx-with-controller/build.gradle
#	cocos/platform/android/libcocos2dx/build.gradle
#	cocos/ui/UIAbstractCheckButton.cpp
#	cocos/ui/UIButton.cpp
#	cocos/ui/UIEditBox/UIEditBox.h
#	cocos/ui/UIEditBox/UIEditBoxImpl-common.h
#	extensions/Android.mk
#	tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.cpp
#	tests/cpp-tests/Classes/NewAudioEngineTest/NewAudioEngineTest.h
@gestern gestern deleted the button-render-title-bugfix branch October 5, 2018 01:58
@gestern gestern restored the button-render-title-bugfix branch October 5, 2018 02:04
@gestern gestern deleted the button-render-title-bugfix branch October 5, 2018 02:05
@PatriceJiang
Copy link
Contributor

PatriceJiang commented Dec 21, 2018

There is an issue that the font size attribute can be lost when the titleLabelType is changed later. Since the field is removed.

@souleid
Copy link

souleid commented Mar 11, 2019

Hey! I have Q,
I'm Bug found during upgrade from 3.16 to 3.17.1.

I was using this code,
auto button = ui::Button::create();
button->setTitleFontSize(defaultFontSize);
button->setTitleFontSize(defaultFontSize);

in 3.17.1 font size return to SYSTEM_DEFAULT_SIZE(12).

so I should changed code,
auto button = ui::Button::create();
button->setTitleFontName(defaultFont);
button->setTitleFontSize(defaultFontSize);

I think you drop out title size in setTitleFontName()
previous code, there is exist
TTFConfig config = _titleRenderer->getTTFConfig();
config.fontFilePath = fontName;
config.fontSize = _fontSize;
_titleRenderer->setTTFConfig(config);

What is right?

@bolino
Copy link
Contributor

bolino commented Mar 28, 2019

We experienced this same issue, some of our Button labels had a fixed size after updating.
Right now we did what is mentioned on the comment above, calling setTitleFontName() before setTitleFontSize().

huangwei1024 pushed a commit to huangwei1024/cocos2d-x that referenced this pull request Jun 20, 2019
* Fix several bugs with button's title:
(a)when using setTitleLabel() the button didn't resolve the corresponded parameters;
(b)bug with measurement accuracy (ignores the fractional part) of the system font and ttf-fonts sizes;
(c)bug with the size of the button title (by default) did not match the value size of the label's typeface;
(d)removes high coupling the typeface parameters of button because it already contains the used label

* Hotfix to call parent `Widget::init()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants