Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more concise way to generate the list font families #1

Closed
jdhao opened this issue May 9, 2017 · 2 comments
Closed

more concise way to generate the list font families #1

jdhao opened this issue May 9, 2017 · 2 comments

Comments

@jdhao
Copy link

jdhao commented May 9, 2017

After looking up the fontconfig manual, I find that you can generat a list of available font family in you system by using the following command:

fc-list -f "%{family[0]}\n" | sort |uniq

In my CentOS system, it generates the following output:

AR PL UMing CN
AR PL UMing HK
AR PL UMing TW
AR PL UMing TW MBE
Abyssinica SIL
Caladea
Cantarell
Carlito
Century Schoolbook L
Clean
DejaVu Sans
DejaVu Sans Mono
DejaVu Serif
Dingbats
Fixed
FreeMono
FreeSans
FreeSerif
Jomolhari
Khmer OS
Khmer OS Content
Khmer OS System
LKLUG
Liberation Mono
Liberation Sans
Liberation Serif
Lohit Assamese
Lohit Bengali
Lohit Devanagari
Lohit Gujarati
Lohit Kannada
Lohit Malayalam
Lohit Marathi
Lohit Nepali
Lohit Oriya
Lohit Punjabi
Lohit Tamil
Lohit Telugu
Madan2
Meera
NanumGothic
Nimbus Mono L
Nimbus Roman No9 L
Nimbus Sans L
Nuosu SIL
Open Sans
OpenSymbol
Overpass
PT Sans
PT Sans Narrow
Padauk
PakType Naskh Basic
STIX
Source Han Serif SC
Standard Symbols L
URW Bookman L
URW Chancery L
URW Gothic L
URW Palladio L
Utopia
VL Gothic
Waree
WenQuanYi Micro Hei
WenQuanYi Micro Hei Mono
WenQuanYi Zen Hei
WenQuanYi Zen Hei Mono
WenQuanYi Zen Hei Sharp

Then you don't need cut any more.

@danstoner
Copy link
Owner

Good tip.

On my systems the results had no line endings. The man fc-list man page has SEE ALSO section where I found the formatter help... FcPatternFormat(3).

https://linux.die.net/man/3/fcpatternformat

Adding a \n to the formatter does the trick.

fc-list -f "%{family[0]}\n" | sort | uniq

danstoner added a commit that referenced this issue May 10, 2017
The purpose of cut in the previous iteration of the fc-list command was to remove the commas and following portions of the font family name (localized name perhaps?).

Without it, we get output such as:

```
$ fc-list --format="%{family}\n" | sort | uniq | tail -n 1
WenQuanYi Micro Hei,文泉驛微米黑,文泉驿微米黑
```
With the field reference ```[0]``` we get:

```
$ fc-list --format="%{family[0]}\n" | sort | uniq | tail -n 1
WenQuanYi Micro Hei Mono
```

I missed this minor but important difference when first reading @jdhao's suggestion in issue #1.
@jdhao
Copy link
Author

jdhao commented May 10, 2017

Yes, I missed a \n in my original comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants