fontspec icon indicating copy to clipboard operation
fontspec copied to clipboard

add optical bounds to fontspec

Open ousia opened this issue 7 years ago • 12 comments

@wspr, I wonder whether opbd could be implemented in fontspec.

the OpenType feature “optical bounds” has been implemented recently in ConTeXt.

Here you have a sample that shows the feature:

\definefontfeature[default][default][protrusion=yes,opbd=yes]
\setupbodyfont[ebgaramond, 150pt]
\setupalign[hanging]
\showframe
\starttext
     \input tufte
\stoptext

The previous sample requires a recent beta from the ConTeXt Suite.

Could optical bounds be implemented in fontspec with LuaTeX?

As far as I know, opbd invokes both lfbd and rtbd. And it also requires protrusion to be enabled.

ousia avatar Mar 06 '17 21:03 ousia

I mostly limit fontspec’s interface to loading of font features. So yes, I can definitely make opbd etc available with a “friendly” name, but I would rely on others to setup the actual protrusion settings. (But happy also to add hooks to fontspec to facilitate this.)

wspr avatar Mar 06 '17 22:03 wspr

@wspr, I see. Further asking in the LuaLaTeX mailing list.

ousia avatar Mar 07 '17 06:03 ousia

I tried out the example with a current context minimals but I can't see what the option is supposed to do - the output with and without the option looks the same to me.

u-fischer avatar Mar 12 '17 16:03 u-fischer

@u-fischer, many thanks for your reply.

I have another sample with exaggerated values:

\showframe
\definefontfeature[default][default][protrusion=quality, opbd=yes]
\definefontfamily[mainface][rm][TestOPBD]
\setupbodyfont[mainface, 60pt]
\setupalign[hanging]

\starttext
Ἠ\\Ἠ\\Ἦ\\ἯἯ
\stoptext

With opbd:

opbd-1

Without opbd:

opbd-1

ousia avatar Mar 12 '17 21:03 ousia

And where can one get the font you used?

u-fischer avatar Mar 12 '17 21:03 u-fischer

http://www.ousia.tk/TestOPBD-Regular.otf is the address.

I only edited a pair of glyphs (from capital eta) from GFS Baskerville with fontforge.

Of course, the values are exaggerated and the font isn’t intended for distribution. Not even all capital eta glyphs with diacritics have a lfbd value set.

BTW, other Greek capital glyphs with diacritics have “incorporated” the left bounds to the left side bearing (which is wrong). This means that only capital eta is free from this error.

ousia avatar Mar 12 '17 21:03 ousia

@u-fischer, any news on optical margins for LuaLaTeX?

ousia avatar Mar 15 '17 18:03 ousia

Pablo, would you be able to test your example font with plain XeTeX and LuaTeX+luaotfload? E.g. syntax like

\input luaotfload.sty\relax
\font\1=“EBGaramond-Regular.otf:+opbd” at 12pt\relax
\1 this is a test

If it works there then it’s easy for me to add the syntax to fontspec.

wspr avatar Mar 16 '17 11:03 wspr

Will, sorry because I was so stupid not to recognize what I already knew.

The following works in LuaTeX and (partially) in XeTeX from TL 2016:

\input ifluatex.sty
\ifluatex\input luaotfload.sty\fi
\font\1="TestOPBD-Regular:+lfbd,+rtbd"
\1 Ἠ

Ἠ\hfill Ἠ

Ἦ\hfill ὩὩ

ἯἯ\hfill ὩὩ
\bye

Output from ConTeXt (sorry, but I don’t know how to get a reasonable page size in plain TeX):

opbd-1

What I knew: opbd is handled by the application, not by the font (which provides both lfbd and rtbd, but no opbd).

To test both sides of optical margin, I added rtbd values to the font provided for testing at http://www.ousia.tk/TestOPBD-Regular.otf.

The partial failure in XeTeX is that rtbd doesn’t seem to work.

I’m not subscribed to the XeTeX mailing list. If you were, would you be so kind to report this issue there?

I guess an option name such as OpticalBounds or OpticalMargins might make sense here.

ousia avatar Mar 16 '17 18:03 ousia

@wspr, since you reported the issue more than two weeks ago and it is clear that XeTeX has to fix +rtbd, how about implementing optical bounds in fontspec right now?

I mean, if XeTeX is fixed, it will work fine with no further changes required in fontspec.

I’m asking for this, because some users would like to use it with LuaTeX.

If you allow me a final suggestion, I think we should have three options:

  • OpticalBounds: +lfbd,+rtbd

  • LeftBounds: +lfbd

  • RightBounds: +rtbd

I mean, it should be possible to enable left, right or both margins.

For example, optical bounds in polytonic Greek should be applied (according to some Greek typographical traditions) only in the left margin.

ousia avatar Apr 03 '17 19:04 ousia

No problem with adding them straight away, I’m just very pressed for time right now. I only just managed to push out a critical bug fix the other day and haven’t been able to spend any time on this, sorry.

My preference would be to have the naming more along the lines of

OpticalBounds = Left
OpticalBounds = Right
OpticalBounds = Both

Or something like that. Thoughts?

wspr avatar Apr 03 '17 23:04 wspr

@wspr, sorry, I thought you were waiting for XeTeX to fix rtbt before implementing any code.

Your preference looks fine to me. It is better than mine.

ousia avatar Apr 05 '17 05:04 ousia