Cache formatted text
MODIFY
WalletWasabi.Fluent/Controls/PrivacyTextPresenter.cs
WalletWasabi.Fluent/Controls/PrivacyTextPresenter.cs
@@ -31,18 +31,27 @@ public class PrivacyTextPresenter : UserControl
private GlyphRun? _glyphRun;
private double _width;
+ private FormattedText? _formattedText;
- protected override Size MeasureOverride(Size availableSize)
+ private FormattedText CreateFormattedText()
{
- var formattedText = new FormattedText(
+ return new FormattedText(
"#",
new Typeface(FontFamily, FontStyle, FontWeight),
FontSize,
TextAlignment.Left,
TextWrapping.NoWrap,
- availableSize);
+ Size.Empty);
+ }
+
+ protected override Size MeasureOverride(Size availableSize)
+ {
+ if (_formattedText is null)
+ {
+ _formattedText = CreateFormattedText();
+ }
- return new Size(FontSize, formattedText.Bounds.Height);
+ return new Size(FontSize, _formattedText.Bounds.Height);
}
public override void Render(DrawingContext context)

Cache formatted text