I am using package xeCJK and I need to do a \setCJKmainfont{} command but I don't even know which fonts I have available on my system. I have quickly installed a bunch of Chinese fonts but I can't recall what I have installed...

  • If you use XeLaTeX or LuaLaTeX you can use every font install on your system. It's a lot, You should add what kind of TeX engine you use I think ;-) – Romain Picot Nov 16 '15 at 7:52
  • I'm using TexLive, and XeLatex. I need a way to see the fonts I have... I'm pretty sure I have the fonts installed, I just need a way to list them and try them systematically... – Yan King Yin Nov 16 '15 at 7:59
  • You can look at it: tex.stackexchange.com/questions/2305/… for a first idea – Romain Picot Nov 16 '15 at 8:01
  • Alright, I solved my problem anyway. I looked in /usr/share/fonts and found ukai.ttc, then I use /setCJKmainfont{ukai.ttc} and it worked. At first the error was because I didn't use full file-name with extension. – Yan King Yin Nov 16 '15 at 8:06
  • 5
    Try fc-list :lang=zh – Thérèse Nov 16 '15 at 11:20

To find out what Chinese font you have in your laptop, bring up the terminal and execute

fc-list :lang=zh-cn > chinese.txt

a text file named chinese.txt will be produced in current directory, with all Chinese font listed.

If a utf8 ignorance error is reported, run the following first

export LC_CTYPE="en_US.UTF-8"

Finally, if you feel like sorting the font names

fc-list :lang=zh-cn | awk -F ": " '{for (f = 2; f <= NF; ++f) { if (f != 2) {printf("%s", OFS);} printf("%s", $f)}; printf "\n"}' | sort -d > chinese.txt
  • How to use this command in the current directory and display only the font file name (with or without full path) ? – DevonDahon Jul 11 '19 at 10:23
  • @maxagaz What do you mean by current directory? I think this can be used in any directory. As for the displaying only the font name, I have updated in the answer. – zyy Jul 11 '19 at 19:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.