我一直在测试FakeSlant
该软件包的功能fontspec
。我有一个问题。软件包文档没有明确说明FakeSlant=#
key=value 参数的单位。根据测试,我猜测单位是 1/100 度,但老实说,我对此没有信心。
\setmainfont{Source Serif 4}[%Available for free on Google Fonts.
Kerning=On%
,SlantedFont={Source Serif 4}
,SlantedFeatures={%
Kerning=On%
,FakeSlant=0.18
}
]
编辑:做了一些测试。看起来该FakeSlant
参数接受从-1
到的值1
,但我仍然不确定这些值的确切含义。
答案1
也许我错了,但倾斜值似乎是倾斜角度的切线。也就是说,如果字体轴倾斜X度(0 度表示直立),倾斜值为 tan(X)。因此,倾斜值 1 表示倾斜角度为 45 度(而倾斜值 -1 表示倾斜角度为 -45 度)。
比较:
\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}
答案2
使用cm
pdfliteral:
平均能量损失
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
实质性代码改编自在 Plain TeX/XeTeX 中缩放文本(\scalebox)使其变窄通过 左 \mapsto 箭头
某些参考示例可能会有用:
平均能量损失
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