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

前端 未结 6 1811
情歌与酒
情歌与酒 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:26

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

    0 讨论(0)
  • 2021-01-13 12:30

    If you aren't writing proprietary software, or any other licensed software that's incompatible with GPL, you could try looking at the code to xlsfonts to see how to query the font server. (The font server could be X itself, but it won't matter.)

    0 讨论(0)
  • 2021-01-13 12:32

    If you're using a high-level toolkit like GTK+ or Qt, there's probably a better function to do it for you; if not, fontconfig is the de-facto way to do it.

    0 讨论(0)
  • 2021-01-13 12:37

    try a function called 'XListFonts'

    http://tronche.com/gui/x/xlib/graphics/font-metrics/XListFonts.html

    0 讨论(0)
  • 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<fontCount; i++)
      {
        printf("[%s]\n", pango_font_family_get_name (families[i]));
      }
    
    0 讨论(0)
  • 2021-01-13 12:44

    Not relevent but you can use fontmatrix shows all and there preview (yum -y install fontmatrix)

    enter image description here

    0 讨论(0)
提交回复
热议问题