Skip to content

Commit

Permalink
fix(Skia): [TextBlock] Fix rendering when font properties change
Browse files Browse the repository at this point in the history
  • Loading branch information
mikernet committed Jun 22, 2022
1 parent 1164417 commit 3dc5b2d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Uno.UI/UI/Xaml/Documents/Inline.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ internal float LineHeight

internal float BelowBaselineHeight => Paint.FontMetrics.Descent;

protected override void InvalidateFontInfo() => _fontInfo = null;

private static FontDetails GetFont(
string? name,
FontWeight weight,
Expand Down Expand Up @@ -99,9 +101,9 @@ private static FontDetails GetFont(
// FromFontFamilyName may return null: https://github.com/mono/SkiaSharp/issues/1058
if (skTypeFace == null)
{
if (typeof(Run).Log().IsEnabled(LogLevel.Warning))
if (typeof(Inline).Log().IsEnabled(LogLevel.Warning))
{
typeof(Run).Log().LogWarning($"The font {name} could not be found, using system default");
typeof(Inline).Log().LogWarning($"The font {name} could not be found, using system default");
}

skTypeFace = SKTypeface.FromFamilyName(null, skWeight, skWidth, skSlant);
Expand Down
26 changes: 26 additions & 0 deletions src/Uno.UI/UI/Xaml/Documents/TextElement.skia.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Windows.UI.Xaml.Documents
{
partial class TextElement
{
protected virtual void InvalidateFontInfo() { }

partial void OnFontFamilyChangedPartial()
{
InvalidateFontInfo();
}

partial void OnFontStyleChangedPartial()
{
InvalidateFontInfo();
}

partial void OnFontWeightChangedPartial()
{
InvalidateFontInfo();
}
}
}

0 comments on commit 3dc5b2d

Please sign in to comment.