Skip to content

Commit

Permalink
(#63) Fix and remove some TODO notes
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Jan 15, 2023
1 parent 471cb70 commit 3ffc449
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/WpfMath.Shared/TexFormulaParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,8 @@ private TexFormula ReadScript(
return new Tuple<AtomAppendMode, Atom?>(
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))
Expand Down
9 changes: 6 additions & 3 deletions src/WpfMath/Fonts/WpfSystemFont.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Globalization;
using System.Windows;
using System.Windows.Media;
Expand All @@ -9,11 +10,15 @@ namespace WpfMath.Fonts;
internal class SystemFont : ITeXFont
{
private readonly FontFamily fontFamily;
private readonly Lazy<Typeface> _typeface;

public SystemFont(double size, FontFamily fontFamily)
{
this.fontFamily = fontFamily;
Size = size;

_typeface = new Lazy<Typeface>(
() => new Typeface(this.fontFamily, FontStyles.Normal, FontWeights.Normal, FontStretches.Normal));
}

public bool SupportsMetrics => false;
Expand All @@ -33,7 +38,7 @@ public Result<CharInfo> GetDefaultCharInfo(char character, TexStyle style) =>

public Result<CharInfo> GetCharInfo(char character, string textStyle, TexStyle style)
{
var typeface = this.GetTypeface();
var typeface = _typeface.Value;
if (!typeface.TryGetGlyphTypeface(out var glyphTypeface))
{
return Result.Error<CharInfo>(new TypeFaceNotFoundException(
Expand Down Expand Up @@ -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
}

0 comments on commit 3ffc449

Please sign in to comment.