Trying to understand how math font selection works

Hi,
In LO math, it seems we can use whatever font we have in our system,
but when the font doesn’t have the character or symbol that being used, LO math still return something.
Did LO choose a replacement from other font set, or they do something else?
I have read the manual (7.6), there is no explanation on this. I’m sorry if I miss something.

Simple example.:
on my system (Windows 10) is installed:
STIX Two text with 4 face: Regular, Italic, Bold, Bold Italic
STIX Two math with: Regular only.

So i thought i set all font (variables, number, etc,…) in LO math as STIX Two math (because its math).
For the variable, I set the italic → STIX Two math, Italic.
When writing a variable, there is no error, LO math returns something that I don’t how to reproduce it, in other software, because they don’t have italic of STIX two math, and I don’t know how LO create this variable (is it automatically replacing or what did they do?)

On the other hand, when I set the font variable in LO math as STIX two text, italic.
I can write a variable in LO math, and the result is reproducible (exactly the same) if i use other software with the same font+ italic (for example i use inkscape).

The background is most of the time it is important that to match the symbols/character/variable between what’s in the text (writer with LO math) and from the images or plot (using other software non LO).
I try to understand how this works in general.

Thank you.

Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 56f7684011345957bbf33a7ee678afaf4d2ba333
CPU threads: 12; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (en_GB); UI: en-US
Calc: threaded

Your description is a bit obscure.


Writer and Math have not the same way to format things. Writer is strongly based on styles while in Math you choose which font and variant to use for various contexts in Format>Fonts.

What happens when the requested font face and variant doesn’t exist is a two-tiered process.

in Tools>Options, you can define a substitution table to request a given face for another one. Note that I use word “face” only, meaning this substitution table will not allow you to replace only a variant (italic, bold, …).

The second step is in the OS, or rather its font renderer. The font renderer is capable to substitute on its own a font for a missing one. In the case of missing face, it has a dictionary of widely known faces to classify them as serif, sans or monospace. It will then take its preferred installed one within the family. If a variant is missing, it can generate dynamically some bold or italic variant according to some algorithm. The result is not aesthetically as appealing as with the real font but you get something anyway.

Going back to Math, its Format>Fonts dialog is rather rudimentary (Math has not evolved like the other components) in that bold and italic are check boxes leading to the suspicion it can’t always emit the right name for the variant (italic is also designated by oblique or slanted).

If I remember right, Math also returns an image of the formula, just in case Writer can use a fallback if some fonts become uninstalled in the future. Thus you can see the formula correctly but can’t use it for other purpose.

@ajlittoz . Sorry for my english. My question is only about LO math.
I use LO math as the symbol and equation inside Writer.
I don’t have issue with writer, but thank you.

Let’s just talk about LO math only from now on.
So responding to your paragraph “Going back to Math…”.
This rudimentary dialog box offers to use any font in my system and i can deliberately set the italic or bold, without the software (and me) knowing if that variant is available or not?
If that the case, LO math returns… a replacement font? based on which font? could you elaborate more “italic is also designed by oblique” → does it mean the LO make a character become italic and not taking from what’s inside the font?
In hypothetical case, let say i set a font (in LO math) which don’t have a symbol/character that will be used inside an LO math. This is hypothetical example, a font doesn’t have a greek character, but i accidentally use it as the LO math font, but i write an equation using a greek character. What will happen? I try to understand this…
is it the same process as you said “two-tiered” process?

Actually, i found this “rudimentary setting” can be very useful, there’s freedom to set the font, if one understand what happen.
For example: google docs math formula doesn’t allow change of font as per now. In MS word, it works differently. So… although LO math has not been evolve for long time… it still have some advantages. Of course i hope for improvement.

I don’t have issue with LO math as image…
Thank you.

The font name you select is necessarily present on your computer because the menu is built from the installed font list. But Math does not check if bold, italic or bold+italic variants are present. It blindly requests the font+variant you chose. What happens next is the responsibility of the OS font renderer. This is done silently and I suppose Math doesn’t even get a notification a substitution occurred.

This is a different issue. Presently Unicode can potentially contain 16×64k characters, out of which ~150k are allocated. It is obvious that no single font offers all these glyphs. When the font renderer discovers that a font has not the requested character, it looks for a font providing it. It will first choose from the same “family” (serif, sans, monospace, …) before looking for an unrelated face.

