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

前端 未结 6 1860
情歌与酒
情歌与酒 2021-01-13 11:39

How can my app get a list of the True Type Fonts that are available on Linux.

Is there a standard directory where they are stored across different distributions? Or

6条回答
  •  情深已故
    2021-01-13 12:43

    I just did it using something called Pango which is used by GTK+. I found it by looking at the code for the linux 'Character Map' program (gucharmap). Here's 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

提交回复
热议问题