"Fossies" - the Fresh Open Source Software Archive

Member "xfontlst-0.2.0/xlstfnt.c" (22 Sep 2010, 1983 Bytes) of package /linux/privat/old/xfontlst-0.2.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "xlstfnt.c" see the Fossies "Dox" file reference documentation.

    1 /*
    2 xlstfnt Version 0.2.0 - List X Windows Fonts
    3 Copyright (C) 2001-2010  dondalah721@yahoo.com (Dondalah)
    4 
    5 This program is free software; you can redistribute it and/or
    6 modify it under the terms of the GNU General Public License
    7 as published by the Free Software Foundation; either version 2
    8 of the License, or (at your option) any later version.
    9 
   10 This program is distributed in the hope that it will be useful,
   11 but WITHOUT ANY WARRANTY; without even the implied warranty of
   12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13 GNU General Public License for more details.
   14 
   15 You should have received a copy of the GNU General Public License
   16 along with this program; if not, write to the Free Software
   17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   18 */
   19 
   20 #include <stdio.h>
   21 #include <stdlib.h>
   22 #include <string.h>
   23 #include <X11/Xlib.h>
   24 #include <X11/keysymdef.h>
   25 #include <assert.h>
   26 #include <unistd.h>
   27 
   28 #define NIL (0)
   29 #define SCRW 240
   30 #define SCRH 120
   31 
   32 Display *dpy;
   33 
   34 void putstx(pgm)
   35 char *pgm;
   36    {
   37    fprintf(stderr,"Usage: %s [mask]\n", pgm);
   38    fprintf(stderr,"Where mask is the font name mask.\n", pgm);
   39    exit(1);
   40    } /* putstx */
   41 
   42 /* X Windows code is based on: */
   43 /* http://tronche.lri.fr:8000/gui/x/xlib-tutorial/2nd-program-anatomy.html */
   44 
   45 int main(argc,argv)
   46 int argc;
   47 char **argv;
   48    {
   49    int i,fnts;
   50    char **lst;
   51    char fntmask[256];
   52    if (argc == 1)
   53       {
   54       strcpy(fntmask,"*");
   55       } /* no fontname mask */
   56    else if (argc == 2)
   57       {
   58       strcpy(fntmask,*(argv+1));
   59       } /* 1 parm */
   60    else putstx(*argv);
   61    dpy = XOpenDisplay(NIL);
   62 
   63    if (dpy == NULL)
   64       {
   65       fprintf(stderr,"X Windows failure\n");
   66       exit(1);
   67       } /* if X Windows is not active */
   68 
   69    assert(dpy);
   70 
   71    lst = (char **) XListFonts(dpy,fntmask,999999,&fnts);
   72    printf("\"%s\"  Total fonts %d\n",
   73       fntmask, fnts);
   74    for (i=0;i<fnts;i++)
   75       {
   76       printf("%4d: %s\n", i, lst[i]);
   77       }
   78    return(0);
   79    } /* main */