Commit d414e42
Round up embolden widths to avoid non-zero widths
With "tfmdata.mode = 2" (PDF stroke and fill), if you set
"tfmdata.width" to a non-zero integer, then the glyphs are stroked with
a line of that thickness; this is documented in the LuaTeX manual. If
you set "tfmdata.width" to zero, then the stroke width will be inherited
from the environment; this isn't documented anywhere, but it's somewhat
useful, and someone is probably relying on it. If you set
"tfmdata.width" to a non-zero value that rounds to zero, then you get
the same behaviour as if you set it to exactly zero; this is somewhat
surprising, since it means that in most cases, "tfmdata.width = 0.49"
produces much thicker glyphs than "tfmdata.width = 0.51". Example:
\input{luaotfload.sty}
\font\TestFontA={lmroman10-regular:embolden=0.000;} at 10.0pt
\font\TestFontB={lmroman10-regular:embolden=0.006;} at 10.0pt
\font\TestFontC={lmroman10-regular:embolden=0.005;} at 10.0pt
\def\Test#1{%
\par
{\tt\string#1}:
\pdfextension literal {10 w} #1 ooo
\pdfextension literal { 1 w} #1 ooo
\pdfextension literal { 0.00001 w} #1 ooo
}
\nopagenumbers
\Test\TestFontA (Expected)
\Test\TestFontB (Expected)
\Test\TestFontC (Weird!)
\bye
The LuaTeX engine developers aren't planning on fixing this
https://mailman.ntg.nl/archives/list/dev-luatex@ntg.nl/thread/7BRXFIAOVQDHMBZADBREXOV6YECYFHS3/
and this current behaviour is incompatible with XeLaTeX
https://tex.stackexchange.com/q/755049
so this commit modifies the "embolden" manipulator to check if the
computed stroke width is non-zero but would round to zero; if so, it
sets the stroke width to 1 instead. This ensures that the stroke width
will be inherited from an outer PDF group if and only if the embolden
factor is exactly zero.
An alternative (and simpler) solution would be to use "math.ceil" to
unconditionally rounds up the computed embolden width; this could
potentially cause backwards compatibility issues since this means that
half of all embolden values would now be 0.001pt thicker than before.
However, since this is applied only by the PDF renderer, this would not
affect line breaking.1 parent 45f7d14 commit d414e42
1 file changed
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
21 | 26 | | |
| |||
0 commit comments