alerque / libertinus

The Libertinus font family
Other
928 stars 57 forks source link

Extremely tight side bearings for nearly all italic letters in Libertinus Math #464

Open DJakov-beep opened 3 years ago

DJakov-beep commented 3 years ago

Hi, I am sorry, if I start to get annoying regarding Libertinus Math and its italic letters. But the more math text I create with it, the more I notice how extremely tight the sidebearings of nearly all Italic letters, in the roman and greek alphabet, are; maybe even some other symbols like brackets are affected. This issue (in case it really is one) becomes more evident, when comparing Libertinus Math to other Opentype Math Fonts like "Latin Modern Math", "Cambria Math", "Minion Math"... etc. Here a little example, created with the engine MS Word in Office 365 (but I guess, in other engines, such as LuaLaTeX or XeLaTeX it is similar; maybe someone could test it and confirm or reject what I am writing here ):

02_Side_Bearings_of_Italic_Letters

One can notice, how small e.g. the distance between a function and the brackets of its variables are, especially in comparison to other fonts. In general, the italic parts of the font (Libertinus Math) look very dense and compressed due to its sidebearings.

Now a critical question: Shouldnt the Italics of a Math Font always be wider than its text counterpart, in order to make Math- Text look harmonic and nice to read? An example of someone mentioning this is Johannes Küster, the creator of Minion Math, in one of his presentations (which are freee to download at his website typoma). He suggests, that "Math Italic should be 5- 10 % wider" than text italics, and more, that "each letter should be read as a single letter, not as part of a word". He gives this example with Minion Math: image

Well, in Libertinus Math it is even the opposite :( Whas it intended that way at the moments of its creation? Please feel free to correct me if Im wrong in my views, I am still a compete layman when it comes to font design and typography. Furthermore, I am not demanding a radical change here, I just want to suggest the topic as a future possible way of improving the apperance of the font.

DJakov-beep commented 3 years ago

Or does this phenomenon only occur with the particular engine, I am using (MS Word, Office 365) and it has nothing to do with the font itself?

ivo-s commented 3 years ago

Hi, after you submitting the issue #461, I realized that the problem is not only about omega, but the whole mathematical alphabet. Long story short, I need some time to think about it, tinker around, and come up with possible solutions, because the problem is more complicated.

I already reworked the side bearings of mathematical glyphs in #256. At that time, I took the TeX treatment of mathematical glyphs as the one true way, but MS Office seems to do things differently. Basicaly, every letter comes in a box that has a certain amount of space on the left and right (side bearings). Because italic letters are slanted, this would not work very well when writing words, so the letters actually "lean out" to the right, beyond their boxes. In order not to collide with upright glyphs, there is an additional parameter for each letter called italics correction, which can be added on the right side to compensate for the leaning out. That way, combinations like tH should not clash together.

In a math font, one does not need to form readable words with nice inter-letter spacing, because such combinations are just products. That is why Johannes Küster's example is correct. However, while TeX always applies italics correction, the right-side bearing is not relevant by itself. MS Office, on the other hand, seems not do to so, which creates unpleasant spacing. This is the core of the problem, because I didn't take this into acount.

In #256, it seems I left the italics correction alone and only adjusted the side bearings to fix the TeX output. This probably needs rethinking. At a quick glance, STIX Math seems to rely mostly in bearings alone, and italics corrections are very minor. It would make sense that, whatever the typesetting engine does with italics correction, the output should look consistent.

I will also have to look into kerning, because there seems to be math{dflt} instead of latn{dflt} relevant for the mathematical letters, which I didn't notice before.

On a side note, things like const. should use text glyphs (and so, likely a text font), not mathematical glyphs U+1DXXX. But it still doesn't change the problem.

DJakov-beep commented 3 years ago

Hi Ivo,

first of all, thanks a lot you for your thorough explanations, they made the font- design- terminology much clearer. I really appreciate your commitment, despite of this issue neither affecting you nor the vast majority of people who use Libertinus Math, as Office Math is not very popular in the (academic) world of Mathematics, Physics and IT.

If I understood you correctly, the solution of the problem consists of adjusting the right side bearings (and to some degree also the kerning) for the whole mathematical alphabet of Libertinus Math, in order to compensate for the lack of italic correction in MS Office? That sounds like a lot of work. Additionally, would it be an option to contact the Office Math development team - e.g. Murray Sargent - and ask what is going on with their implementation of the italic correction (in case it is not documented anywhere publicy)?

As long as this issue remains, I guess Office Math Users typing Math formatted in Libertinus Math can use spacing commands like \thinsp or \hairsp in order to imitate the spacing needed for products.

As I do not know in which stage the fix of this issue currently is, I'd like to ask you, how I should proceed regarding the issue's status. Am I supposed to close the issue or should it remain opened until a fix is in reach?

By the way, I am grateful also for you sharing your Phd- Thesis via GitHub. It is interesting (additionally to its physics content) to see a beautifully typeset real world document using the Libertinus font (beautiful, even compared to many other LaTeX- created documents). Just by imitating it's typographic features, like margin widths, aligned in justification, line spacing, etc. (and taking into consideration a few basic typographical rules for text and maths), a MS Word- user was able to improve the appeareance of his documents so dramatically, that it becomes fairly difficult to distinguish them from LaTeX- created documents.

Best Wishes.

ivo-s commented 3 years ago

I am fairly confident that this is not MS Office's fault, and it should be fixed. The bearings used to be quite off, then I fixed them in a certain way, but with my current knowledge, I believe it needs to be redone. The italic correction helps with upright glyphs such as brackets, but there is no font rule that italic correction must always be applied unconditionally. When I look at other mathematical fonts, the bearings and italic corrections are set much more neatly. Unfortunately, I cannot see any universal pattern that would allow an algorithmic change.

So the current status is that I look at the fonts from time to time and try to come up with a guideline for fixing the problem. The easy part would probably be that cases like brackets should remain as they are now, but the balance between the side bearings and italic correction needs to be adjusted somehow. This issue should definitely stay open. Currently I am not able to commit much time to contributing here, and I have not been active here for the past couple of months. But that does not mean this issue should be closed. Many things here need fixing, it's just that the more tricky ones take longer :-) Right now I cannot promise anything, and most likely the issue will not be resolved within couple of weeks.

If anyone feels like they could tackle this, I guess the good practice would be to let others now they are working on it and check the Network graph for potentially active forks. Alternatively, I would also appreciate any guidance from typographers.

I am glad that you like the thesis template. I cannot claim that it is typographically correct, but I had fun tweaking it :-) Also remember that the easiest way to fool TeX people is to switch to Latin Modern in MS Word :smiling_imp:

