{"id":15623804,"url":"https://github.com/fornever/xaml-math","last_synced_at":"2025-05-14T03:07:26.292Z","repository":{"id":38083593,"uuid":"81464927","full_name":"ForNeVeR/xaml-math","owner":"ForNeVeR","description":"A collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and Avalonia XAML-based frameworks","archived":false,"fork":false,"pushed_at":"2024-06-08T20:41:27.000Z","size":2437,"stargazers_count":641,"open_issues_count":83,"forks_count":102,"subscribers_count":31,"default_branch":"master","last_synced_at":"2024-10-29T22:32:12.109Z","etag":null,"topics":["dotnet","formula","hacktoberfest","latex","math","render","svg","tex","wpf"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ForNeVeR.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-09T15:32:36.000Z","updated_at":"2024-10-17T03:01:44.000Z","dependencies_parsed_at":"2024-01-02T22:38:18.751Z","dependency_job_id":"d2b0db9a-1f99-4b6d-a41e-4d99021d03e5","html_url":"https://github.com/ForNeVeR/xaml-math","commit_stats":{"total_commits":846,"total_committers":30,"mean_commits":28.2,"dds":"0.37234042553191493","last_synced_commit":"d5d86b70d43ce8470834438f87c5d14af0305708"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForNeVeR%2Fxaml-math","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForNeVeR%2Fxaml-math/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForNeVeR%2Fxaml-math/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ForNeVeR%2Fxaml-math/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ForNeVeR","download_url":"https://codeload.github.com/ForNeVeR/xaml-math/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247563930,"owners_count":20958971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dotnet","formula","hacktoberfest","latex","math","render","svg","tex","wpf"],"created_at":"2024-10-03T09:58:58.771Z","updated_at":"2025-04-06T23:12:17.006Z","avatar_url":"https://github.com/ForNeVeR.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"XAML-Math\n=========\n\n*XAML-Math* is a collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and [Avalonia][avalonia] XAML-based frameworks.\n\n- For WPF, use NuGet package [WPF-Math][nuget-wpf]: [![NuGet][badge-nuget-wpf]][nuget-wpf]\n- For Avalonia, use [Avalonia-Math][nuget-avalonia]: [![NuGet][badge-nuget-avalonia]][nuget-avalonia]\n\nWPF-Math supports the following .NET variants:\n- .NET Framework 4.6.2 or later\n- .NET 6 or later\n\nAvalonia-Math supports:\n- .NET Framework 4.6.2 or later\n- .NET Standard 2.0 or later\n- .NET 6 or later\n\nA part of XAML-Math independent of the UI frameworks is published on NuGet as [XAML-Math Shared Code][nuget-xaml]: [![NuGet][badge-nuget-xaml]][nuget-xaml]\n\nGetting Started\n---------------\n\nThe simplest way of using *XAML-Math* is to render a static formula in a XAML file as follows.\n\n```xml\n\u003c!-- WPF --\u003e\n\u003cWindow … xmlns:controls=\"clr-namespace:WpfMath.Controls;assembly=WpfMath\"\u003e\n    \u003ccontrols:FormulaControl Formula=\"\\left(x^2 + 2 \\cdot x + 2\\right) = 0\" /\u003e\n\u003c/Window\u003e\n\n\u003c!-- Avalonia --\u003e\n\u003cWindow … xmlns:controls=\"clr-namespace:AvaloniaMath.Controls;assembly=AvaloniaMath\"\u003e\n    \u003ccontrols:FormulaBlock Formula=\"\\left(x^2 + 2 \\cdot x + 2\\right) = 0\" /\u003e\n\u003c/Window\u003e\n```\n\nFor a more detailed sample, check out the [example project][example]. It shows the usage of data binding and some advanced concepts.\n\n![Screenshot of example project](docs/example-screenshot.png)\n\n### Using the rendering API\n\nThe following example demonstrates usage of `TexFormula` API to render the image into a PNG file using the `RenderToPng` extension method:\n\n```csharp\nusing System;\nusing System.IO;\nusing WpfMath.Parsers;\nusing WpfMath;\nusing XamlMath.Exceptions;\n\nnamespace ConsoleApplication2\n{\n    internal class Program\n    {\n        public static void Main(string[] args)\n        {\n            const string latex = @\"\\frac{2+2}{2}\";\n            const string fileName = @\"T:\\Temp\\formula.png\";\n\n            try\n            {\n                var parser = WpfTeXFormulaParser.Instance;\n                var formula = parser.Parse(latex);\n                var pngBytes = formula.RenderToPng(20.0, 0.0, 0.0, \"Arial\");\n                File.WriteAllBytes(fileName, pngBytes);\n            }\n            catch (TexException e)\n            {\n                Console.Error.WriteLine(\"Error when parsing formula: \" + e.Message);\n            }\n        }\n    }\n}\n```\n\nNote that `XamlMath.TexFormulaParser::Parse` may throw a `XamlMath.Exceptions.TexException` if it was unable to parse a formula.\n\nIf you need any additional control over the image format, consider using the extension methods from the `WpfTeXFormulaExtensions` class:\n\n```csharp\nusing System;\nusing System.IO;\nusing System.Windows.Media.Imaging;\nusing WpfMath.Parsers;\nusing WpfMath.Rendering;\nusing XamlMath;\n\nconst string latex = @\"\\frac{2+2}{2}\";\nconst string fileName = @\"T:\\Temp\\formula.png\";\n\nvar parser = WpfTeXFormulaParser.Instance;\nvar formula = parser.Parse(latex);\nvar environment = WpfTeXEnvironment.Create(TexStyle.Display, 20.0, \"Arial\");\nvar bitmapSource = formula.RenderToBitmap(environment);\nConsole.WriteLine($\"Image width: {bitmapSource.Width}\");\nConsole.WriteLine($\"Image height: {bitmapSource.Height}\");\n\nvar encoder = new PngBitmapEncoder();\nencoder.Frames.Add(BitmapFrame.Create(bitmapSource));\nusing (var target = new FileStream(fileName, FileMode.Create))\n{\n    encoder.Save(target);\n    Console.WriteLine($\"File saved to {fileName}\");\n}\n```\n\nYou may also pass your own `IElementRenderer` implementation to `TeXFormulaExtensions::RenderTo` method if you need support for any alternate rendering engines.\n\nDocumentation\n-------------\n\n- [Changelog][docs.changelog]\n\n- [Color support in XAML-Math][docs-colors]\n- [Matrices and Matrix-Like Constructs][docs-matrices]\n- [Environments (`\\begin` and `\\end`)][docs.environments]\n- [How to improve blurred formulas][docs-blurred-text-issue]\n\n- [How to prepare `DefaultTexFont.xml` from the font file][docs-prepare-font]\n\n- [Licensing history][docs-licensing-history]\n\n- [Maintainership][docs.maintainership]\n\nBuild and Maintenance Instructions\n----------------------------------\n\nBuild the project using [.NET SDK 7.0][dotnet-sdk] or later. Here's the build and test script:\n\n```console\n$ dotnet build XamlMath.All.sln --configuration Release\n$ dotnet test XamlMath.All.sln\n```\n\nTo approve the test results if they differ from the existing ones, execute the `scripts/approve-all.ps1` script using PowerShell or PowerShell Core.\n\nTo publish the package, execute the following command:\n\n```console\n$ dotnet pack XamlMath.All.sln --configuration Release\n```\n\nHistory\n-------\n\nThe library was originally ported from the [JMathTex project][jmathtex], copyright 2004-2007 Universiteit Gent. The port was originally named *WPF-TeX* and was written and maintained by [Alex Regueiro][alex-regueiro]. It was later available as [*WPF-Math* on Launchpad][launchpad], but was unmaintained from 2011 until it 2017, when was revived in [its current form][github].\n\nIn 2023, after adding the Avalonia support, the *WPF-Math* project was renamed to *XAML-Math*.\n\nLicense Notes\n-------------\n\nThe project code and all the resources are distributed under the terms of [MIT license][license].\n\nThe [fonts][] `cmex10.ttf`, `cmmi10.ttf`, `cmr10.ttf`, and `cmsy10.ttf` and `cmtt10.ttf` are under the [Knuth License][knuth-license].\n\nThe font file `jlm_msam10.ttf` ([taken from JLaTeXMath project][jlatexmath.fonts]) is licensed under the [Open Font License][docs.open-font-license].\n\nXAML-Math (named *WPF-Math* at the time) started as a direct port of [JMathTeX][jmathtex] project written in Java, reusing both code and resources. JMathTeX is distributed under the terms of GNU GPL v2 license. XAML-Math, being a derived work, has a permission from JMathTeX authors to be redistributed under the MIT license. See the [Licensing history][docs-licensing-history] for the details.\n\nWe're very grateful to JMathTeX authors for their work and allowing to redistribute the derived library. JMathTeX is written by:\n- Kris Coolsaet\n- Nico Van Cleemput\n- Kurt Vermeulen\n\n[docs-blurred-text-issue]: docs/blurred-text-issue.md\n[docs-colors]: docs/colors.md\n[docs-licensing-history]: docs/licensing-history.md\n[docs-matrices]: docs/matrices.md\n[docs-prepare-font]: docs/prepare-font.md\n[docs.changelog]: ./CHANGELOG.md\n[docs.environments]: docs/environments.md\n[docs.maintainership]: ./MAINTAINERSHIP.md\n[docs.open-font-license]: fonts/LICENSES.md\n[example]: src/WpfMath.Example/\n[fonts]: fonts/\n[jlatexmath.fonts]: https://github.com/opencollab/jlatexmath/tree/af77a8e80d41ff67dfe2f42f14b41f6860dfeeec/jlatexmath/src/main/resources/org/scilab/forge/jlatexmath/fonts/maths\n[license]: LICENSE.md\n\n[alex-regueiro]: https://github.com/alexreg\n[avalonia]: https://avaloniaui.net/\n[dotnet-sdk]: https://dotnet.microsoft.com/download\n[github]: https://github.com/ForNeVeR/xaml-math\n[jmathtex]: https://jmathtex.sourceforge.net/\n[knuth-license]: https://ctan.org/license/knuth\n[launchpad]: https://launchpad.net/wpf-math\n[msbuild]: https://github.com/Microsoft/msbuild\n[nuget-avalonia]: https://www.nuget.org/packages/AvaloniaMath/\n[nuget-wpf]: https://www.nuget.org/packages/WpfMath/\n[nuget-xaml]: https://www.nuget.org/packages/XamlMath.Shared/\n\n[badge-nuget-avalonia]: https://img.shields.io/nuget/v/AvaloniaMath.svg\n[badge-nuget-wpf]: https://img.shields.io/nuget/v/WpfMath.svg\n[badge-nuget-xaml]: https://img.shields.io/nuget/v/XamlMath.Shared.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffornever%2Fxaml-math","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffornever%2Fxaml-math","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffornever%2Fxaml-math/lists"}