-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options to style passed in BitmapText constructor. #6671
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #6671 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 678 678
=========================================
Hits 678 678 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking a stab at this. I'm really not crazy about this existing _font
object. What if we deprecate that font
getter/setter and break out the properties separately. Why does this have to be an object? Can't we just have separate properties for name/size/align?
Also, we should make sure that font
is deprecated properly for backward compatibility support.
Co-authored-by: Matt Karl <matt@mattkarl.com>
All subproperties of _font are lifted up to BitmapText properties. Signed-off-by: Shukant Pal <shukantpal@outlook.com>
Signed-off-by: Shukant Pal <shukantpal@outlook.com>
Signed-off-by: Shukant Pal <shukantpal@outlook.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'm good with this one. I made a couple of tweaks:
- Added setters for
fontName
andfontSize
- Fixed the deprecation (both in constructor and font setter)
- Defined defaults using
Object.assign
- Upgrade deprecations in tests
- Removes roundPixels and anchor from style options (these are rendering options, not "style")
Here's a demo just to prove that the deprecations still work:
https://jsfiddle.net/bigtimebuddy/har5kmcf/
const text = new PIXI.BitmapText(
'Hello World',
{ font: fontName } // deprecated, must be `fontName` as style prop
);
text.font = fontName; // setter has ben removed
text.font = '20px ' + fontName; // setter with size has been removed
text.font = { name: fontName, size: 20 }; // set as an object has been removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
#6667
Description of change
style.tint
passed toBitmapText
will now update the_tint
property of theBitmapText
and notthis._font
.Furthermore, the
_tint
field from_font
is removed (it was never referenced anywhere else).Added additional options to
IBitmapTextStyle
:letterSpacing
,maxWidth
,maxLineHeight
,anchor
,roundPixels
Updated the
BitmapText
constructor parameter documentation to reflect the above optionsPre-Merge Checklist
npm run lint
)npm run test
)