Closed
Description
Version
- Phaser Version: 3.80.1
- Operating system: MacOS
- Browser: all browsers
Description
https://github.com/phaserjs/phaser/blob/master/src/gameobjects/text/TextStyle.js
TextStyle.setStyle normalizes the given fontSize by adding "px" if it is just a number. However, the function will mutate the original given "style" parameter, which is a counterintuitive side-effect that is also unnecessary. This makes hard to define global font styles for reuse, since after the first setStyle call a font size of for example 32 (number) will be "32px" (string) afterwards, meaning it cannot be used for calculation of relative font sizes anymore.
The "style" parameter should not be mutated. Cloning it before changing it would fix the problem, I guess a shallow copy would also suffice.
Example Test Code
Metadata
Metadata
Assignees
Labels
No labels