Skip to content

Commit

Permalink
fix: [macOS] Tentative performance update for NSTextStorage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromelaban committed Apr 3, 2020
1 parent 722e7b8 commit 31bd64f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Uno.UI/UI/Xaml/Controls/TextBlock/TextBlock.macOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected override Size MeasureOverride(Size size)
{
// This measures the height correctly, even if the Text is null or empty
// This matches Windows where empty TextBlocks still have a height (especially useful when measuring ListView items with no DataContext)
var font = NSFontHelper.TryGetFont((float)FontSize, FontWeight, FontStyle, FontFamily);
var font = NSFontHelper.TryGetFont((float)FontSize*2, FontWeight, FontStyle, FontFamily);

var str = new NSAttributedString(Text, font);

Expand Down Expand Up @@ -333,15 +333,16 @@ private void UpdateTypography()
_textContainer.LineFragmentPadding = 0;
_textContainer.LineBreakMode = GetLineBreakMode();
_textContainer.MaximumNumberOfLines = (nuint)GetLines();


// Configure textStorage
_textStorage = new NSTextStorage();
_textStorage.SetString(_attributedString);

// Configure layoutManager
_layoutManager = new NSLayoutManager();
_layoutManager.AddTextContainer(_textContainer);

// Configure textStorage
_textStorage = new NSTextStorage();
_textStorage.AddLayoutManager(_layoutManager);
_textStorage.SetString(_attributedString);
}
}

Expand Down

0 comments on commit 31bd64f

Please sign in to comment.