diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a80ef2c..23e7a43a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,12 +17,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - `RenderGlyphRun` has been replaced with `RenderCharacter` method (not reliant on any WPF-specific types), - `RenderRectangle` now receives an instance of a new `WpfMath.Rendering.Rectangle` type (decoupled from WPF). - `WpfMath.TexRenderer` is now obsolete. Consult the documentation on new recommended ways to perform custom rendering. There are new extension methods in two classes (`WpfMath.Rendering.WpfTeXFormulaExtensions` and `WpfMath.Rendering.TeXFormulaExtensions`) that are the main way to render formulae now. +- **(Breaking change.)** `WpfMath.TexFormnula::GetRenderer` is gone. Create a `TexRenderer` using constructor (obsolete) or use the aforementioned extension methods instead. ### Added - `WpfMath.CharInfo`: a new public type to work with a font character. Use `WpfMath.Fonts.WpfCharInfoEx::GetGlyphRun` if you need to get a `System.Windows.Media.GlyphRun` from it. - `WpfMath.Rendering.WpfTeXFormulaExtensions` to render a `WpfMath.TexFormula` into a `System.Windows.Media.Imaging.BitmapSource` or `System.Windows.Media.Geometry`. - New classes for WPF-Math porting to platforms other than WPF (consult the `WpfMath.Rendering.IElementRenderer` interface and `TexFormulaParser` constructor parameters to know more). - +- `WpfMath.Colors.RgbaColor` as a new portable color representation. +- `WpfMath.Fonts.IFontProvider`: implement this interface to provide alternate font reading functionality. +- `WpfMath.Fonts.ITeXFont`: implement this interface to provide access to a platform-specific font resource. +- `WpfMath.Rendering.IBrushFactory`: implement this interface to provide access to creation of platform-specific solid-colored brushes. +- `WpfMath.TeXFontMetrics` that contains some measurements of a font glyph. +- An utility `Result` struct is now public. ## [0.12.0] - 2023-01-07 ### Added diff --git a/src/WpfMath.ApiTest/api/WpfMath.Shared.net452.verified.cs b/src/WpfMath.ApiTest/api/WpfMath.Shared.net452.verified.cs index 9813825c..69648cb2 100644 --- a/src/WpfMath.ApiTest/api/WpfMath.Shared.net452.verified.cs +++ b/src/WpfMath.ApiTest/api/WpfMath.Shared.net452.verified.cs @@ -41,46 +41,6 @@ public partial class FormulaNotFoundException : System.Exception { internal FormulaNotFoundException() { } } - public partial interface ITeXFont - { - double Size { get; } - bool SupportsMetrics { get; } - double GetAxisHeight(WpfMath.TexStyle style); - double GetBigOpSpacing1(WpfMath.TexStyle style); - double GetBigOpSpacing2(WpfMath.TexStyle style); - double GetBigOpSpacing3(WpfMath.TexStyle style); - double GetBigOpSpacing4(WpfMath.TexStyle style); - double GetBigOpSpacing5(WpfMath.TexStyle style); - WpfMath.Utils.Result GetCharInfo(char character, string textStyle, WpfMath.TexStyle style); - WpfMath.Utils.Result GetCharInfo(string name, WpfMath.TexStyle style); - WpfMath.Utils.Result GetCharInfo(WpfMath.CharFont charFont, WpfMath.TexStyle style); - WpfMath.Utils.Result GetDefaultCharInfo(char character, WpfMath.TexStyle style); - double GetDefaultLineThickness(WpfMath.TexStyle style); - double GetDenom1(WpfMath.TexStyle style); - double GetDenom2(WpfMath.TexStyle style); - WpfMath.ExtensionChar GetExtension(WpfMath.CharInfo charInfo, WpfMath.TexStyle style); - double GetKern(WpfMath.CharFont leftChar, WpfMath.CharFont rightChar, WpfMath.TexStyle style); - WpfMath.CharFont? GetLigature(WpfMath.CharFont leftChar, WpfMath.CharFont rightChar); - int GetMuFontId(); - WpfMath.CharInfo GetNextLargerCharInfo(WpfMath.CharInfo charInfo, WpfMath.TexStyle style); - double GetNum1(WpfMath.TexStyle style); - double GetNum2(WpfMath.TexStyle style); - double GetNum3(WpfMath.TexStyle style); - double GetQuad(int fontId, WpfMath.TexStyle style); - double GetSkew(WpfMath.CharFont charFont, WpfMath.TexStyle style); - double GetSpace(WpfMath.TexStyle style); - double GetSub1(WpfMath.TexStyle style); - double GetSub2(WpfMath.TexStyle style); - double GetSubDrop(WpfMath.TexStyle style); - double GetSup1(WpfMath.TexStyle style); - double GetSup2(WpfMath.TexStyle style); - double GetSup3(WpfMath.TexStyle style); - double GetSupDrop(WpfMath.TexStyle style); - double GetXHeight(WpfMath.TexStyle style, int fontId); - bool HasNextLarger(WpfMath.CharInfo charInfo); - bool HasSpace(int fontId); - bool IsExtensionChar(WpfMath.CharInfo charInfo); - } public enum MatrixCellAlignment { Left = 0, @@ -152,14 +112,14 @@ public enum TexDelimiter } public sealed partial class TexEnvironment : System.IEquatable { - public TexEnvironment(WpfMath.TexStyle Style, WpfMath.ITeXFont MathFont, WpfMath.ITeXFont TextFont, WpfMath.Rendering.IBrush? Background = null, WpfMath.Rendering.IBrush? Foreground = null) { } + public TexEnvironment(WpfMath.TexStyle Style, WpfMath.Fonts.ITeXFont MathFont, WpfMath.Fonts.ITeXFont TextFont, WpfMath.Rendering.IBrush? Background = null, WpfMath.Rendering.IBrush? Foreground = null) { } public WpfMath.Rendering.IBrush? Background { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public WpfMath.Rendering.IBrush? Foreground { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } - public WpfMath.ITeXFont MathFont { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } + public WpfMath.Fonts.ITeXFont MathFont { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public WpfMath.TexStyle Style { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } - public WpfMath.ITeXFont TextFont { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } + public WpfMath.Fonts.ITeXFont TextFont { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] - public void Deconstruct(out WpfMath.TexStyle Style, out WpfMath.ITeXFont MathFont, out WpfMath.ITeXFont TextFont, out WpfMath.Rendering.IBrush? Background, out WpfMath.Rendering.IBrush? Foreground) { throw null; } + public void Deconstruct(out WpfMath.TexStyle Style, out WpfMath.Fonts.ITeXFont MathFont, out WpfMath.Fonts.ITeXFont TextFont, out WpfMath.Rendering.IBrush? Background, out WpfMath.Rendering.IBrush? Foreground) { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] public override bool Equals(object? obj) { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] @@ -189,7 +149,6 @@ public TexFormula() { } public WpfMath.SourceSpan? Source { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string? TextStyle { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public void Add(WpfMath.TexFormula formula, WpfMath.SourceSpan? source = null) { } - public WpfMath.Boxes.Box CreateBox(WpfMath.TexEnvironment environment) { throw null; } public void SetBackground(WpfMath.Rendering.IBrush brush) { } public void SetForeground(WpfMath.Rendering.IBrush brush) { } } @@ -290,12 +249,6 @@ public static partial class StandardColorParsers public static System.Collections.Generic.IReadOnlyDictionary Dictionary; } } -namespace WpfMath.Data -{ - public static partial class WpfMathResourceMarker - { - } -} namespace WpfMath.Exceptions { public partial class TexCharacterMappingNotFoundException : WpfMath.Exceptions.TexException @@ -334,6 +287,46 @@ public partial interface IFontProvider public partial interface IFontTypeface { } + public partial interface ITeXFont + { + double Size { get; } + bool SupportsMetrics { get; } + double GetAxisHeight(WpfMath.TexStyle style); + double GetBigOpSpacing1(WpfMath.TexStyle style); + double GetBigOpSpacing2(WpfMath.TexStyle style); + double GetBigOpSpacing3(WpfMath.TexStyle style); + double GetBigOpSpacing4(WpfMath.TexStyle style); + double GetBigOpSpacing5(WpfMath.TexStyle style); + WpfMath.Utils.Result GetCharInfo(char character, string textStyle, WpfMath.TexStyle style); + WpfMath.Utils.Result GetCharInfo(string name, WpfMath.TexStyle style); + WpfMath.Utils.Result GetCharInfo(WpfMath.CharFont charFont, WpfMath.TexStyle style); + WpfMath.Utils.Result GetDefaultCharInfo(char character, WpfMath.TexStyle style); + double GetDefaultLineThickness(WpfMath.TexStyle style); + double GetDenom1(WpfMath.TexStyle style); + double GetDenom2(WpfMath.TexStyle style); + WpfMath.ExtensionChar GetExtension(WpfMath.CharInfo charInfo, WpfMath.TexStyle style); + double GetKern(WpfMath.CharFont leftChar, WpfMath.CharFont rightChar, WpfMath.TexStyle style); + WpfMath.CharFont? GetLigature(WpfMath.CharFont leftChar, WpfMath.CharFont rightChar); + int GetMuFontId(); + WpfMath.CharInfo GetNextLargerCharInfo(WpfMath.CharInfo charInfo, WpfMath.TexStyle style); + double GetNum1(WpfMath.TexStyle style); + double GetNum2(WpfMath.TexStyle style); + double GetNum3(WpfMath.TexStyle style); + double GetQuad(int fontId, WpfMath.TexStyle style); + double GetSkew(WpfMath.CharFont charFont, WpfMath.TexStyle style); + double GetSpace(WpfMath.TexStyle style); + double GetSub1(WpfMath.TexStyle style); + double GetSub2(WpfMath.TexStyle style); + double GetSubDrop(WpfMath.TexStyle style); + double GetSup1(WpfMath.TexStyle style); + double GetSup2(WpfMath.TexStyle style); + double GetSup3(WpfMath.TexStyle style); + double GetSupDrop(WpfMath.TexStyle style); + double GetXHeight(WpfMath.TexStyle style, int fontId); + bool HasNextLarger(WpfMath.CharInfo charInfo); + bool HasSpace(int fontId); + bool IsExtensionChar(WpfMath.CharInfo charInfo); + } } namespace WpfMath.Rendering { diff --git a/src/WpfMath.ApiTest/api/WpfMath.Shared.netcoreapp3.1.verified.cs b/src/WpfMath.ApiTest/api/WpfMath.Shared.netcoreapp3.1.verified.cs index 9813825c..69648cb2 100644 --- a/src/WpfMath.ApiTest/api/WpfMath.Shared.netcoreapp3.1.verified.cs +++ b/src/WpfMath.ApiTest/api/WpfMath.Shared.netcoreapp3.1.verified.cs @@ -41,46 +41,6 @@ public partial class FormulaNotFoundException : System.Exception { internal FormulaNotFoundException() { } } - public partial interface ITeXFont - { - double Size { get; } - bool SupportsMetrics { get; } - double GetAxisHeight(WpfMath.TexStyle style); - double GetBigOpSpacing1(WpfMath.TexStyle style); - double GetBigOpSpacing2(WpfMath.TexStyle style); - double GetBigOpSpacing3(WpfMath.TexStyle style); - double GetBigOpSpacing4(WpfMath.TexStyle style); - double GetBigOpSpacing5(WpfMath.TexStyle style); - WpfMath.Utils.Result GetCharInfo(char character, string textStyle, WpfMath.TexStyle style); - WpfMath.Utils.Result GetCharInfo(string name, WpfMath.TexStyle style); - WpfMath.Utils.Result GetCharInfo(WpfMath.CharFont charFont, WpfMath.TexStyle style); - WpfMath.Utils.Result GetDefaultCharInfo(char character, WpfMath.TexStyle style); - double GetDefaultLineThickness(WpfMath.TexStyle style); - double GetDenom1(WpfMath.TexStyle style); - double GetDenom2(WpfMath.TexStyle style); - WpfMath.ExtensionChar GetExtension(WpfMath.CharInfo charInfo, WpfMath.TexStyle style); - double GetKern(WpfMath.CharFont leftChar, WpfMath.CharFont rightChar, WpfMath.TexStyle style); - WpfMath.CharFont? GetLigature(WpfMath.CharFont leftChar, WpfMath.CharFont rightChar); - int GetMuFontId(); - WpfMath.CharInfo GetNextLargerCharInfo(WpfMath.CharInfo charInfo, WpfMath.TexStyle style); - double GetNum1(WpfMath.TexStyle style); - double GetNum2(WpfMath.TexStyle style); - double GetNum3(WpfMath.TexStyle style); - double GetQuad(int fontId, WpfMath.TexStyle style); - double GetSkew(WpfMath.CharFont charFont, WpfMath.TexStyle style); - double GetSpace(WpfMath.TexStyle style); - double GetSub1(WpfMath.TexStyle style); - double GetSub2(WpfMath.TexStyle style); - double GetSubDrop(WpfMath.TexStyle style); - double GetSup1(WpfMath.TexStyle style); - double GetSup2(WpfMath.TexStyle style); - double GetSup3(WpfMath.TexStyle style); - double GetSupDrop(WpfMath.TexStyle style); - double GetXHeight(WpfMath.TexStyle style, int fontId); - bool HasNextLarger(WpfMath.CharInfo charInfo); - bool HasSpace(int fontId); - bool IsExtensionChar(WpfMath.CharInfo charInfo); - } public enum MatrixCellAlignment { Left = 0, @@ -152,14 +112,14 @@ public enum TexDelimiter } public sealed partial class TexEnvironment : System.IEquatable { - public TexEnvironment(WpfMath.TexStyle Style, WpfMath.ITeXFont MathFont, WpfMath.ITeXFont TextFont, WpfMath.Rendering.IBrush? Background = null, WpfMath.Rendering.IBrush? Foreground = null) { } + public TexEnvironment(WpfMath.TexStyle Style, WpfMath.Fonts.ITeXFont MathFont, WpfMath.Fonts.ITeXFont TextFont, WpfMath.Rendering.IBrush? Background = null, WpfMath.Rendering.IBrush? Foreground = null) { } public WpfMath.Rendering.IBrush? Background { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public WpfMath.Rendering.IBrush? Foreground { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } - public WpfMath.ITeXFont MathFont { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } + public WpfMath.Fonts.ITeXFont MathFont { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public WpfMath.TexStyle Style { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } - public WpfMath.ITeXFont TextFont { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } + public WpfMath.Fonts.ITeXFont TextFont { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] - public void Deconstruct(out WpfMath.TexStyle Style, out WpfMath.ITeXFont MathFont, out WpfMath.ITeXFont TextFont, out WpfMath.Rendering.IBrush? Background, out WpfMath.Rendering.IBrush? Foreground) { throw null; } + public void Deconstruct(out WpfMath.TexStyle Style, out WpfMath.Fonts.ITeXFont MathFont, out WpfMath.Fonts.ITeXFont TextFont, out WpfMath.Rendering.IBrush? Background, out WpfMath.Rendering.IBrush? Foreground) { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] public override bool Equals(object? obj) { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] @@ -189,7 +149,6 @@ public TexFormula() { } public WpfMath.SourceSpan? Source { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public string? TextStyle { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } } public void Add(WpfMath.TexFormula formula, WpfMath.SourceSpan? source = null) { } - public WpfMath.Boxes.Box CreateBox(WpfMath.TexEnvironment environment) { throw null; } public void SetBackground(WpfMath.Rendering.IBrush brush) { } public void SetForeground(WpfMath.Rendering.IBrush brush) { } } @@ -290,12 +249,6 @@ public static partial class StandardColorParsers public static System.Collections.Generic.IReadOnlyDictionary Dictionary; } } -namespace WpfMath.Data -{ - public static partial class WpfMathResourceMarker - { - } -} namespace WpfMath.Exceptions { public partial class TexCharacterMappingNotFoundException : WpfMath.Exceptions.TexException @@ -334,6 +287,46 @@ public partial interface IFontProvider public partial interface IFontTypeface { } + public partial interface ITeXFont + { + double Size { get; } + bool SupportsMetrics { get; } + double GetAxisHeight(WpfMath.TexStyle style); + double GetBigOpSpacing1(WpfMath.TexStyle style); + double GetBigOpSpacing2(WpfMath.TexStyle style); + double GetBigOpSpacing3(WpfMath.TexStyle style); + double GetBigOpSpacing4(WpfMath.TexStyle style); + double GetBigOpSpacing5(WpfMath.TexStyle style); + WpfMath.Utils.Result GetCharInfo(char character, string textStyle, WpfMath.TexStyle style); + WpfMath.Utils.Result GetCharInfo(string name, WpfMath.TexStyle style); + WpfMath.Utils.Result GetCharInfo(WpfMath.CharFont charFont, WpfMath.TexStyle style); + WpfMath.Utils.Result GetDefaultCharInfo(char character, WpfMath.TexStyle style); + double GetDefaultLineThickness(WpfMath.TexStyle style); + double GetDenom1(WpfMath.TexStyle style); + double GetDenom2(WpfMath.TexStyle style); + WpfMath.ExtensionChar GetExtension(WpfMath.CharInfo charInfo, WpfMath.TexStyle style); + double GetKern(WpfMath.CharFont leftChar, WpfMath.CharFont rightChar, WpfMath.TexStyle style); + WpfMath.CharFont? GetLigature(WpfMath.CharFont leftChar, WpfMath.CharFont rightChar); + int GetMuFontId(); + WpfMath.CharInfo GetNextLargerCharInfo(WpfMath.CharInfo charInfo, WpfMath.TexStyle style); + double GetNum1(WpfMath.TexStyle style); + double GetNum2(WpfMath.TexStyle style); + double GetNum3(WpfMath.TexStyle style); + double GetQuad(int fontId, WpfMath.TexStyle style); + double GetSkew(WpfMath.CharFont charFont, WpfMath.TexStyle style); + double GetSpace(WpfMath.TexStyle style); + double GetSub1(WpfMath.TexStyle style); + double GetSub2(WpfMath.TexStyle style); + double GetSubDrop(WpfMath.TexStyle style); + double GetSup1(WpfMath.TexStyle style); + double GetSup2(WpfMath.TexStyle style); + double GetSup3(WpfMath.TexStyle style); + double GetSupDrop(WpfMath.TexStyle style); + double GetXHeight(WpfMath.TexStyle style, int fontId); + bool HasNextLarger(WpfMath.CharInfo charInfo); + bool HasSpace(int fontId); + bool IsExtensionChar(WpfMath.CharInfo charInfo); + } } namespace WpfMath.Rendering { diff --git a/src/WpfMath.Shared/Atoms/CharAtom.cs b/src/WpfMath.Shared/Atoms/CharAtom.cs index 9758a39a..b76e55de 100644 --- a/src/WpfMath.Shared/Atoms/CharAtom.cs +++ b/src/WpfMath.Shared/Atoms/CharAtom.cs @@ -1,3 +1,4 @@ +using WpfMath.Fonts; using WpfMath.Utils; namespace WpfMath.Atoms diff --git a/src/WpfMath.Shared/Atoms/CharSymbol.cs b/src/WpfMath.Shared/Atoms/CharSymbol.cs index 77b741db..d69a4754 100644 --- a/src/WpfMath.Shared/Atoms/CharSymbol.cs +++ b/src/WpfMath.Shared/Atoms/CharSymbol.cs @@ -1,4 +1,5 @@ using WpfMath.Boxes; +using WpfMath.Fonts; using WpfMath.Utils; namespace WpfMath.Atoms diff --git a/src/WpfMath.Shared/Atoms/DummyAtom.cs b/src/WpfMath.Shared/Atoms/DummyAtom.cs index 8827ce00..993ee965 100644 --- a/src/WpfMath.Shared/Atoms/DummyAtom.cs +++ b/src/WpfMath.Shared/Atoms/DummyAtom.cs @@ -1,4 +1,5 @@ using WpfMath.Boxes; +using WpfMath.Fonts; using WpfMath.Utils; namespace WpfMath.Atoms diff --git a/src/WpfMath.Shared/Atoms/FixedCharAtom.cs b/src/WpfMath.Shared/Atoms/FixedCharAtom.cs index b130054b..78d74112 100644 --- a/src/WpfMath.Shared/Atoms/FixedCharAtom.cs +++ b/src/WpfMath.Shared/Atoms/FixedCharAtom.cs @@ -1,3 +1,4 @@ +using WpfMath.Fonts; using WpfMath.Utils; namespace WpfMath.Atoms diff --git a/src/WpfMath.Shared/Atoms/SymbolAtom.cs b/src/WpfMath.Shared/Atoms/SymbolAtom.cs index ffd19297..563b5720 100644 --- a/src/WpfMath.Shared/Atoms/SymbolAtom.cs +++ b/src/WpfMath.Shared/Atoms/SymbolAtom.cs @@ -1,7 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; +using WpfMath.Fonts; using WpfMath.Utils; namespace WpfMath.Atoms diff --git a/src/WpfMath.Shared/Compatibility/TupleExtensions.cs b/src/WpfMath.Shared/Compatibility/TupleExtensions.cs index 5f6f5813..2b4488af 100644 --- a/src/WpfMath.Shared/Compatibility/TupleExtensions.cs +++ b/src/WpfMath.Shared/Compatibility/TupleExtensions.cs @@ -1,8 +1,10 @@ +using System; + namespace WpfMath.Compatibility; #if NET452 // not needed for .NET Core 3.0+ because there are System.TupleExtensions -// TODO: Remove after migration to .NET Framework 4.7 -using System; +// TODO[#338]: Remove after migration to .NET Framework 4.7 + internal static class TupleExtensions { public static void Deconstruct(this Tuple tuple, out T1 x1, out T2 x2) diff --git a/src/WpfMath.Shared/Data/WpfMathResourceMarker.cs b/src/WpfMath.Shared/Data/WpfMathResourceMarker.cs index e2a52458..fa6935c0 100644 --- a/src/WpfMath.Shared/Data/WpfMathResourceMarker.cs +++ b/src/WpfMath.Shared/Data/WpfMathResourceMarker.cs @@ -1,6 +1,6 @@ namespace WpfMath.Data; /// Marks an assembly containing the WPF-Math resource files (XML and fonts). -public static class WpfMathResourceMarker +internal static class WpfMathResourceMarker { } diff --git a/src/WpfMath.Shared/Fonts/ITeXFont.cs b/src/WpfMath.Shared/Fonts/ITeXFont.cs new file mode 100644 index 00000000..ee747b08 --- /dev/null +++ b/src/WpfMath.Shared/Fonts/ITeXFont.cs @@ -0,0 +1,82 @@ +using WpfMath.Utils; + +namespace WpfMath.Fonts; + +/// Font that specifies how TexFormula objects are rendered. +public interface ITeXFont +{ + /// Whether the font supports . + bool SupportsMetrics { get; } + + double Size { get; } + + ExtensionChar GetExtension(CharInfo charInfo, TexStyle style); + + CharFont? GetLigature(CharFont leftChar, CharFont rightChar); + + CharInfo GetNextLargerCharInfo(CharInfo charInfo, TexStyle style); + + Result GetDefaultCharInfo(char character, TexStyle style); + + Result GetCharInfo(char character, string textStyle, TexStyle style); + + Result GetCharInfo(CharFont charFont, TexStyle style); + + Result GetCharInfo(string name, TexStyle style); + + double GetKern(CharFont leftChar, CharFont rightChar, TexStyle style); + + double GetQuad(int fontId, TexStyle style); + + double GetSkew(CharFont charFont, TexStyle style); + + bool HasSpace(int fontId); + + bool HasNextLarger(CharInfo charInfo); + + bool IsExtensionChar(CharInfo charInfo); + + int GetMuFontId(); + + double GetXHeight(TexStyle style, int fontId); + + double GetSpace(TexStyle style); + + double GetAxisHeight(TexStyle style); + + double GetBigOpSpacing1(TexStyle style); + + double GetBigOpSpacing2(TexStyle style); + + double GetBigOpSpacing3(TexStyle style); + + double GetBigOpSpacing4(TexStyle style); + + double GetBigOpSpacing5(TexStyle style); + + double GetSub1(TexStyle style); + + double GetSub2(TexStyle style); + + double GetSubDrop(TexStyle style); + + double GetSup1(TexStyle style); + + double GetSup2(TexStyle style); + + double GetSup3(TexStyle style); + + double GetSupDrop(TexStyle style); + + double GetNum1(TexStyle style); + + double GetNum2(TexStyle style); + + double GetNum3(TexStyle style); + + double GetDenom1(TexStyle style); + + double GetDenom2(TexStyle style); + + double GetDefaultLineThickness(TexStyle style); +} diff --git a/src/WpfMath.Shared/ITeXFont.cs b/src/WpfMath.Shared/ITeXFont.cs deleted file mode 100644 index 3d47f341..00000000 --- a/src/WpfMath.Shared/ITeXFont.cs +++ /dev/null @@ -1,83 +0,0 @@ -using WpfMath.Utils; - -namespace WpfMath -{ - /// Font that specifies how TexFormula objects are rendered. - public interface ITeXFont - { - /// Whether the font supports . - bool SupportsMetrics { get; } - - double Size { get; } - - ExtensionChar GetExtension(CharInfo charInfo, TexStyle style); - - CharFont? GetLigature(CharFont leftChar, CharFont rightChar); - - CharInfo GetNextLargerCharInfo(CharInfo charInfo, TexStyle style); - - Result GetDefaultCharInfo(char character, TexStyle style); - - Result GetCharInfo(char character, string textStyle, TexStyle style); - - Result GetCharInfo(CharFont charFont, TexStyle style); - - Result GetCharInfo(string name, TexStyle style); - - double GetKern(CharFont leftChar, CharFont rightChar, TexStyle style); - - double GetQuad(int fontId, TexStyle style); - - double GetSkew(CharFont charFont, TexStyle style); - - bool HasSpace(int fontId); - - bool HasNextLarger(CharInfo charInfo); - - bool IsExtensionChar(CharInfo charInfo); - - int GetMuFontId(); - - double GetXHeight(TexStyle style, int fontId); - - double GetSpace(TexStyle style); - - double GetAxisHeight(TexStyle style); - - double GetBigOpSpacing1(TexStyle style); - - double GetBigOpSpacing2(TexStyle style); - - double GetBigOpSpacing3(TexStyle style); - - double GetBigOpSpacing4(TexStyle style); - - double GetBigOpSpacing5(TexStyle style); - - double GetSub1(TexStyle style); - - double GetSub2(TexStyle style); - - double GetSubDrop(TexStyle style); - - double GetSup1(TexStyle style); - - double GetSup2(TexStyle style); - - double GetSup3(TexStyle style); - - double GetSupDrop(TexStyle style); - - double GetNum1(TexStyle style); - - double GetNum2(TexStyle style); - - double GetNum3(TexStyle style); - - double GetDenom1(TexStyle style); - - double GetDenom2(TexStyle style); - - double GetDefaultLineThickness(TexStyle style); - } -} diff --git a/src/WpfMath.Shared/Rendering/IBrushFactory.cs b/src/WpfMath.Shared/Rendering/IBrushFactory.cs index ecbc1d4f..1268a5bb 100644 --- a/src/WpfMath.Shared/Rendering/IBrushFactory.cs +++ b/src/WpfMath.Shared/Rendering/IBrushFactory.cs @@ -4,5 +4,5 @@ namespace WpfMath.Rendering; public interface IBrushFactory { - public IBrush FromColor(RgbaColor color); + IBrush FromColor(RgbaColor color); } diff --git a/src/WpfMath.Shared/TexEnvironment.cs b/src/WpfMath.Shared/TexEnvironment.cs index a92f439f..863b0fb8 100644 --- a/src/WpfMath.Shared/TexEnvironment.cs +++ b/src/WpfMath.Shared/TexEnvironment.cs @@ -1,3 +1,4 @@ +using WpfMath.Fonts; using WpfMath.Rendering; namespace WpfMath; diff --git a/src/WpfMath.Shared/TexFormula.cs b/src/WpfMath.Shared/TexFormula.cs index b42214a5..13429ab0 100644 --- a/src/WpfMath.Shared/TexFormula.cs +++ b/src/WpfMath.Shared/TexFormula.cs @@ -24,9 +24,6 @@ internal Atom? RootAtom public SourceSpan? Source { get; set; } - // TODO: Document the absence of TexFormula.GetRenderer method (that should be replaced with - // WpfMath.Rendering.TeXFormulaExtensions and WpfMath.Rendering.WpfTeXFormulaExtensions). - public void Add(TexFormula formula, SourceSpan? source = null) { Debug.Assert(formula != null); @@ -85,7 +82,7 @@ public void SetBackground(IBrush brush) } } - public Box CreateBox(TexEnvironment environment) + internal Box CreateBox(TexEnvironment environment) { if (this.RootAtom == null) return StrutBox.Empty; diff --git a/src/WpfMath.Shared/TexFormulaParser.cs b/src/WpfMath.Shared/TexFormulaParser.cs index 4efafe4c..dcf03f3e 100644 --- a/src/WpfMath.Shared/TexFormulaParser.cs +++ b/src/WpfMath.Shared/TexFormulaParser.cs @@ -46,7 +46,7 @@ public class TexFormulaParser private static readonly IList symbols; private static readonly IList delimeters; private static readonly HashSet textStyles; - // TODO: Architectural solution to make this work faster. + // TODO[#339]: Architectural solution to make this work faster. private readonly IReadOnlyDictionary> predefinedFormulas; private static readonly string[][] delimiterNames = diff --git a/src/WpfMath.Shared/TexPredefinedFormulaParser.cs b/src/WpfMath.Shared/TexPredefinedFormulaParser.cs index 14291589..3b0ec825 100644 --- a/src/WpfMath.Shared/TexPredefinedFormulaParser.cs +++ b/src/WpfMath.Shared/TexPredefinedFormulaParser.cs @@ -83,7 +83,7 @@ public TexPredefinedFormulaParser(IBrushFactory brushFactory) this.rootElement = doc.Root; } - // TODO: Review this API + // TODO[#339]: Review this API public void Parse(Dictionary> predefinedTeXFormulas) { var rootEnabled = rootElement.AttributeBooleanValue("enabled", true); diff --git a/src/WpfMath.Shared/TexSymbolParser.cs b/src/WpfMath.Shared/TexSymbolParser.cs index 35aeffc8..730fd6e7 100644 --- a/src/WpfMath.Shared/TexSymbolParser.cs +++ b/src/WpfMath.Shared/TexSymbolParser.cs @@ -37,7 +37,6 @@ private static void SetTypeMappings() public TexSymbolParser() { - // for 3.5 using var resource = typeof(WpfMathResourceMarker).Assembly.ReadResource(resourceName); var doc = XDocument.Load(resource); this.rootElement = doc.Root; diff --git a/src/WpfMath.Tests/Utils.fs b/src/WpfMath.Tests/Utils.fs index 4b4b92bd..5f54cb8d 100644 --- a/src/WpfMath.Tests/Utils.fs +++ b/src/WpfMath.Tests/Utils.fs @@ -3,9 +3,9 @@ module WpfMath.Tests.Utils open System open System.Windows -open WpfMath.Parsers open Xunit +open WpfMath.Parsers let initializeFontResourceLoading = let monitor = obj() diff --git a/src/WpfMath/TexRenderer.cs b/src/WpfMath/TexRenderer.cs index 8d821410..fc03b655 100644 --- a/src/WpfMath/TexRenderer.cs +++ b/src/WpfMath/TexRenderer.cs @@ -7,7 +7,7 @@ namespace WpfMath { [Obsolete("Use extension methods on WpfMath.TexFormula instead.")] - public class TexRenderer // TODO[F]: Drop in the next release + public class TexRenderer // TODO[#340]: Drop in the next release { /// Default DPI for WPF. private const int DefaultDpi = 96; diff --git a/src/WpfMath/WpfMath.csproj b/src/WpfMath/WpfMath.csproj index 4dfbf323..29823d18 100644 --- a/src/WpfMath/WpfMath.csproj +++ b/src/WpfMath/WpfMath.csproj @@ -51,7 +51,7 @@ Changed: - +