ForNeVeR / xaml-math

A collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and Avalonia XAML-based frameworks
MIT License
637 stars 100 forks source link

Changing font has no effect #408

Closed seghier closed 1 year ago

seghier commented 1 year ago

Hi I change font in

var pngBytes = formula.RenderToPng(20.0, 0.0, 0.0, "Algerian");

But i don't see any change, why?

And can you add support for thin font like this one

image

ForNeVeR commented 1 year ago

Please give the example of the formula you are rendering using this code.

Note that this system font setting only applies to the text section of the formula (i.e. when you use the text{ … } command). Math section can only use hardcoded fonts for now, because the font metrics are impossible to extract automatically for now.

(I'll open a separate feature request, and we'll think of auto-expanding the metrics system to work with any text in formulas later, if your request is about that part; but, to figure that out, we need a formula example.)

seghier commented 1 year ago

Thank you Any simple formula for example:

\begin{align} x+1 &= y + 1 \\ x &= y-1 \end{align}

\binom{n}{k} = \frac{n!}{k!(n-k)!}

f(x) = \cases{1/3 & \mathrm{if} \thinspace 0\le x\le 1;\cr 2/3 & \mathrm{if} \thinspace 3\le x \le 4; \cr 0 & 
\mathrm{elsewhere.}\cr}

I already create two plugins to use them in Rhinoceros 3D and Grasshopper, and i hope if there is a way to export the formula as svg or at least adding support for thin font, because create vector (svg or dxf) from thin font is easier in Rhino

image

ForNeVeR commented 1 year ago

For this formula, you can try something like this:

\text{f(x)} = \cases{\text{1/3} & \text{if 0 ≤ x ≤ 1;} \\
\text{2/3} & \text{if 3 ≤ x ≤ 4;} \\
\text{0} & \text{elsewhere.}}
ForNeVeR commented 1 year ago

So, I've opened a feature request #411 and found a bug #412 while typing that formula.

This request I consider as answered for now, but feel free to ask any additional questions!