The main issue here is the returned character could have a totally different metrics (taller or thinner, wider or narrower, space around) than your desired font resulting in jagged line.

This is exactly the discussion (and information) that i needed. Thank you.
If i may draw first conclusions:
Font selection in LO math may mislead us, because they (LO) don’t check if a variant available or not.
One has to check by themselves or has the priory knowledge of the font being used, which is not an easy task for beginner.
I think this is one thing that LO math has to improve.
Although i’m not sure the developer will get this message.
I accidentally notice this in LO, because in other software either they don’t allow this to happen (Inkscape) or they allow but give something that we can notice there’s a mixing font/replacement (word, latex in python-Matplotlib).

About the Unicode, is this the reason we have math-font set such as Cambria Math, STIX two math, TeX Gyre DejaVu Math?

Math is quite outdated in its founding principles. I believe the general service predates Unicode and certainly the gigantic overhaul on font management which happened in the last two decades. Unfortunately, a formula editor is considered a minor secondary feature. If you look at questions on AskLO, you see that major concern is with Calc, then Writer, finally Impress. Draw maintains itself at some constant “background” activity. Base is gaining interest. But Math is considered as an accessory for specialised “academic papers” and don’t get much attention. However, for developers’ defence, I’d say that a good crystal-clear relevant specification for renewal is not available. And most academics will turn to LaTeX which offers premium quality.

The “preferred” math-font is OpenSymbol. Math implictly relies on it for drawing operators. Consequently, this font is implicitly installed with LO. This doesn’t preclude you from chosing another font for variables, function names, … but integral sign, product or summation will always be drawn in OpenSymbol.

If you can produce a good specification for next-generation Math, feel free to do so. I’d be personally interested in reading in and I’d back up and support it eventually. Several of us, e.g. @Lupp, long for some evolution of Math. But we’re growing really old to participate in development.

Yes, I think it is true for most physicist/mathematician (or closer to that).
For academic who is more to experimentalist & engineers, WYSIWYG is still the norm, and especially who uses Linux. It really depends on the community/group/lab where he/she works.

I will open a new question about this, because it turns out i don’t understand it enough, the docs doesn’t explain it enough.

How to do this? is there a guide/example to prapare such thing?
I think that LO writer is good, LO math needs improvement of course.
If it can help, i will try.

Due to age and long retired from my profession as a teacher, I’m no longer a frequent user of the Math component of “our software”. I’m still interested, however, in a sense.
A few (only 8) years ago I even posted a related question with the intention to “answer” it myself making an offer: There was a bait trying to initiate development. See How to get better scalable bracket?, tdf#32362, and tdf#39750.
As far as I can tell, the only recent improvement (announced for 2024-02-DD) to Math was to enable it to create formulas shown in RTL mode, and using Arabic sripts.

Let’s hope the author will also start a revival of Math regarding the old bugs.

BTW: Do you know the TexMaths extension. I’m not any longer eager to study LaTeX for the purpose, but I’m interested in examples.

See also: tdf#101174 (it will be possible to choose fonts other than OpenSymbol in v24.2).

Thanks to Khaled Hosny.

Eager to learn if there will also be an OpenSymbol font then allowing a smart scaling of square and curly brackets.

yes, i know. I don’t prefer to use this. I used a lot of inline-equation in my text and the LO math provides ‘faster’ approach for me.

So these operators, how to set the font? is it in function/variable/ custom fonts in the LO math font selection? It seems not yet implemented in the current version…

If you not yet read it this ask thread may be of interst for you. My contribution there also contains some links to different related threads.

I’m afraid any really sustainable layouter for mathematical formulas will need to do a lot in a similar way as TexMath does it. If this can also offer support for existing Math formula syntax or what automatic conversions can be implemented, I can’t tell.
… …
Taking the risk again to open the horizon, I would suggest thinking about whether we (the worlds math users of today) should make a visual representation of mathematics developed centuries ago the standard for the millennia to come. For example: We are still suffering from an approximately 3500 year old decision to divide by the sexagesimal system. Let’s learn from it. …

1 Like

Hi all,

Mr. Lupp, Thank you for pointing those informations.

I will summarize this information and give some pointer for future development.
LO writer is really good, I am now writing my PhD thesis using Writer (+ a lot of LO math within it).

It is a pity LO math is not actively updated as Writer did.
But I really hope.

