Closed frank-weindel closed 5 months ago
👍
As per phase 2 proposal, With inter-Black MSDF type, "Wonka" text will have a line height of 48, and "Migration" text will have a line height of 56, based on the maximum character height in each word
If two texts have different line heights, how does the final rendered height become the same for a given font size?
@suresh-gangumalla In Phase 2, the calculation of the Default Line Height is across all characters of the font, not just characters used in the text
property of a text node. So both "Wonka" and "Migration" should result in the same Default Line Height since they both use the same font "Inter-Black".
Updated the Phase 2 of the proposal to now rely on font metrics being provided explicitly by the developer (and extractable with the msdf-generator tool). This will have the added bonus of text between Canvas and SDF text renderers being able to be laid out consistently.
The following proposal aims to make the Reported Text Height, which is provided during the
loaded
event for Text Nodes, consistent between SDF and Canvas text renderers, closer to how HTML/CSS works, and solve some issues that have been reported around the current implementation:165
157
The phases are divided as such to make it easier to grok the issues and their solutions. We could very well implement and release all of phases at once.
Phase 1: Make Reported Text Height dimension of text based purely on Line Height and number of lines rendered (plus offsetY)
Phase 2: Determine Default Line Height by Font Metrics
ascender
,descender
andlineGap
.metrics.actualBoundingBoxAscent
/fontSize
metrics.actualBoundingBoxDescent
/fontSize
Phase 3: Make the Default Vertical Align text property value "middle"
vertical-align
property has an entirely different functionality and there is really no equivalent property in CSS that does exactly what Lightning's Vertical Align text property does. In HTML/CSS, text is rendered in the way it would be if the Lightning Vertical Align property was set to "middle".