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

  1. \newfontfamily\codefont{Inconsolata Semi Bold}

which doesn't work on Windows (font not found error).

  1. \newfontfamily\codefont{Inconsolata SemiBold}

which works on Windows but fails on Linux with

Package fontspec Error: The font "Inconsolata SemiBold" cannot be found.

  1. \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.


  1. \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>
  • typically with xelatex it is best to use the file name and not the font name, so XXX.ttf. Commented Mar 18, 2021 at 16:50
  • That gives another error @UlrikeFischer which hints that maybe the fontsize is wrong?
    – Dschoni
    Commented Mar 18, 2021 at 16:58
  • well is the font somewhere where xelatex finds it? And did you write the name correctly (linux is case sensitive). Commented Mar 18, 2021 at 17:22
  • Indeed the font is not on the system as it wasn't installed by the ttf-inconsolata package which only installs regular and bold versions. Thanks @UlrikeFischer!
    – Dschoni
    Commented Mar 19, 2021 at 8:22

1 Answer 1


I found a solution that is working for me and is portable across Windows and Unix.

I installed Inconsolata as a font from the packages. In ubuntu, apt-get install fonts-inconsolata installs the .otf version of the font - in e.g. alpine apk add ttf-inconsolata installs only the regular and bold weights of the font. There are several answers here on how to use different weights with .otf fonts, however none of them seem to be compatible with a .tex file that compiles under windows.

So, I manually installed the needed font variant (in my case Inconsolata-SemiBold.ttf) by copying both to /usr/share/fonts/TTF/Inconsolata-SemiBold.ttf as well as /usr/share/fonts/truetype/inconsolata/Inconsolata-SemiBold.ttf. This way I can directly choose the font or use it as the semi-bold variant of Inconsolata (e.g. inside listings) automatically.

For this to work, the fonts have to have the correct permissions (chmod 644) and the font-cache has to be updated (e.g. /usr/bin/fc-cache -fv).

Inside my .tex file both versions of


and e.g. using semi-bold inside lstlisting works on Windows and *nix.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .