我在 Linux(openSuse Tumbleweed)下运行已完全更新的 TeXlive 2023。
我正在研究可变字体(请参见此处:递归字体、多个轴、fontspec、texlive 2022)我从下载了可变字体https://fonts.google.com/specimen/Geologica,文件名为 Geologica-VariableFont_CRSV,SHRP,slnt,wght.ttf。我将其重命名为Geologica-VariableFont.ttf
。
我正在尝试写一行文本,其中每个字符都比上一个字符稍微粗一些。 MWE:
\documentclass{article}
\usepackage{fontspec}
%\usepackage[ngerman]{babel}
\setmainfont{Geologica-VariableFont.ttf}[
Renderer=HarfBuzz,
% ItalicFont=Geologica-VariableFont.ttf,
% BoldFont=Geologica-VariableFont.ttf,
% BoldItalicFont=Geologica-VariableFont.ttf,
% BoldFeatures={RawFeature={+axis={wght=500}}},
% ItalicFeatures={RawFeature={+axis={wght=250, slnt=-12, CRSV=1, SHRP=100}}},
% UprightFeatures={RawFeature={+axis={wght=250, SHRP=100}}},%
]
\newcommand{\Upwght}[2]{\addfontfeatures{UprightFeatures={RawFeature={+axis={SHRP=100,wght=#1}}}}#2}%
% \newcommand{\Itwght}[2]{\addfontfeatures{ItalicFeatures={RawFeature={+axis={CRSV=1,slnt=-12,SHRP=100,wght=#1}}}}#2}%
\begin{document}
%\LARGE
Hallo!
\Upwght{100}{U}%
\Upwght{120}{n}%
\Upwght{140}{g}%
\Upwght{160}{e}%
\Upwght{180}{h}%
\Upwght{200}{a}%
\Upwght{220}{l}%
\Upwght{240}{t}%
\Upwght{260}{e}%
\Upwght{280}{n}%
\Upwght{300}{e}
\Upwght{320}{R}%
\Upwght{340}{e}%
\Upwght{360}{d}%
\Upwght{380}{e}%
\Upwght{400}{n}
\Upwght{420}{u}%
\Upwght{440}{n}%
\Upwght{460}{g}%
\Upwght{480}{e}%
\Upwght{500}{h}%
\Upwght{520}{a}%
\Upwght{540}{l}%
\Upwght{560}{t}%
\Upwght{580}{e}%
\Upwght{600}{n}%
\Upwght{620}{e}%
\Upwght{640}{r}
\Upwght{660}{F}%
\Upwght{680}{r}%
\Upwght{700}{a}%
\Upwght{750}{u}%
\Upwght{800}{e}%
\Upwght{900}{n}
\end{document}
如果我注释掉最后六个字母,它就可以正常工作。但是这里的 MWE 停止了:
> Running `LaTeX' on `230715-Geologica-experimente' with ``lualatex-dev
> -file-line-error --synctex=1 -interaction=nonstopmode 230715-Geologica-experimente.tex'' This is LuaHBTeX, Version 1.17.0
> (TeX Live 2023) restricted system commands enabled.
> (./230715-Geologica-experimente.tex LaTeX2e <2023-11-01> pre-release-0
> (develop 2023-8-12 branch) L3 programming layer <2023-08-11>
> (/local/texlive/2023/texmf-dist/tex/latex-dev/base/article.cls
> Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
> (/local/texlive/2023/texmf-dist/tex/latex-dev/base/size10.clo))
> (/local/texlive/2023/texmf-dist/tex/latex/fontspec/fontspec.sty
> (/local/texlive/2023/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
> (/local/texlive/2023/texmf-dist/tex/latex/l3kernel/expl3.sty
> (/local/texlive/2023/texmf-dist/tex/latex/l3backend/l3backend-luatex.def)))
> (/local/texlive/2023/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
> (/local/texlive/2023/texmf-dist/tex/latex-dev/base/fontenc.sty)
> (/local/texlive/2023/texmf-dist/tex/latex/fontspec/fontspec.cfg)))
> (./230715-Geologica-experimente.aux)
> (/local/texlive/2023/texmf-dist/tex/latex-dev/base/ts1cmr.fd)realloc():
> invalid next size
>
> TeX Output abgebrochen (core dumped) at Sat Aug 12 14:02:43
该日志包含 28 个块,这里是 1 号:
Package fontspec Info: Font family 'Geologica-VariableFont.ttf(1)' created for
(fontspec) font 'Geologica-VariableFont.ttf' with options
(fontspec) [Ligatures=TeX,Renderer=HarfBuzz,UprightFeatures={RawFea
ture={+axis={SHRP=100,wght=100}}}].
(fontspec)
(fontspec) This font family consists of the following NFSS
(fontspec) series/shapes:
(fontspec)
(fontspec) - 'normal' (m/n) with NFSS spec.:
(fontspec) <->"[Geologica-VariableFont.ttf]:mode=harf;script=latn;l
anguage=dflt;+tlig;+axis={SHRP=100,wght=100};"
(fontspec) - 'small caps' (m/sc) with NFSS spec.:
然后是重量为120的2号:
Package fontspec Info: Font family 'Geologica-VariableFont.ttf(2)' created for
(fontspec) font 'Geologica-VariableFont.ttf' with options
(fontspec) [Ligatures=TeX,Renderer=HarfBuzz,UprightFeatures={RawFea
ture={+axis={SHRP=100,wght=100}}},UprightFeatures={RawFeature={+axis={SHRP=100,
wght=120}}}].
(fontspec)
(fontspec) This font family consists of the following NFSS
(fontspec) series/shapes:
(fontspec)
(fontspec) - 'normal' (m/n) with NFSS spec.:
(fontspec) <->"[Geologica-VariableFont.ttf]:mode=harf;script=latn;l
anguage=dflt;+tlig;+axis={SHRP=100,wght=100};+axis={SHRP=100,wght=120};"
(fontspec) - 'small caps' (m/sc) with NFSS spec.:
这是日志文件的结尾:
Package fontspec Info: Font family 'Geologica-VariableFont.ttf(28)' created
(fontspec) for font 'Geologica-VariableFont.ttf' with options
(fontspec) [Ligatures=TeX,Renderer=HarfBuzz,UprightFeatures={RawFea
ture={+axis={SHRP=100,wght=100}}},UprightFeatures={RawFeature={+axis={SHRP=100,
wght=120}}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=140}}},UprightFea
tures={RawFeature={+axis={SHRP=100,wght=160}}},UprightFeatures={RawFeature={+ax
is={SHRP=100,wght=180}}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=200}
}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=220}}},UprightFeatures={Ra
wFeature={+axis={SHRP=100,wght=240}}},UprightFeatures={RawFeature={+axis={SHRP=
100,wght=260}}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=280}}},Uprigh
tFeatures={RawFeature={+axis={SHRP=100,wght=300}}},UprightFeatures={RawFeature=
{+axis={SHRP=100,wght=320}}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=
340}}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=360}}},UprightFeatures
={RawFeature={+axis={SHRP=100,wght=380}}},UprightFeatures={RawFeature={+axis={S
HRP=100,wght=400}}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=420}}},Up
rightFeatures={RawFeature={+axis={SHRP=100,wght=440}}},UprightFeatures={RawFeat
ure={+axis={SHRP=100,wght=460}}},UprightFeatures={RawFeature={+axis={SHRP=100,w
ght=480}}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=500}}},UprightFeat
ures={RawFeature={+axis={SHRP=100,wght=520}}},UprightFeatures={RawFeature={+axi
s={SHRP=100,wght=540}}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=560}}
},UprightFeatures={RawFeature={+axis={SHRP=100,wght=580}}},UprightFeatures={Raw
Feature={+axis={SHRP=100,wght=600}}},UprightFeatures={RawFeature={+axis={SHRP=1
00,wght=620}}},UprightFeatures={RawFeature={+axis={SHRP=100,wght=640}}}].
(fontspec)
(fontspec) This font family consists of the following NFSS
(fontspec) series/shapes:
(fontspec)
(fontspec) - 'normal' (m/n) with NFSS spec.:
(fontspec) <->"[Geologica-VariableFont.ttf]:mode=harf;script=latn;l
anguage=dflt;+tlig;+axis={SHRP=100,wght=100};+axis={SHRP=100,wght=120};+axis={S
HRP=100,wght=140};+axis={SHRP=100,wght=160};+axis={SHRP=100,wght=180};+axis={SH
RP=100,wght=200};+axis={SHRP=100,wght=220};+axis={SHRP=100,wght=240};+axis={SHR
P=100,wght=260};+axis={SHRP=100,wght=280};+axis={SHRP=100,wght=300};+axis={SHRP
=100,wght=320};+axis={SHRP=100,wght=340};+axis={SHRP=100,wght=360};+axis={SHRP=
100,wght=380};+axis={SHRP=100,wght=400};+axis={SHRP=100,wght=420};+axis={SHRP=1
00,wght=440};+axis={SHRP=100,wght=460};+axis={SHRP=100,wght=480};+axis={SHRP=10
0,wght=500};+axis={SHRP=100,wght=520};+axis={SHRP=100,wght=540};+axis={SHRP=100
,wght=560};+axis={SHRP=100,wght=580};+axis={SHRP=100,wght=600};+axis={SHRP=100,
wght=620};+axis={SHRP=100,wght=640};"
(fontspec) - 'small caps' (m/sc) with NFSS spec.:
Package fontspec Info: Font family 'Geologica-VariableFont.ttf(29)' created
(fontspec) for f
如果我从第 29 个字母开始注释掉,它就会起作用。我可以改进什么?我猜罪魁祸首是我笨拙的命令:
\newcommand{\Upwght}[2]{\addfontfeatures{UprightFeatures={RawFeature={+axis={SHRP=100,wght=#1}}}}#2}%
答案1
您可以通过将\Upwght
命令替换为以下内容来避免这种情况:
\newcommand{\Upwght}[2]{{\addfontfeatures{UprightFeatures={RawFeature={+axis={SHRP=100,wght=#1}}}}#2}}%
这会在整个命令周围添加括号,确保新功能仅适用于参数,而不适用于整个剩余文档。这通常会使命令的行为更加直观(如果它适用于之后的所有内容,为什么还要接受参数?)并避免过多字体功能堆积的问题。