YuanshengZhao / Garamond-Math

An OTF math font matching the EB Garamond.
SIL Open Font License 1.1
104 stars 6 forks source link

feature request: sub/superscripts #5

Open itzsimpl opened 6 years ago

itzsimpl commented 6 years ago

Is there a way perhaps to create a closer match between the math sub/superscripts and text sub/superscripts (RawFeatures=+sinf and RawFeatures=+sups, see also package realscripts) that are included in both the original Georg Duffner's EB Garamond, https://github.com/georgd/EB-Garamond, as well as Octavio Pardo's version, https://github.com/octaviopardo/EBGaramond12). By closer match I mean size, alignment and weight.

stone-zeng commented 6 years ago

I think you are from https://github.com/josephwright/siunitx/issues/339.

IMHO, the unit expression is a specific kind of math expression. If there are no math expressions, the sub/superscripts in Unicode should be enough and I think it's a better choice to use them; if there are math formulas in your article (maybe it's your case), however, to keep all sub/superscripts in same shapes should be better.

Another thing is that Unicode sub/superscripts only support 1-level sub/superscripts (no superscripts of superscripts). If the Unicode sub/superscripts are used in math mode ,they may be too small.

Personally, I don't want to change the design of the original EB Garamond. Anyway, @YuanshengZhao will add a feature to support it if you like :)

stone-zeng commented 6 years ago

By the way, you may find that the Unicode sub/superscripts in EB Garamond italic is actually slant version. I believe you will not accept them in math mode.

itzsimpl commented 6 years ago

You found me ;)

The two issues, although related, are different. Meaning, that for siunitx, when confined to just text (e.g. if one writes a document without any mathematical equations), in my opinion, it would be a nice feature to allow for the use of unicode sub/superscripts, as these were designed by the font designer so that they do not interfere much with the text block's greyness.

The math font is a different ball game. Georg Duffner's EB Garamond was not designed as a math font. It is true that a feature request was done quite some time ago (georgd/EB-Garamond#8), but up until your version came along one had to resort to loading specific subsets using unicode-math (at least in XeLaTeX). Kudos for doing it. From this point of view, I would also suggest that, to avoid confusion (as there are many versions of the Garamond typeface) you rename your font to EBGaramond Math.

What I am saying also is, that since you are working on it, you might consider revising also the math sub/superscripts (via a combination of copying glyphs from Duffner's 8pt font, the ssty and other TeX parameters). As far as I know, the sizing and placement of sub/superscripts in math is based on CM fonts, but EB Garamond differs from CM in x-height and its relation to ascenders and descenders and there are of course differences in placement that will arise due to the algorithm TeX uses for placement of math sub/superscripts. However, IMHO when confined to single level sub/superscripts it would be neat to strive for a similar output both in text and math. Especially for text that includes math (so that the grayness of the textblock is maintained. Help of a professional font designer (which I am not) would be handy of course, but IMHO the existing unicode sub/superscripts may be the best thing one can extend upon.

I have to admit, that since the first posting of the feature request I came to realize that what I am trying to do is much more complex than I initially though.

The closest I am able to come to what I want with a 12pt type is by calling:

\setmathfont[
    Path=fonts/Garamond-Math/, 
    StylisticSet=1, 
]{Garamond-math.otf} % base math font
\setmathfont{EBGaramond12-Regular.otf}[ % override rm to include optical size fonts
    Path=fonts/EBGaramond/,
    range=\mathup/{num,latin,Latin,greek,Greek}, 
    Ligatures={TeX},
    Numbers={Lining}, % force lining numbers for math
    Script=Latin, % force the use of Latin script (suppresses fontspec warning 'Math'->'Latin' script)
    SizeFeatures={ % optical sizes, this overrides (s)script-font/-features
        {Size=-8, Font={EBGaramond08-Regular.otf}, Numbers={Lining}}, % force lining numbers for (s)scripts
        {Size= 8-, Font=*}
    }
]
\DeclareMathSizes{12.045}{12.045}{7.02625}{6.0225}
\check@mathfonts

and \setlength\subsupersep{.5pt}

image

See the above figure (the second MATH paragraph is with changed math sizes). You will notice that in the second paragraph (i.e. first MATH) the text block grayness is perturbed more so than in the others. I still have to discover how one could reduce the size of the first level scripts only when in \textstyle (and/or for equations with just first level scripts). The issue is that due to the low x-height the second level scripts quite quickly become illegible.

YuanshengZhao commented 6 years ago

@itzsimpl I have found out that adding the feature of super/subscripts with better matching with text itself is not that difficult. However, there are many glyphs missing:

BTW, because many glyphs in Octavio Pardo's version are different from those in Georg Duffner's version, lowercase Greek letters for example, I do not think mixing these up to be a good idea.

The current solution to script size is using a "interpolated" glyph between normal and heavier weights (you can find that the script is a little bit heavier than normal), but the shape of glyph is not changed at all (usually the small-sized glyphs are made wider). Although this is not a good solution in general, it is able to make formulas much more readable.