Closed mohpor closed 5 years ago
Hmm, titleLabel?.font =
has always been around setting font to roboto, we've just updated it to use Theme.font
instead of RobotoFont
directly.
If we add Theme.isEnabled
check it then next time a dev updates Material will end up seeing different font if it hasn't been changed previously in code.
I think we may check if font is set by user by comparing current one with default one:
let defaultButtonFont = UIFont.systemFont(ofSize: UIFont.buttonFontSize)
if titleLabel?.font == defaultButtonFont {
titleLabel?.font = Theme.font.regular(with: fontSize)
}
@mohpor Can you please try above code and see if it works for you?
Then it must be something else that is triggering the font update.
I have a rather large project that has many many Button
instants, after updating to Material 3.x, all of those which rely on IB for font description now have lost the font.
I already have a workaround, but due to the vast amount of revision and coding effort, I had to revert back to 2.16.4
If we add Theme.isEnabled check it then next time a dev updates Material will end up seeing different font if it hasn't been changed previously in code.
this is what has happened to me unfortunately.
Ahh, I am mistaken. The line was added by me in https://github.com/CosmicMind/Material/commit/cf36b57ff18ec1607715456e0354e109ffebc9c1 It was not there before.
The reason why I added it, I believe, was that @danieldahan had been changing font to RobotoFont
after creating a button throughout the sample projects. I just wanted to eliminate it by setting it in the library itself which unfortunately seems to a breaking change for storyboard users. @danieldahan I think we should remove the line back. What do you think?
btw, thank you for reporting this @mohpor 💪
Hey @mohpor! You can try #1231 to see if it fixes your issue.
Hi @mohpor please find the latest release with the above fixes here https://github.com/CosmicMind/Material/releases/tag/3.1.1.
Hi,
Material 3.x (and Theming to be more specific), discards font's set on
Button
s in IB.this line will override the button's font, regardless of you opting out of theming.
I guess it should check to see if Theming (globally) is enabled before changing values.
e.g.:
For now, the workaround is to set button's font in code.