0

Environment

  • OS: Arch Linux x86_64
  • Host: Windows Subsystem for Linux - Arch (2.0.9.0)
  • TEX: TinyTex

Purpose

I want to use Windows Fonts and ctex for Chinese writing. So I touch $HOME/.config/fontconfig/fonts.conf which includes the following:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <dir>/mnt/c/Windows/Fonts/</dir>
</fontconfig>

Run fc-cache -fv, and fc-list does show me Windows Fonts.

Question

when I run latexmk -pdf with the example below:

\documentclass[fontset=windows, UTF8]{article}
\usepackage{ctex}
\begin{document}
好
\end{document}

It reports the error:

Latexmk: This is Latexmk, John Collins, 31 Jan. 2024. Version 4.83.
No existing .aux file, so I'll make a simple one, and require run of *latex.
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex':  Reasons for rerun
Category 'other':
  Rerun of 'pdflatex' forced or previously required:
    Reason or flag: 'Initial setup'

------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex -file-line-error -halt-on-error -interaction=nonstopmode -synctex=1  -recorder  "test.tex"'
------------
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2023-11-01> patch level 1
L3 programming layer <2024-01-22>
(/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/size10.clo)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctex.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/l3kernel/expl3.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctexhook.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctexpatch.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/fix-cm.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/ts1enc.def)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/config/ctexopts.cfg) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/CJKutf8.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/generic/iftex/ifpdf.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/generic/iftex/iftex.sty)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/inputenc.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/CJK.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/mule/MULEenc.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/CJK.enc)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/base/fontenc.sty)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjkpunct/CJKpunct.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjkpunct/CJKpunct.spa)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/CJKspace.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.bdg) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctexspa.def)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/zhnumber/zhnumber.sty (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/zhnumber/zhnumber-utf8.cfg)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese.def (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/tools/indentfirst.sty) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/ctex-c5size.clo) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def)) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/config/ctex.cfg) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.enc) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.chr) (./test.aux) (/home/ausosa/.TinyTeX/texmf-dist/tex/latex/ctex/fd/c70rm.fd) (/home/ausosa/.TinyTeX/texmf-dist/tex/generic/ctex/zhmap/ctex-zhmap-windows.tex{/home/ausosa/.TinyTeX/texmf-var/fonts/map/pdftex/updmap/pdftex.map}{UGBK.sfd}{Unicode.sfd}) [1] (./test.aux) )
!pdfTeX error: pdflatex (file simsun.ttc): cannot open TrueType font file for reading
 ==> Fatal error occurred, no output PDF file produced!

Among wsl2 Automount options, the default umask is 022, So I do not know why pdflatex cannot open file for reading.

So What's the problem?

5
  • Welcome to TeX.SE!
    – Mensch
    Feb 12 at 7:35
  • well the first question is if you have the font. Do you have a tex system in "normal windows" where you can try without the additional complication of wsl and mounting? Feb 12 at 10:01
  • Yeah. simsun.tcc does exist in my Windows System. Exactly, it exists in C:/Windows/Fonts directory. In windows I also tried installing Tinytex and everything is good. But in wsl2 it cannot open the font file and I do not know why? As I use wsl2 very often so I want to figure it out.
    – aurora
    Feb 12 at 10:17
  • note you show a configuraton for fontconfig but that's not used by pdflatex or lualatex, only xelatex Feb 12 at 12:16

1 Answer 1

1

as it happens I installed a fresh texlive 2024 pretest in wsl2 this morning so the following is definitely the only change I needed to make so that your example ran and produces

enter image description here

Just modify

/usr/local/texlive/2024/texmf.cnf

(or more likely 2023 or wherever you installed texlive) to add settings so that it looks in the windows fonts directory

my file now looks like

% (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
%
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
%
TTFONTS = $TEXMFDOTDIR;$TEXMF/fonts/{truetype,opentype}//;$OSFONTDIR//:/mnt/c/windows/fonts

OPENTYPEFONTS = $TEXMFDOTDIR;$TEXMF/fonts/{opentype,truetype}//;$OSFONTDIR//:/mnt/c/windows/fonts

just adding :/mnt/c/windows/fonts to the two settings copied from /usr/local/texlive/2024/texmf-dist/web2c/texmf.cnf

2
  • you can also use fontset=fandol which works using texlive fonts so needs no customisation at all Feb 12 at 11:32
  • Thanks, it works. I did not know "fontconfig is not used by pdflatex or lualatex, only xelatex".Got it.
    – aurora
    Feb 12 at 12:39

You must log in to answer this question.

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