issue with optical bounds (OpenType)
Dear list, I’m experiencing a weird issue with optical bounds in OpenType. Here you have the mandatory sample (font avaiable at https://gitlab.com/ousia/greek-lfbd/raw/master/TypographicaOStandard-Regular...): \startluacode fonts.handlers.otf.addfeature { name = "leftbounds", type = "single", data = { Ἀ = { -32, 0, -32, 0 }, Ἁ = { -32, 0, -32, 0 }, Ἂ = { -70, 0, -70, 0 }, Ἃ = { -70, 0, -70, 0 }, Ἄ = { -50, 0, -50, 0 }, Ἅ = { -50, 0, -50, 0 }, Ἇ = { -42, 0, -42, 0 }, Ἆ = { -42, 0, -42, 0 }, Ἠ = { -212, 0, -212, 0 }, Ἡ = { -212, 0, -212, 0 }, Ἢ = { -258, 0, -258, 0 }, Ἣ = { -258, 0, -258, 0 }, Ἥ = { -286, 0, -286, 0 }, Ἤ = { -286, 0, -286, 0 }, Ἦ = { -246, 0, -246, 0 }, Ἧ = { -246, 0, -246, 0 }, Ὧ = { -196, 0, -196, 0 }, } } \stopluacode \enabletrackers[fonts.protrusion] \definefontfeature[default][default] [script=greek, protrusion=quality, opbd=yes] \definefontfeature[leftbounds][leftbounds=yes] \showframe \setuplayout[page] \definefontfamily[mainface][rm][Typographica Old Standard] \definefontfamily[mainface][tt][Latin Modern Mono] \setupbodyfont[mainface, 300pt] \setupalign[hanging] \startbuffer \ifnum\pagenumber=1{\ttxx opbd}\else{\ttxx -opbd}\fi\page Ω\\ Ὧ\\ Α\\Ἀ\\Α\\Ἁ\\Α\\Ἂ\\Α\\Ἃ\\Α\\Ἄ\\Α\\Ἅ\\Α\\Ἆ\\Α\\Ἇ\\ Ἠ\\Η\\Ἡ\\Η\\Ἢ\\Η\\Ἣ\\Η\\Ἤ\\Η\\Ἥ\\Η\\Ἦ\\Η\\Ἧ\\Η \stopbuffer \starttext \getbuffer \setupalign[nothanging] \feature[+][leftbounds] \getbuffer \stoptext OpenType optical bounds are read from the font right: fonts > protrusions > left factor 1, right factor 1 fonts > protrusions > setting left using lfbd fonts > protrusions > lfbd -> 0.032 Ἀ (U+01F08) fonts > protrusions > lfbd -> 0.032 Ἁ (U+01F09) fonts > protrusions > lfbd -> 0.070 Ἂ (U+01F0A) fonts > protrusions > lfbd -> 0.070 Ἃ (U+01F0B) fonts > protrusions > lfbd -> 0.050 Ἄ (U+01F0C) fonts > protrusions > lfbd -> 0.050 Ἅ (U+01F0D) fonts > protrusions > lfbd -> 0.042 Ἆ (U+01F0E) fonts > protrusions > lfbd -> 0.042 Ἇ (U+01F0F) fonts > protrusions > lfbd -> 0.196 Ὧ (U+01F6F) fonts > protrusions > lfbd -> 0.246 Ἧ (U+01F2F) fonts > protrusions > lfbd -> 0.286 Ἦ (U+01F2E) fonts > protrusions > lfbd -> 0.246 Ἥ (U+01F2D) fonts > protrusions > lfbd -> 0.258 Ἤ (U+01F2C) fonts > protrusions > lfbd -> 0.286 Ἣ (U+01F2B) fonts > protrusions > lfbd -> 0.258 Ἢ (U+01F2A) fonts > protrusions > lfbd -> 0.212 Ἡ (U+01F29) fonts > protrusions > lfbd -> 0.212 Ἠ (U+01F28) I’m afraid that they aren’t applied accurately. The same values are used with the property "leftbounds" and they are perfect in that feature. Shouldn’t be the output from both methods be exactly the same? In all glyph pairs, both accented and unaccented glyphs should end in exactly the same point. I think this may be a bug, although I may be missing something. Many thanks for your help, Pablo -- http://www.ousia.tk
On 12/7/2018 7:54 PM, Pablo Rodriguez wrote:
Shouldn’t be the output from both methods be exactly the same? maybe you need to choose a script and/or language
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 12/7/18 8:15 PM, Hans Hagen wrote:
On 12/7/2018 7:54 PM, Pablo Rodriguez wrote:
Shouldn’t be the output from both methods be exactly the same?
maybe you need to choose a script and/or language
Many thanks for your reply, Hans. I modified the font myself and the Greek script is required and selected (with the Latin script, that OT opbd property doesn’t work at all). The issue is that, although opbd values are used, that results from opbd and from single placement in addfeature are different (although LuaTeX reports the same values for lfbd). Just in case it helps, Pablo -- http://www.ousia.tk
On 12/7/18 8:15 PM, Hans Hagen wrote:
On 12/7/2018 7:54 PM, Pablo Rodriguez wrote:
Shouldn’t be the output from both methods be exactly the same?
maybe you need to choose a script and/or language
Many thanks for your reply, Hans.
I modified the font myself and the Greek script is required and selected (with the Latin script, that OT opbd property doesn’t work at all).
The issue is that, although opbd values are used, that results from opbd and from single placement in addfeature are different (although LuaTeX reports the same values for lfbd). because you implement it as kerning and not as opbd (protrusion is not kerning) ... you can try to change the name to "lfbd" (if you would enable lfbd as feature for sure you would get funny kerning so opbd
On 12/7/2018 9:14 PM, Pablo Rodriguez wrote: picks up from those instead) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 12/7/18 11:25 PM, Hans Hagen wrote:
On 12/7/2018 9:14 PM, Pablo Rodriguez wrote:
[...] The issue is that, although opbd values are used, that results from opbd and from single placement in addfeature are different (although LuaTeX reports the same values for lfbd).
because you implement it as kerning and not as opbd (protrusion is not kerning) ... you can try to change the name to "lfbd" (if you would enable lfbd as feature for sure you would get funny kerning so opbd picks up from those instead)
If protrusion has to apply other values than the ones besides opbd, the values for optical bounds aren’t reliable for accurate glyph positioning. Sorry, but otherwise there is no need for optical margins in OpenType (standard protrusion would be all that is needed). Kerning might be selectively applied, such as in: \startluacode fonts.handlers.otf.addfeature { name = "leftbounds", type = "single", data = { Ἠ = { -212, 0, -212, 0 }, Ὧ = { -196, 0, -196, 0 }, } } \stopluacode \definefontfeature[default][default][protrusion=quality] \definefontfeature[leftbounds][leftbounds=yes] \setupfirstline [alternative=word, n=1, style={\feature[+][leftbounds]}] \showframe \setuplayout[page] \definefontfamily[mainface][rm][Typographica Old Standard] \definefontfamily[mainface][tt][Latin Modern Mono] \setupbodyfont[mainface, 300pt] \setupalign[hanging] \startbuffer «a\par «b\par Ω\par Ὧ\par Ἠ\par \stopbuffer \starttext \setupparagraphintro[each][\setfirstline] \getbuffer \stoptext At least to get Greek hanging diacritics, I think this is the way to go. It would be extremely useful to enable a \setuplineintro for verse. It would be also useful to have a function that substracts the width of two given glyphs. (This is exactly the amount to get hanging diacritics properly kerned.) Many thanks for your help, Pablo -- http://www.ousia.tk
On 12/9/2018 1:34 PM, Pablo Rodriguez wrote:
On 12/7/18 11:25 PM, Hans Hagen wrote:
On 12/7/2018 9:14 PM, Pablo Rodriguez wrote:
[...] The issue is that, although opbd values are used, that results from opbd and from single placement in addfeature are different (although LuaTeX reports the same values for lfbd).
because you implement it as kerning and not as opbd (protrusion is not kerning) ... you can try to change the name to "lfbd" (if you would enable lfbd as feature for sure you would get funny kerning so opbd picks up from those instead)
If protrusion has to apply other values than the ones besides opbd, the values for optical bounds aren’t reliable for accurate glyph positioning. Sorry, but otherwise there is no need for optical margins in OpenType (standard protrusion would be all that is needed).
Kerning might be selectively applied, such as in:
\startluacode fonts.handlers.otf.addfeature { name = "leftbounds", type = "single", data = { Ἠ = { -212, 0, -212, 0 }, Ὧ = { -196, 0, -196, 0 }, } } \stopluacode \definefontfeature[default][default][protrusion=quality] \definefontfeature[leftbounds][leftbounds=yes] \setupfirstline [alternative=word, n=1, style={\feature[+][leftbounds]}] \showframe \setuplayout[page] \definefontfamily[mainface][rm][Typographica Old Standard] \definefontfamily[mainface][tt][Latin Modern Mono] \setupbodyfont[mainface, 300pt] \setupalign[hanging] \startbuffer «a\par «b\par Ω\par Ὧ\par Ἠ\par \stopbuffer \starttext \setupparagraphintro[each][\setfirstline] \getbuffer \stoptext
At least to get Greek hanging diacritics, I think this is the way to go. It would be extremely useful to enable a \setuplineintro for verse.
It would be also useful to have a function that substracts the width of two given glyphs. (This is exactly the amount to get hanging diacritics properly kerned.) you confuse mechanism:
- protrusion only happen at the start and end of the line - kerning (like single does) happens everywhere so, you need to extend "lfbd" and not use some own kerning feature "leftbounds" which applyu it everywhere while "lfbd" is treated special i.e. sets the protrusion values (when "opbd" is enabled) ... no other way to do this Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 12/9/18 2:22 PM, Hans Hagen wrote:
[...] you confuse mechanism:
- protrusion only happen at the start and end of the line - kerning (like single does) happens everywhere
so, you need to extend "lfbd" and not use some own kerning feature "leftbounds" which applyu it everywhere while "lfbd" is treated special i.e. sets the protrusion values (when "opbd" is enabled) ... no other way to do this
In that case, I have some questions: -Is it possible to enable standard protrusion with opbd? (I mean, I don’t any other character protruded when opbd is enabled.) -Is there any way that I can apply pure raw lfbd/rtbd values to protrusion with no other protrusion calculation at all in opbd? -In order to avoid editing all the Greek fonts to get hanging diacritics: is there any way to replicate the lfbd feature with "fonts.handlers.otf.addfeature"? Many thanks for your help, Pablo -- http://www.ousia.tk
On 12/9/2018 5:35 PM, Pablo Rodriguez wrote:
On 12/9/18 2:22 PM, Hans Hagen wrote:
[...] you confuse mechanism:
- protrusion only happen at the start and end of the line - kerning (like single does) happens everywhere
so, you need to extend "lfbd" and not use some own kerning feature "leftbounds" which applyu it everywhere while "lfbd" is treated special i.e. sets the protrusion values (when "opbd" is enabled) ... no other way to do this
In that case, I have some questions:
-Is it possible to enable standard protrusion with opbd? (I mean, I don’t any other character protruded when opbd is enabled.)
well, you want to use what the font provides and if the font is incomplete i'd not trust the bits that are there either when opbd is enabled protrusion is taken from that so you should add all chars that you want to prodrude then in an addendum to is (k
-Is there any way that I can apply pure raw lfbd/rtbd values to protrusion with no other protrusion calculation at all in opbd?
you can create your own vectors if you want
-In order to avoid editing all the Greek fonts to get hanging diacritics: is there any way to replicate the lfbd feature with "fonts.handlers.otf.addfeature"?
probably with some lua magic one can do a lot but these are typical things i do when i need them (also because one needs to check the whole of unicode and cook up categories, this kind of stuff is: do it all robust and well or don't do it; also one doesn't know how consistent font designs are) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 12/9/18 6:53 PM, Hans Hagen wrote:
On 12/9/2018 5:35 PM, Pablo Rodriguez wrote:
[...] -Is there any way that I can apply pure raw lfbd/rtbd values to protrusion with no other protrusion calculation at all in opbd?
you can create your own vectors if you want
My own vectors wouldn’t solve the issue, because the variable would be: lfbd(Ὧ) = glyph.width(Ω) - glyph.width(Ὧ) I need to place glyphs accurately, not characters. Character dimensions wouldn’t help to get hanging diacritics.
-In order to avoid editing all the Greek fonts to get hanging diacritics: is there any way to replicate the lfbd feature with "fonts.handlers.otf.addfeature"?
probably with some lua magic one can do a lot but these are typical things i do when i need them (also because one needs to check the whole of unicode and cook up categories, this kind of stuff is: do it all robust and well or don't do it; also one doesn't know how consistent font designs are)
The variable is so simple that the glyph with diacritical marks should be placed in the beginning of the line as it had no such marks. If the font has all glyphs for uppercase letters with the same width for the letter strokes, a general approach (such as the menttioned above, I guess it) would work. Many thanks for your help, Pablo -- http://www.ousia.tk
On 12/9/2018 8:54 PM, Pablo Rodriguez wrote:
On 12/9/18 6:53 PM, Hans Hagen wrote:
On 12/9/2018 5:35 PM, Pablo Rodriguez wrote:
[...] -Is there any way that I can apply pure raw lfbd/rtbd values to protrusion with no other protrusion calculation at all in opbd?
you can create your own vectors if you want
My own vectors wouldn’t solve the issue, because the variable would be:
lfbd(Ὧ) = glyph.width(Ω) - glyph.width(Ὧ)
I need to place glyphs accurately, not characters. Character dimensions wouldn’t help to get hanging diacritics.
well, these dimensions are available so one could use them in constructing additional lfbd feature specifications (add f eatures runtime)
-In order to avoid editing all the Greek fonts to get hanging diacritics: is there any way to replicate the lfbd feature with "fonts.handlers.otf.addfeature"?
probably with some lua magic one can do a lot but these are typical things i do when i need them (also because one needs to check the whole of unicode and cook up categories, this kind of stuff is: do it all robust and well or don't do it; also one doesn't know how consistent font designs are)
The variable is so simple that the glyph with diacritical marks should be placed in the beginning of the line as it had no such marks.
the mechanism is more complex: the linebreak algorithm has to take this into account (both ends of a potential line) and also look over e.g. par starts and so Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 12/10/18 10:51 AM, Hans Hagen wrote:
On 12/9/2018 8:54 PM, Pablo Rodriguez wrote:
[] My own vectors wouldn’t solve the issue, because the variable would be:
lfbd(Ὧ) = glyph.width(Ω) - glyph.width(Ὧ)
I need to place glyphs accurately, not characters. Character dimensions wouldn’t help to get hanging diacritics.
well, these dimensions are available so one could use them in constructing additional lfbd feature specifications (add f eatures runtime)
Many thanks for your reply, Hans. In order to modify the fonts, it would be helpful to have a function that can substract two glyph widths of a given font, such as: function document.hanging_diacritics(char_one, char_two) return (char_one.glyphwidth - char_two.glyphwidth) end I don’t have any idea about how to do it. This way I don’t have to calculate the value for each glyph feature and I can simply add the values to the font. BTW, what kind of specifications you think can be constructed for the lfbd feature (sorry, but I don’t get it). Many thanks for your help, Pablo -- http://www.ousia.tk
participants (2)
-
Hans Hagen
-
Pablo Rodriguez