Skip to content

Instantly share code, notes, and snippets.

@dohyunkim
Last active April 1, 2024 13:26
Show Gist options
  • Save dohyunkim/2079c4edd9b2bf19dee3cbdffb0df77a to your computer and use it in GitHub Desktop.
Save dohyunkim/2079c4edd9b2bf19dee3cbdffb0df77a to your computer and use it in GitHub Desktop.
\documentclass{article}
\usepackage{fontspec,xcolor,luamplib}
\setmainfont{tex gyre pagella}
\directlua{
local function ol(f,_,v)
v = tonumber(v) or 3
v = v * f.size / 6578.176 % 3 means 0.3pt when using 10pt font
f.width = v
f.mode = 1
end
fonts.constructors.features.otf.register {
name = 'outline',
description = 'outline glyphs',
manipulators = {
base = ol,
node = ol,
plug = ol,
}
}
}
\newfontfeature{outline}{outline\ifx\empty#1\empty\else=#1\fi}
\ExplSyntaxOn
\NewDocumentCommand\drawoutline{ O{3} m +m }
{
\color_group_begin:
\addfontfeature{outline=#1}
\color_stroke:n { #2 }
#3
\color_group_end:
}
\NewDocumentCommand\filldrawoutline{ O{3} m m +m }
{
\color_group_begin:
\addfontfeature{FakeBold=#1}
\color_fill:n { #2 }
\color_stroke:n { #3 }
#4
\color_group_end:
}
\ExplSyntaxOff
\begin{document}
\drawoutline{red!50!yellow}
{\Huge Lorem ipsum dolor sit amet,}
\bigskip
\filldrawoutline[2.5]{red!50!yellow}{blue}
{\Huge Lorem ipsum dolor sit amet,}
\begin{mplibcode}
beginfig(1)
draw btex
\addfontfeature{FakeBold=3}
Lorem ipsum dolor sit amet
etex
scaled 2
rotated 15
withcolor 1
withprescript "MPlibOverrideColor=1 .5 0 rg 0 0 1 RG";
endfig;
\end{mplibcode}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment