Closed kekekeks closed 1 year ago
Is there an equivalent API in WPF that we can copy?
There is no equivalent, but WPF contains FormattedText class. Usage example: http://stackoverflow.com/a/840642
How did you solve it later? I am now rendering some strings and also need to know the width of each rendered string.
See TextFormatter and friends.
In HtmlRenderer MeasureString
is now implemented like this:
https://github.com/AvaloniaUI/Avalonia.HtmlRenderer/blob/f4e8c20a53a4cb4cc09b4f2ad8460e75d9f1fb36/Avalonia.HtmlRenderer/Adapters/GraphicsAdapter.cs#L115-L124
We need something to be able to implement methods like
public override void MeasureString(string str, Font font, double maxWidth, out int charFit, out double charFitWidth)
(HtmlRenderer requires this).For example, Graphics.MeasureCharacterRanges returns info about each character's position.