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
643 stars 103 forks source link

Support UTF8 #82

Closed abozanona closed 7 years ago

abozanona commented 7 years ago

Can you support UTF8 symbols? I can't add symbols from other languages than English!

ForNeVeR commented 7 years ago

Thanks for the report. That issue is definitely on the radar, see #35. In the meantime, please try to use \text{...} workaround as suggested in https://github.com/ForNeVeR/wpf-math/issues/35#issuecomment-282025947.

alexreg commented 7 years ago

Generally, the only symbols allowed in maths are the letters from the Latin, Greek, and occasionally Hebrew alphabets. Do we really need general support for other character sets?

ForNeVeR commented 7 years ago

Yes, we need (if possible). I'm using Cyrillic in my maths all the time :)

Yes, Cyrillic characters are sometimes used as actual math symbols and not only text annotations; some of the areas in my scientific field (computational electrodynamics) are full of those ПЯП = ЮЭ² and so on.

alexreg commented 7 years ago

Hmm, I see. I guess it's only something done in countries where Cyrillic is the ordinary script anyway... explains why we never see it in the West. I wonder if Chinese characters are used, even...

Even in Russia, Latin characters are more common though, right?

ForNeVeR commented 7 years ago

These are extremely rare in international papers, but they aren't uncommon in the local documentation (especially in government regulations and patent descriptions).

Also I have to translate these symbols myself when I'm writing papers for international journals, and that generally confuses everyone (both local and foreign reviewers, my teammates, myself).

Please note that in my experience TeX doesn't allow any non-standard characters outside of the \text{} blocks, so I'm not sure if we have to implement that as stated in #35. We'll probably need some additional research in that (e.g. how LuaTeX or XeTeX handles that; what about MathJAX, so on). We're open to suggestions.

abozanona commented 7 years ago

I tried to use \text{SOME TEXT HERE} but it didn't work Unknown symbol or command or predefined TeXFormula: 'text'

If it's not allowed to use symbols other than the standard ones, maybe you could declare an array of the positions of non-standard symbols in the equation so We can replace it in the string by \text{number of cats}

alexreg commented 7 years ago

Can you post exactly what you're doing? The \text{...} command works just fine for us!

abozanona commented 7 years ago

I've downloaded the WpfMath.dll file to my project from NuGet Manager V0.3.0, I'm using vb.net

Private Function ParseFormula(input As String) As TexFormula
    ' Create formula object from input text.
    Dim formula As TexFormula = Nothing
    Try
        txtEquation.ForeColor = Color.Black
        formula = Me.formulaParser.Parse(input)
    Catch ex As Exception
        txtEquation.ForeColor = Color.Red
    End Try

    Return formula
End Function

When I try to parse \text{abc} it gives me the exception Unknown symbol or command or predefined TeXFormula: 'text'

abozanona commented 7 years ago

I tried to type the same command on the application I downloaded from here and it gives me the same error image

alexreg commented 7 years ago

Try 0.3.1 for a start.

abozanona commented 7 years ago

I tried now to upgrade to 0.3.1 from NuGet manager but it didn't work either.

alexreg commented 7 years ago

Okay. @ForNeVeR can answer this hopefully. You've definitely set something up wrong on your end, however...

ForNeVeR commented 7 years ago

Well, it won't be an easy task. I've started the work in the branch, and currently I'm struggling with TexFontInfo. It seems that we'll need to somehow extract TexFontInfo from the real system fonts.

ForNeVeR commented 7 years ago

Well, guys, we have rudimentary support for UTF-8 now.

I wasn't able do everything in one go, so now new features in that direction will depend on our dear users' needs. Feel free to open new tickets regarding concrete features we lack.

As an example, this will now work:

\frac{\text{ЭЭ}}{\text{ЭЭ}_{2}}