-
Notifications
You must be signed in to change notification settings - Fork 13
Round up embolden widths to avoid non-zero widths #316
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
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} latex3#1 ooo
\pdfextension literal { 1 w} latex3#1 ooo
\pdfextension literal { 0.00001 w} latex3#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.
|
The behaviour will still be incompatible with XeLaTeX. It just won't be quite as horrible. Moreover, not only very small values don't work. Only integer values are respected, whereas XeTeX seems to treat this as a continuum. [But I agree that it is better to round to something than have the current behaviour. I just think the choices here are unfortunate.] |
Internally, only integer values work, but this is in units of 1/1000bp, which is small enough that it appears continuous. I would assume that XeTeX uses a similar representation, since it's fairly rare for TeX engines to use floating point. The default value of |
You are right. Sorry. I believed the OP. However, XeTeX appears to round e.g. \documentclass{article}
\usepackage{fontspec}
\setmainfont[FakeBold=0.001]{Latin Modern Roman}
\setsansfont[FakeBold=1]{Latin Modern Roman}
\setmonofont{Latin Modern Roman}
\begin{document}
\parindent=0pt
\rmfamily ABCDE (0.001)
\sffamily ABCDE (1)
\ttfamily ABCDE (N/A)
\end{document}compiled with XeLaTeX suggests that, if it is rounding, the engine treats |
|
As you just investigated all this: Could you also add as part of this PR a few sentences to the luaotfload documentation about which values of embolden make actually sense and what they roughly do? |
Sure, I'll add that in tomorrow. |
|
Ok, I've updated the documentation for the |
Thank you for taking the time to explain this. |



With
tfmdata.mode = 2(PDF stroke and fill), if you settfmdata.widthto a non-zero integer, then the glyphs are stroked with a line of that thickness; this is documented in the LuaTeX manual. If you settfmdata.widthto 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 settfmdata.widthto 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.49produces much thicker glyphs thantfmdata.width = 0.51. Example:The LuaTeX engine developers aren't planning on fixing this and this current behaviour is incompatible with XeLaTeX so this commit modifies the
emboldenmanipulator 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.ceilto 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.