Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion doc/luaotfload-main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,32 @@
\endaltitem

\beginaltitem {embolden}
A factor, defined as a decimal number.
A factor, defined as a decimal number. This fakes a bold font by
stroking the glyph outlines with an outline of a constant width. This
is typographically not ideal, but can give acceptable output when the
factor and is rendered correctly by the PDF viewer. However, many PDF
viewers---most notably Chrome---completely misrender the effect at low
zoom levels, so you should only use this feature on fonts typeset at
large sizes, if you know for certain which PDF viewers will be used to
view the document, or if you're printing to paper.

\identifier{luaotfload} defines the \identifier{embolden} feature to
give the same results as the same feature in \XeTeX, so its definition
is rather obscure: internally, the \identifier{embolden} parameter is
divided by~10, multiplied by the font size in \TeX{} points
(\verb|pt|), and then directly written to the PDF file as the stroke
width (therefore treating \TeX{} points as PostScript points
(\verb|bp|)). As an additional feature not present in \XeTeX, if you
set the \identifier{embolden} parameter to exactly~0, \LuaTeX{} will
stroke the font without setting the stroke width, meaning that the
stroke width will be inherited from the outer PDF graphics state.

Setting \identifier{embolden} to values below~0.5 is only useful for
print documents, since many PDF viewers will always render the stroke
widths at some greater minimum value; setting \identifier{embolden} to
values above~20 is rarely useful since if the stroke overlaps with
itself, there will be significant visual artifacts. Useful values are
generally between~1 and~10.

For example

Expand Down
7 changes: 6 additions & 1 deletion src/luaotfload-embolden.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ assert(luaotfload_module, "This is a part of luaotfload and should not be loaded
local otffeatures = fonts.constructors.newfeatures "otf"

local function enableembolden(tfmdata, _, embolden)
tfmdata.mode, tfmdata.width = 2, tfmdata.size*embolden/6578.176
tfmdata.mode = 2
local width = math.round(tfmdata.size*embolden/6578.176)
if width == 0 and embolden ~= 0 then
width = 1
end
tfmdata.width = width
end

otffeatures.register {
Expand Down