3

I'm been testing the FakeSlant feature of the fontspec package. I have a question. The package documentation is not clear what the units are for the FakeSlant=# key=value parameter. My guess on the units based off testing is 1/100th of a degree, but I'm not confident about this honestly.

\setmainfont{Source Serif 4}[%Available for free on Google Fonts.
    Kerning=On%
    ,SlantedFont={Source Serif 4}
        ,SlantedFeatures={%
            Kerning=On%
            ,FakeSlant=0.18
            }
]

EDIT: Did some more testing. It looks like the FakeSlant parameter accepts values from -1 to 1 but I'm still unsure what those values mean exactly.

User23456234
  • 1,808

2 Answers2

2

Maybe I am wrong, but the slant value seems to be the tangens of the slanting angle. That is, if the font axis is slanted by x degrees (0 degrees meaning upright), the slant value would be tan(x). Thus, a slant value of 1 represents a slanting angle of 45 degrees (and a value of -1 an angle of -45 degrees).

Compare:

\documentclass[tikz]{standalone}
\usepackage{fontspec}
\setmainfont{Noto Serif}

\begin{document} \begin{tikzpicture}

\draw[red] (45:-0.5) -- (45:1);
\node at (45:0.5) 
    % tan(45deg) = 1
    {\addfontfeature{FakeSlant=1}I};

% subtraction from 90 degrees in order to make 0 degrees match upright
\draw[yellow] ({90-20}:-0.5) -- ({90-20}:1);
\node at ({90-20}:0.5) 
    % tan(20deg) = 0.36397
    {\addfontfeature{FakeSlant=0.36397}I};

\draw[blue] ({90-5}:-0.5) -- ({90-5}:1);
\node at ({90-5}:0) 
    % tan(5deg) = 0.08749
    {\addfontfeature{FakeSlant=0.08749}I};

\end{tikzpicture} \end{document}

enter image description here

2

Using the cm pdfliteral:

pdfliteral

MWE

pdftex

\protected\def\rbox#1{% \setbox0\hbox{{#1}}% \setbox2\hbox{% \special{pdf:literal q}% \special{pdf:literal -1 0 0 1 0 0 cm}\rlap{\copy0} \special{pdf:literal Q}}% \hbox to --1\wd0{\kern--1\wd0\box2\hss}% }

\rbox{abc $\mapsto $ xyz}

Text text text, $abc\mathbin{\rbox{ $\mapsto$}}xyz$, text text text. % note the space: >>\rbox{ $<<

\protected\def\rbox#1{% \setbox0\hbox{{#1}}% \setbox2\hbox{% \special{pdf:literal q}% \special{pdf:literal -1 0 -0.2 1 0 0 cm}\rlap{\copy0} \special{pdf:literal Q}}% \hbox to --1\wd0{\kern--1\wd0\box2\hss}% }

\rbox{abc $\mapsto $ xyz}

\protected\def\rbox#1{% \setbox0\hbox{{#1}}% \setbox2\hbox{% \special{pdf:literal q}% \special{pdf:literal -1 1 -0.2 4 0 -50 cm}\rlap{\copy0} \special{pdf:literal Q}}% \hbox to --1\wd0{\kern--1\wd0\box2\hss}% }

\rbox{abc $\mapsto $ xyz}

\bye

Substantive code adapted from Scale text (\scalebox) in Plain TeX/XeTeX to make it narrower via Left \mapsto arrow


Some sort of reference example could be useful:

example

MWE

pdftex

\vskip2ex%

\protected\def\rbox#1{% #1: % \setbox0\hbox{{abc}}% \setbox2\hbox{% \special{pdf:literal q}% \special{pdf:literal #1 cm}\rlap{\copy0}% \special{pdf:literal Q}% }% \hbox to --1\wd0{\kern1\wd0\box2\hss}% \vrule \vskip1ex% }

no change: \rbox{1 0 0 1 0 0 }

translate: \rbox{1 0 0 1 50 35 }

scaling: \rbox{2 0 0 0.5 0 0 }

scaling: \rbox{0.5 0 0 2 0 0 }

reflection: \rbox{1 0 0 -1 0 0 }

reflection: \rbox{-1 0 0 -1 0 0 }

reflection: \rbox{-1 0 0 1 0 0 }

skew: \rbox{1 0.5 0 1 0 0 }

skew: \rbox{1 0 0.5 1 0 0 }

skew: \rbox{1 0 -0.5 1 0 0 }

skew: \rbox{1 -0.5 -0.5 1 0 0 } % 1 tan-x tan-y 1 0 0

\vskip1ex rotation: \rbox{1 1 -1 1 0 0 }

rotation: \rbox{-1 -1 1 -1 0 0 }

\vskip1ex rotation: \rbox{0.86 0.5 -0.5 0.86 0 0 }%cos30 sin30 -sin30 cos30

\vskip1ex rotation: \rbox{0.98 0.21 -0.21 0.98 0 0 } % -12 degrees

\protected\def\rboxc{% \setbox0\hbox{{abc}}% \setbox2\hbox{% \special{pdf:literal q}% \special{pdf:literal 2 0 0 2 0 0 cm}%scale \special{pdf:literal 1 0 -0.5 1 0 0 cm}%skew \special{pdf:literal 0.86 0.5 -0.5 0.86 0 0 cm}%rotate \special{pdf:literal -1 0 0 1 0 0 cm}{\copy0}%reflect \special{pdf:literal Q}% }% \hbox to --1\wd0{\kern1\wd0\box2\hss}% \vrule \vskip1ex% }

combined:

\rboxc

\bye

Cicada
  • 10,129