[MZ] Y-coordinate of the icon

It’s v1.10.0.
The formula for calculating the Y-coordinate of the icon is incorrect.
Adding 2 to the coordinate is a sloppy workaround for displaying a 32px-high icon on a line with a height of 36px, which causes display issues when the line height obtained from this.lineHeight() is changed.

It does not take into account any changes in resolution or layout due to changes in the asset specifications, so I believe it is a poor implementation.


Calculating it from textState.height or this.lineHeight() would be a more reasonable approach.

2 Likes

Thanks for the writeup and the code! Before I pass this on, does the misalignment show up in a stock project at the default line height, or only once lineHeight() is overridden or the icon size changes? From the snippet you posted the + 2 looks tuned for a 32px icon on a 36px line, so I’m wondering if it only drifts once one of those moves.

If it’s the second case then this is more of an improvement request than a defect, which changes where it goes rather than whether it gets looked at. Deriving the Y from textState.height does look like the more flexible version either way.

This also occurs when using control characters to change the font size.
+2 is too rough.
It would be more appropriate to calculate the centering based on textState.height.
Including the icon height in the maxFontSizeInLine() processing would make it even more perfect.