diff --git a/src/WpfMath.Shared/TexFormulaParser.cs b/src/WpfMath.Shared/TexFormulaParser.cs index 9127879e..4efafe4c 100644 --- a/src/WpfMath.Shared/TexFormulaParser.cs +++ b/src/WpfMath.Shared/TexFormulaParser.cs @@ -565,9 +565,8 @@ private TexFormula ReadScript( return new Tuple( AtomAppendMode.Add, new StyledAtom(source, bodyFormula.RootAtom, _brushFactory.FromColor(color), null)); - // TODO[#63]: ↑ Should read platform brush from color - } } + } if (environment.AvailableCommands.TryGetValue(command, out var parser) || _commandRegistry.TryGetValue(command, out parser)) diff --git a/src/WpfMath/Fonts/WpfSystemFont.cs b/src/WpfMath/Fonts/WpfSystemFont.cs index 84a13a37..15cc2252 100644 --- a/src/WpfMath/Fonts/WpfSystemFont.cs +++ b/src/WpfMath/Fonts/WpfSystemFont.cs @@ -1,3 +1,4 @@ +using System; using System.Globalization; using System.Windows; using System.Windows.Media; @@ -9,11 +10,15 @@ namespace WpfMath.Fonts; internal class SystemFont : ITeXFont { private readonly FontFamily fontFamily; + private readonly Lazy _typeface; public SystemFont(double size, FontFamily fontFamily) { this.fontFamily = fontFamily; Size = size; + + _typeface = new Lazy( + () => new Typeface(this.fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal)); } public bool SupportsMetrics => false; @@ -33,7 +38,7 @@ public Result GetDefaultCharInfo(char character, TexStyle style) => public Result GetCharInfo(char character, string textStyle, TexStyle style) { - var typeface = this.GetTypeface(); + var typeface = _typeface.Value; if (!typeface.TryGetGlyphTypeface(out var glyphTypeface)) { return Result.Error(new TypeFaceNotFoundException( @@ -127,6 +132,4 @@ private TexFontMetrics GetFontMetrics(char c, Typeface typeface) ); return new TexFontMetrics(formattedText.Width, formattedText.Height, 0.0, formattedText.Width, 1.0); } - - private Typeface GetTypeface() => new Typeface(this.fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal); // TODO[F]: Put into lazy field }