8

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

Romain Picot
  • 6,730
  • 4
  • 28
  • 58
Yan King Yin
  • 1,743
  • 1
  • 19
  • 26
  • 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 07: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 07:59
  • You can look at it: http://tex.stackexchange.com/questions/2305/what-fonts-are-installed-on-my-box for a first idea – Romain Picot Nov 16 '15 at 08: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 08:06
  • 5
    Try fc-list :lang=zh – Thérèse Nov 16 '15 at 11:20

1 Answers1

9

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
zyy
  • 2,146
  • 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