📄 sptobdf.c
字号:
/* $XConsortium: sptobdf.c,v 1.5 94/04/17 20:17:51 dpw Exp $ *//* * Copyright 1990, 1991 Network Computing Devices; * Portions Copyright 1987 by Digital Equipment Corporation * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the names of Network Computing Devices and * Digital not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * Network Computing Devices and Digital make no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * NETWORK COMPUTING DEVICES AND DIGITAL DISCLAIM ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS, IN NO EVENT SHALL NETWORK COMPUTING DEVICES OR DIGITAL BE * LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Dave Lemke *//*Copyright (c) 1987, 1994 X ConsortiumPermission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:The above copyright notice and this permission notice shall be includedin all copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OROTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OROTHER DEALINGS IN THE SOFTWARE.Except as contained in this notice, the name of the X Consortium shallnot be used in advertising or otherwise to promote the sale, use orother dealings in this Software without prior written authorizationfrom the X Consortium.*//* * Speedo outline to BFD format converter */#include <stdio.h>#include "speedo.h"#ifdef EXTRAFONTS#include "ncdkeys.h"#else#include "keys.h"#endif#include "iso8859.h"#define MAX_BITS 1024#define BBOX_CLIPstatic char line_of_bits[MAX_BITS + 1];static FILE *fp;static ufix16 char_index, char_id;static buff_t font;static buff_t char_data;static ufix8 *f_buffer, *c_buffer;static ufix16 mincharsize;static fix15 cur_y;static fix15 bit_width, bit_height;static ufix8 key[] ={ KEY0, KEY1, KEY2, KEY3, KEY4, KEY5, KEY6, KEY7, KEY8}; /* Font decryption key */static char *progname;static char *fontname = NULL;static char *fontfile = NULL;static int point_size = 120;static int x_res = 72;static int y_res = 72;static int quality = 0;static int iso_encoding = 1;static int num_props = 7;static int stretch = 120;static specs_t specs;static void dump_header();static voidusage(){ fprintf(stderr, "Usage: %s [-xres x resolution] [-yres y resolution]\n\t[-ptsize pointsize] [-fn fontname] [-q quality (0-1)] fontfile\n", progname); fprintf(stderr, "Where:\n"); fprintf(stderr, "-xres specifies the X resolution (72)\n"); fprintf(stderr, "-yres specifies the Y resolution (72)\n"); fprintf(stderr, "-pts specifies the pointsize in decipoints (120)\n"); fprintf(stderr, "-fn specifies the font name (full Bitstream name)\n"); fprintf(stderr, "-q specifies the font quality [0-1] (0)\n"); fprintf(stderr, "\n"); exit(0);}static fix15read_2b(ptr) ufix8 *ptr;{ fix15 tmp; tmp = *ptr++; tmp = (tmp << 8) + *ptr; return tmp;}static fix31read_4b(ptr) ufix8 *ptr;{ fix31 tmp; tmp = *ptr++; tmp = (tmp << 8) + *ptr++; tmp = (tmp << 8) + *ptr++; tmp = (tmp << 8) + *ptr; return tmp;}static voidprocess_args(ac, av) int ac; char **av;{ int i; for (i = 1; i < ac; i++) { if (!strncmp(av[i], "-xr", 3)) { if (av[i + 1]) { x_res = atoi(av[++i]); } else usage(); } else if (!strncmp(av[i], "-yr", 3)) { if (av[i + 1]) { y_res = atoi(av[++i]); } else usage(); } else if (!strncmp(av[i], "-pt", 3)) { if (av[i + 1]) { point_size = atoi(av[++i]); } else usage(); } else if (!strncmp(av[i], "-fn", 3)) { if (av[i + 1]) { fontname = av[++i]; } else usage(); } else if (!strncmp(av[i], "-q", 2)) { if (av[i + 1]) { quality = atoi(av[++i]); } else usage(); } else if (!strncmp(av[i], "-st", 3)) { if (av[i + 1]) { stretch = atoi(av[++i]); } else usage(); } else if (!strncmp(av[i], "-noni", 5)) { iso_encoding = 0; } else if (*av[i] == '-') { usage(); } else fontfile = av[i]; } if (!fontfile) usage();}voidmain(argc, argv) int argc; char **argv;{ ufix32 i; ufix8 tmp[16]; ufix32 minbufsize; ufix16 cust_no; int first_char_index, num_chars; progname = argv[0]; process_args(argc, argv); fp = fopen(fontfile, "r"); if (!fp) { fprintf(stderr, "No such font file, \"%s\"\n", fontfile); exit(-1); } if (fread(tmp, sizeof(ufix8), 16, fp) != 16) { fprintf(stderr, "error reading \"%s\"\n", fontfile); exit(-1); } minbufsize = (ufix32) read_4b(tmp + FH_FBFSZ); f_buffer = (ufix8 *) malloc(minbufsize); if (!f_buffer) { fprintf(stderr, "can't get %x bytes of memory\n", minbufsize); exit(-1); } fseek(fp, (ufix32) 0, 0); if (fread(f_buffer, sizeof(ufix8), (ufix16) minbufsize, fp) != minbufsize) { fprintf(stderr, "error reading file \"%s\"\n", fontfile); exit(-1); } mincharsize = read_2b(f_buffer + FH_CBFSZ); c_buffer = (ufix8 *) malloc(mincharsize); if (!c_buffer) { fprintf(stderr, "can't get %x bytes for char buffer\n", mincharsize); exit(-1); } /* init */ sp_reset(); font.org = f_buffer; font.no_bytes = minbufsize; if ((cust_no = sp_get_cust_no(font)) != CUS0) { fprintf(stderr, "Non-standard encryption for \"%s\"\n", fontfile); exit(-1); } sp_set_key(key); first_char_index = read_2b(f_buffer + FH_FCHRF); num_chars = read_2b(f_buffer + FH_NCHRL); /* set up specs */ /* Note that point size is in decipoints */ specs.pfont = &font; /* XXX beware of overflow */ specs.xxmult = point_size * x_res / 720 * (1 << 16); specs.xymult = 0L << 16; specs.xoffset = 0L << 16; specs.yxmult = 0L << 16; specs.yymult = point_size * y_res / 720 * (1 << 16); specs.yoffset = 0L << 16; switch (quality) { case 0: specs.flags = 0; break; case 1: specs.flags = MODE_SCREEN; break; case 2: specs.flags = MODE_2D; break; default: fprintf(stderr, "bogus quality value %d\n", quality); break; } specs.out_info = NULL; if (!fontname) { fontname = (char *) (f_buffer + FH_FNTNM); } if (iso_encoding) num_chars = num_iso_chars; dump_header(num_chars); if (!sp_set_specs(&specs)) { fprintf(stderr, "can't set specs\n"); } else { if (iso_encoding) { for (i = 0; i < num_iso_chars * 2; i += 2) { char_index = iso_map[i + 1]; char_id = iso_map[i]; if (!sp_make_char(char_index)) { fprintf(stderr, "can't make char %x\n", char_index); } } } else { for (i = 0; i < num_chars; i++) { char_index = i + first_char_index; char_id = sp_get_char_id(char_index); if (char_id) { if (!sp_make_char(char_index)) { fprintf(stderr, "can't make char %x\n", char_index); } } } } } (void) fclose(fp); printf("ENDFONT\n"); exit(0);}static voiddump_header(num_chars) ufix32 num_chars;{ fix15 xmin, ymin, xmax, ymax; fix15 ascent, descent; fix15 pixel_size; xmin = read_2b(f_buffer + FH_FXMIN);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -