Based on some early experimentation, developers have discovered that they almost always need to know the total line height (sum height of all lines), in order to calculate vertical placement of the formatted text on the canvas. The simple usage of fillFormattedText does not provide this information, and the advanced API requires iteratively measuring lines (which is slightly cumbersome and has potential performance overhead for all the other unneeded metrics calculations).
It would be nice to have a more convenient way of getting the total height needed for placement.
--
As previously noted in the explainer:
Should fillFormattedText (the single shot API) return the total height consumed after drawing lines?
This could be one way of getting the height, but ideally it can be obtained prior to drawing the text on the canvas.
Current approach (with metrics) puts retrieving the metrics object in the primary rendering path. The FormattedTextParagraph will have the total line height as blockSize.
Copied from: https://github.com/MicrosoftEdge/MSEdgeExplainers/issues/370
Based on some early experimentation, developers have discovered that they almost always need to know the total line height (sum height of all lines), in order to calculate vertical placement of the formatted text on the canvas. The simple usage of
fillFormattedText
does not provide this information, and the advanced API requires iteratively measuring lines (which is slightly cumbersome and has potential performance overhead for all the other unneeded metrics calculations).It would be nice to have a more convenient way of getting the total height needed for placement.
--
As previously noted in the explainer:
This could be one way of getting the height, but ideally it can be obtained prior to drawing the text on the canvas.