fstobdf.c revision 21c2f794
121c2f794Smrg/* $Xorg: fstobdf.c,v 1.4 2001/02/09 02:05:30 xorgcvs Exp $ */ 221c2f794Smrg/* 321c2f794Smrg 421c2f794SmrgCopyright 1990, 1998 The Open Group 521c2f794Smrg 621c2f794SmrgPermission to use, copy, modify, distribute, and sell this software and its 721c2f794Smrgdocumentation for any purpose is hereby granted without fee, provided that 821c2f794Smrgthe above copyright notice appear in all copies and that both that 921c2f794Smrgcopyright notice and this permission notice appear in supporting 1021c2f794Smrgdocumentation. 1121c2f794Smrg 1221c2f794SmrgThe above copyright notice and this permission notice shall be included in 1321c2f794Smrgall copies or substantial portions of the Software. 1421c2f794Smrg 1521c2f794SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1621c2f794SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1721c2f794SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1821c2f794SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 1921c2f794SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2021c2f794SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2121c2f794Smrg 2221c2f794SmrgExcept as contained in this notice, the name of The Open Group shall not be 2321c2f794Smrgused in advertising or otherwise to promote the sale, use or other dealings 2421c2f794Smrgin this Software without prior written authorization from The Open Group. 2521c2f794Smrg 2621c2f794Smrg * Copyright 1990 Network Computing Devices; 2721c2f794Smrg * Portions Copyright 1987 by Digital Equipment Corporation 2821c2f794Smrg * 2921c2f794Smrg * Permission to use, copy, modify, distribute, and sell this software and 3021c2f794Smrg * its documentation for any purpose is hereby granted without fee, provided 3121c2f794Smrg * that the above copyright notice appear in all copies and that both that 3221c2f794Smrg * copyright notice and this permission notice appear in supporting 3321c2f794Smrg * documentation, and that the names of Network Computing Devices, or Digital 3421c2f794Smrg * not be used in advertising or publicity pertaining to distribution 3521c2f794Smrg * of the software without specific, written prior permission. 3621c2f794Smrg * 3721c2f794Smrg * NETWORK COMPUTING DEVICES, AND DIGITAL DISCLAIM ALL WARRANTIES WITH 3821c2f794Smrg * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF 3921c2f794Smrg * MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES, 4021c2f794Smrg * OR DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 4121c2f794Smrg * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 4221c2f794Smrg * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 4321c2f794Smrg * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF 4421c2f794Smrg * THIS SOFTWARE. 4521c2f794Smrg */ 4621c2f794Smrg/* $XFree86: xc/programs/fstobdf/fstobdf.c,v 1.6tsi Exp $ */ 4721c2f794Smrg 4821c2f794Smrg#include <stdio.h> 4921c2f794Smrg#include <stdlib.h> 5021c2f794Smrg#include <string.h> 5121c2f794Smrg#include "fstobdf.h" 5221c2f794Smrgstatic void 5321c2f794Smrgusage(char *progName) 5421c2f794Smrg{ 5521c2f794Smrg fprintf(stderr, "Usage: %s [-s <font server>] -fn <font name>\n", 5621c2f794Smrg progName); 5721c2f794Smrg exit(0); 5821c2f794Smrg} 5921c2f794Smrg 6021c2f794Smrgstatic void 6121c2f794SmrgFail(char *progName) 6221c2f794Smrg{ 6321c2f794Smrg fprintf(stderr, "%s: unable to dump font\n", progName); 6421c2f794Smrg exit(1); 6521c2f794Smrg} 6621c2f794Smrg 6721c2f794Smrgint 6821c2f794Smrgmain(int argc, char *argv[]) 6921c2f794Smrg{ 7021c2f794Smrg FSServer *fontServer; 7121c2f794Smrg Font fontID, 7221c2f794Smrg dummy; 7321c2f794Smrg FSBitmapFormat bitmapFormat; 7421c2f794Smrg FSXFontInfoHeader fontHeader; 7521c2f794Smrg FSPropInfo propInfo; 7621c2f794Smrg FSPropOffset *propOffsets; 7721c2f794Smrg unsigned char *propData; 7821c2f794Smrg 7921c2f794Smrg FILE *outFile; 8021c2f794Smrg char *fontName; 8121c2f794Smrg char *serverName; 8221c2f794Smrg int i; 8321c2f794Smrg 8421c2f794Smrg fontName = NULL; 8521c2f794Smrg serverName = NULL; 8621c2f794Smrg outFile = stdout; 8721c2f794Smrg 8821c2f794Smrg for (i = 1; i < argc; i++) { 8921c2f794Smrg if (!strncmp(argv[i], "-s", 2)) { 9021c2f794Smrg if (argv[++i]) 9121c2f794Smrg serverName = argv[i]; 9221c2f794Smrg else 9321c2f794Smrg usage(argv[0]); 9421c2f794Smrg } else if (!strncmp(argv[i], "-fn", 3)) { 9521c2f794Smrg if (argv[++i]) 9621c2f794Smrg fontName = argv[i]; 9721c2f794Smrg else 9821c2f794Smrg usage(argv[0]); 9921c2f794Smrg } 10021c2f794Smrg } 10121c2f794Smrg 10221c2f794Smrg if (fontName == NULL) 10321c2f794Smrg usage(argv[0]); 10421c2f794Smrg 10521c2f794Smrg fontServer = FSOpenServer(serverName); 10621c2f794Smrg if (!fontServer) { 10721c2f794Smrg char *sn = FSServerName(serverName); 10821c2f794Smrg if (sn) 10921c2f794Smrg fprintf(stderr, "%s: can't open font server \"%s\"\n", 11021c2f794Smrg argv[0], sn); 11121c2f794Smrg else 11221c2f794Smrg fprintf(stderr, "%s: No font server specified.\n", 11321c2f794Smrg argv[0]); 11421c2f794Smrg exit(0); 11521c2f794Smrg } 11621c2f794Smrg bitmapFormat = 0; 11721c2f794Smrg fontID = FSOpenBitmapFont(fontServer, bitmapFormat, (FSBitmapFormatMask) 0, 11821c2f794Smrg fontName, &dummy); 11921c2f794Smrg if (!fontID) { 12021c2f794Smrg printf("can't open font \"%s\"\n", fontName); 12121c2f794Smrg exit(0); 12221c2f794Smrg } 12321c2f794Smrg FSQueryXInfo(fontServer, fontID, &fontHeader, &propInfo, &propOffsets, 12421c2f794Smrg &propData); 12521c2f794Smrg 12621c2f794Smrg if (!EmitHeader(outFile, &fontHeader, &propInfo, propOffsets, propData)) 12721c2f794Smrg Fail(argv[0]); 12821c2f794Smrg if (!EmitProperties(outFile, &fontHeader, &propInfo, propOffsets, propData)) 12921c2f794Smrg Fail(argv[0]); 13021c2f794Smrg if (!EmitCharacters(outFile, fontServer, &fontHeader, fontID)) 13121c2f794Smrg Fail(argv[0]); 13221c2f794Smrg fprintf(outFile, "ENDFONT\n"); 13321c2f794Smrg 13421c2f794Smrg FSFree((char *) propOffsets); 13521c2f794Smrg FSFree((char *) propData); 13621c2f794Smrg exit (0); 13721c2f794Smrg} 138