displayfonts.c

来自「开发linux应用-用gtk+和gdk开发linux图形用户界面应用--的实例」· C语言 代码 · 共 51 行

C
51
字号
/* * File: DisplayFonts.c *  * Show all fonts available on the system. */#include <gtk/gtk.h>#include <gdk/gdkx.h>#include <X11/Xlib.h>/* * If they have more than this many fonts, they have * too many fonts anyways. */#define MAX_FONTS 30000/* * main.c * */int main (int argc, char *argv[]){    int nFonts;    char **szaFontNames;    int i;    /* --- Initialize GTK.  Needed for the GDK_DISPLAY call --- */    gtk_init (&argc, &argv);    /* --- Get the font names --- */    szaFontNames = XListFonts (GDK_DISPLAY (), "*", MAX_FONTS, &nFonts);    /* --- Check number retrieved --- */    if (nFonts == MAX_FONTS) {        /* --- They got a lot of fonts on their system. --- */        printf ("Many fonts on your system.  Not displaying all.");    }    /* --- Display all the fonts --- */    for (i = 0; i < nFonts; i++) {        /* --- Get the name --- */        printf ("%s\n", szaFontNames[i]);    }    XFreeFontNames (szaFontNames);    return (0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?