I'm trying to write a file, that compiles both on windows and unix (I'm using the alpine-tinytex image, but the answer should be portable across *nix).
I would like to use the semi-bold fontface of the Inconsolata
google-font using XeLaTeX. For Windows I installed it manually, in Alpine, I used
apk add ttf-inconsolata
Using \newfontfamily\codefont{Inconsolata}
I can use the font in Unix, and even changing the weight to the standard variants (e.g. bold using \textbf{}
) but I'm unable to use semi-bold. All answers to enable non-standard weights (such as this or this seem to rely on loading a different sub-font.
I've tried
\newfontfamily\codefont{Inconsolata Semi Bold}
which doesn't work on Windows (font not found error).
\newfontfamily\codefont{Inconsolata SemiBold}
which works on Windows but fails on Linux with
Package fontspec Error: The font "Inconsolata SemiBold" cannot be found.
\newfontfamily\codefont{Inconsolata-SemiBold}
(which is the name of the ttf. variant according to the font's documentation)
which works on Windows but fails on Linux with kpathsea
stating:`
kpathsea: Running mktextfm Inconsolata-SemiBold
/home/appuser/.TinyTeX/texmf-dist/web2c/mktexnam: Could not map source abbreviation for Inconsolata-SemiBold.
/home/appuser/.TinyTeX/texmf-dist/web2c/mktexnam: Need to update ?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; ; nonstopmode; input Inconsolata-SemiBold
This is METAFONT, Version 2.7182818 (TeX Live 2020) (preloaded base=mf)
kpathsea: Running mktexmf Inconsolata-SemiBold
! I can't find file `Inconsolata-SemiBold'.
<*> ...; ; nonstopmode; input Inconsolata-SemiBold
which I think is the closest to a solution but still I seem to miss something.
Edit:
\newfontfamily\codefont{Inconsolata-SemiBold.ttf}
works on Windows but fails on Unix with:
kpathsea:make_tex: Invalid filename `[Inconsolata-SemiBold.ttf]/OT', contains '['
[...]
! Package fontspec Error: The font "Inconsolata-SemiBold" cannot be found.
[...]
! Font TU/Inconsolata-SemiBold.ttf(0)/m/n/10.95=[Inconsolata-SemiBold.ttf]/OT a
t 10.95pt not loadable: Metric (TFM) file or installed font not found.
<to be read again>
XXX.ttf
.ttf-inconsolata
package which only installs regular and bold versions. Thanks @UlrikeFischer!