If i have ability as developer, i would help, but i don’t have (i know python only).
Perhaps i can help with manual and giving some guidelines.

The work of Khaled Hosny looks promising.

best regards,
Tetuko

You could then also consider writing your thesis in Jupyter notebook format!
https://jupyter-notebook.readthedocs.io/en/stable/ui_components.html

LaTEX | Mathjax equations
you may also use matplotlib, numpy and sympy in that »Environment«

Math isn’t bad, however. It just isn’t quite “state of the art” currently.

If your concept of “inline formula” is as I would understand it, you may be interested in the attached example demonstrating the automatic conversion (rendering) of inline formulas to Math OLE objects.

(No. The example is not written in Python. It’s too provisional for that noble language.)
nextExampleMathInlineFormulas.odt (38.7 KB)

Thank you.
Currently, I’m not considering making any extreme switch.

I completely agree.

I think I have read your post previously perhaps more than once, thank you for the sharing the file.
To be honest, I have not tried it myself because i still don’t know Macro and has not got the time to learn it. But definitely one thing that I will try in my spare time.

@ajlittoz @Lupp @mikekaganski
Thank you very much for all the inputs.

I try to sum up our discussion. Here is what I got:

  1. Font issue as in this post: LO should be able to detect if a variant of a font is not available. At least let the user know about it. Although I prefer LO math does not allow selection of unavailable variant.
    Reason: it is misleading, especially for beginners. Not allowing will also “educate” the user, such as myself in this case.

  2. It is convenient to use math-object for all math-variable in the text (as inline eqn) because it provides consistency everywhere in the text and not affected by style of the paragraph. For example a variable %alpha_1, i will use LO-math throughout the text, even tough it is possible to use symbol alpha and subscript 1.
    I think it is the norm nowadays, as the other authors do the same.

So the ability to change all LO-math font & font size in the text at the same time should be there, without the need of extension or macro. A basic need.

Note: Word-math also has issue with this. In theory was easy, but when there’s a lot of equations it is not easy to change font all together, and I have to check and change one by one. The LO math extension actually works better in this case.

Below are more “imaginary” and probably more work to it. It is related to what @Lupp post.

  1. LO math is outdated compared to Word’s and Google Docs’s math because it returns an image and was designed as a separate app.

One advantage of LO math is that we can always edit the code, which is impossible in Word and Gdocs after the equation is printed. You can only write math in using code once in the beginning.

I imagine to return non-image formula would be a very far future project.
But to be able to go back on forth to the formula editor is the key here.
How to make it more straightforward, would be useful for text using plenty of formulas.

Instead of opening LO-math each time we write/edit a formula in writer, why not keep the formula-editor there inside the writer, for example in a special mode “math-mode”. Every time the text cursor is next to the math object (image), we can see the code appear in the formula-editor, then we can press something to be automatically in the formula-editor or back to text.

I don’t have enough knowledge on this matter.
The auto-scaling of inline-formula in Latex (as far as i remember) and Word works pretty well, for example when you write a fraction in inline-formula. I guess this is not possible when LO math still returns an image.
But we should go to this direction.

If you think, I should post a request/bug in the bugZilla. (if one of those ideas is good enough). Please let me know.

Let me dream aloud (I am not a developer).


Designing formulas in a separate app is certainly a good thing. That this separate app looks integrated in Writer (and other LO components) is only a matter of implementation and user interaction procedure (designed in the GUI).


I do agree that it would be nice to control visual/typographic aspects from within Writer. This is where I begin to dream awake. The basic tool for this in Writer is styles. So, the right track would be to implement a new style category for Math, as feature-rich and versatile as those in Writer. To make things easy, this new style should be configured in Math (so that it is also available in the other components Calc, Impress, Draw, …). When the Math object is imported into Writer, its styles are also imported. Then Writer should be extended to be able to interpret the Math styles.


In this scheme, you still need to go to Math to modify your styles (because it is easier than modifying all components to interact with Math styles, unless of course developers can find a way to share the Math styles code).


There is also another needed feature: referencing Math objects. As an example, take your %alpha_1 single-variable formula. If it is interspersed in text in multiple locations, I’d like it to be a reference to a single object, so that if I need to change it to %beta_n I do it only once and all occurrences are changed simultaneously.


To make this dream come true, we need a solid rigorous specification coexisting peacefully with ODF.

1 Like