-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#63) TexFormula: move to the Shared assembly
- Loading branch information
Showing
14 changed files
with
86 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Linq; | ||
using System.Windows.Media; | ||
using WpfMath.Fonts; | ||
|
||
namespace WpfMath.Rendering; | ||
|
||
public static class WpfTeXEnvironment | ||
{ | ||
/// <summary>Creates an instance of <see cref="TexEnvironment"/> for a WPF program.</summary> | ||
/// <param name="style">Initial style for the formula content.</param> | ||
/// <param name="scale">Formula font size.</param> | ||
/// <param name="systemTextFontName">Name of the system font to use for the <code>\text</code> blocks.</param> | ||
/// <param name="foreground">Foreground color. Black if not specified.</param> | ||
/// <param name="background">Background color.</param> | ||
public static TexEnvironment Create( | ||
TexStyle style = TexStyle.Display, | ||
double scale = 20.0, | ||
string systemTextFontName = "Arial", | ||
Brush? foreground = null, | ||
Brush? background = null) | ||
{ | ||
var mathFont = new DefaultTexFont(WpfMathFontProvider.Instance, scale); | ||
var textFont = GetSystemFont(systemTextFontName, scale); | ||
|
||
return new TexEnvironment( | ||
style, | ||
mathFont, | ||
textFont, | ||
background.ToPlatform(), | ||
foreground.ToPlatform()); | ||
} | ||
|
||
private static SystemFont GetSystemFont(string fontName, double size) | ||
{ | ||
var fontFamily = System.Windows.Media.Fonts.SystemFontFamilies.First( | ||
ff => ff.ToString() == fontName || ff.FamilyNames.Values?.Contains(fontName) == true); | ||
return new SystemFont(size, fontFamily); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters