How to get a list of installed True Type Fonts on Linux using C or C ++?

How can my application get a list of True Type fonts available on Linux.

Is there a standard directory in which they are stored in different distributions? Or some other standard way to find them?

+6
c ++ c linux fonts true-type-fonts
source share
6 answers

I think fontconfig is the right way to do this. Take a look at the wikipedia article or fontconfig hompage .

+4
source share

I just did it using something called Pango, which is used by GTK +. I found it by looking at the linux 'Character Map' (gucharmap) program code. Here is the basic idea:

PangoFontFamily **families; ... pango_context_list_families ( gtk_widget_get_pango_context (GTK_WIDGET (notebook)), &families, &fontCount); printf("%d fonts found\n", fontCount); for(i=0; i<fontCount; i++) { printf("[%s]\n", pango_font_family_get_name (families[i])); } 
+3
source share
+2
source share

Not relevant, but you can use fontmatrix show everything and there is a preview (yum -y install fontmatrix)

enter image description here

+1
source share

If you are not writing proprietary software or any other licensed software that is not compatible with the GPL, you can try looking at the xlsfonts code to find out how to request a font server. (The font server may be X itself, but that doesn't matter.)

0
source share

If you use a high-level toolkit such as GTK + or Qt, it might be better for you. if not, fontconfig is the de facto way to do this.

0
source share

All Articles