Skip to content

Commit

Permalink
Fix WPF bidi (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidxuang committed Jan 23, 2024
1 parent efb5541 commit 27e3d27
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions FluentIcons.WPF/SymbolIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ protected override void OnRender(DrawingContext context)

var canvas = RenderTransform.TransformBounds(new Rect(0, 0, ActualWidth, ActualHeight));
context.PushClip(new RectangleGeometry(canvas));
var origin = new Point(canvas.Right - canvas.Width / 2 - _formattedText.Width / 2, canvas.Bottom - canvas.Height / 2 - _formattedText.Height / 2);
var origin = FlowDirection == FlowDirection.LeftToRight
? new Point(canvas.Left + (canvas.Width - _formattedText.Width) / 2, canvas.Top + (canvas.Height - _formattedText.Height) / 2)
: new Point(canvas.Right - (canvas.Width - _formattedText.Width) / 2, canvas.Top + (canvas.Height - _formattedText.Height) / 2);
context.DrawText(_formattedText, origin);
context.Pop();
}
Expand All @@ -103,7 +105,7 @@ private void InvalidateText()
_formattedText = new FormattedText(
Symbol.ToString(IsFilled),
CultureInfo.CurrentCulture,
CultureInfo.CurrentCulture.TextInfo.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight,
FlowDirection,
_font,
FontSize,
Foreground,
Expand Down

0 comments on commit 27e3d27

Please sign in to comment.