DJakov-beep commented 3 years ago

Alright then, under these circumstances this issue shall remain open for a while ... :) Should I adjust the title in order to describe the problem more accurately? Maybe you have some reasonable suggestions?

I understand that you cannot promise anything. Every little improvement is much appreciated, whenever it comes and finds it's way.

I am not sure if any experienced typographer or (math) font designer is caring about Libertinus Math, seeing this issue or reading our conversation. I guess if guidance or advice is needed, one could ask some font designers, who have already created and perfected other Opentype Math Fonts over the course of the last decade(s) for advice about the finetuning between bearings and italic corrections. Have you already looked something up in font- design- literature or papers regarding this topic? Maybe the solution or relevant principles were already described somewhere in detail. Through asking one could possibly get a hint to relevant literature as well. People who come into my mind, are e.g. the GUST group, who have developed the Latin Modern font and the TeX Gyre Font Family, or Mr. Küster behind Minion Math. Certainly there are many more experienced people who know which detailes are relevant for solving the issue.

Thanks for the suggestion. Yes, at some points I noticed the worshipping of Computer Modern/ Latin Modern in the TeX community as well (no judgement on my part).

Firestar-Reimu commented 1 year ago

Same problem on Xelatex/Lualatex here after a year and a half:

This is Libertinus Screenshot_20220820_002849

\documentclass{article}
\usepackage{unicode-math}
\usepackage{libertinus}
\begin{document}
\[
    \frac{1}{2}\partial_i (A_i^2 + A_j^2 + A_k^2) = A_i \partial_i A_i + A_j \partial_i A_j + A_k \partial_i A_k
\]
\end{document}

Also: Screenshot_20220820_010532 The kerning is very tight and weird

This is Libertine Screenshot_20220820_004439

\documentclass{article}
\usepackage[libertine]{newtxmath}
\begin{document}
\[
    \frac{1}{2}\partial_i (A_i^2 + A_j^2 + A_k^2) = A_i \partial_i A_i + A_j \partial_i A_j + A_k \partial_i A_k
\]
\end{document}

Screenshot_20220820_010615

juhaszp95 commented 1 year ago

Further to the above (I think this is related), there are cases where characters come very close to, or indeed collide. Here's an MWE (compiled in LuaLaTeX):

\documentclass[12pt]{article}
\usepackage{libertinus-otf}

\begin{document}    
    $\langle d \rangle \langle N \rangle x^{E_N - E} \mathrm{d}t \mu_c R_r a f\Big(x\Big) \left. c \right\rvert$
\end{document}

The output is: image

Note also the strange kerning inside the parantheses. Maybe @alerque has a view on this?

Firestar-Reimu commented 1 month ago

@juhaszp95 what about on XeLaTeX?

image

which looks good,

but on LuaLaTeX:

image

maybe you can check this:

https://tex.stackexchange.com/questions/697498/luatex-unicode-math-and-italic-correction

Firestar-Reimu commented 1 month ago

image

This is STIX 2, we can see that although it is not very well kerned on lualatex, it looks much better than libertinus.

\documentclass[12pt]{article}
\usepackage{unicode-math}
\setmathfont{Libertinus Math}
\usepackage{fontspec}
\setmainfont{Libertinus Serif}
\usepackage{physics2}
\usephysicsmodule{ab,op.legacy,ab.legacy}
\usepackage{fixdif,derivative}

\begin{document}
    $\langle d \rangle \langle N \rangle x^{E_N - E} \mathrm{d}t \mu_c R_r a f\Big(x\Big) \left. c \right\rvert$

    $\ab<d> \ab<N> x^{E_N - E} \d{t} \mu_c R_r a f\ab\Big(x) \eval{c}$
\end{document}