- Timestamp:
- Oct 18, 2015, 8:17:23 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150625/Ohana/src/libkapa/rotfont/fixfont.c
r5854 r38885 1 1 # include <stdio.h> 2 2 # include <math.h> 3 # include <stdlib.h> 4 # include <string.h> 3 5 # define TRUE 1 4 6 # define FALSE 0 … … 24 26 25 27 typedef struct { 26 int dx, dy, ascent, Nb; 28 int dx; 29 int dy; 30 float dXps; 31 int ascent; 32 int Nb; 27 33 unsigned char *bits; 28 34 char name[64]; … … 32 38 int scan_line (FILE *f, char *line); 33 39 34 main (int argc, char **argv) {40 int main (int argc, char **argv) { 35 41 36 42 int BitMap, Nvalue, code; … … 43 49 FILE *f; 44 50 45 if (argc != 3) {46 fprintf (stderr, "USAGE: fixfont (file.bdf) ( name)\n");51 if (argc != 4) { 52 fprintf (stderr, "USAGE: fixfont (file.bdf) (file.psx) (name)\n"); 47 53 exit (0); 48 54 } 49 55 50 f = fopen (argv[1], "r"); 56 char *bdfname = argv[1]; 57 char *psxname = argv[2]; 58 char *fontname = argv[3]; 59 60 // read in the PS sizes first 61 f = fopen (psxname, "r"); 51 62 if (f == (FILE *) NULL) { 52 fprintf (stderr, "failed to open file %s\n", argv[1]); 63 fprintf (stderr, "failed to open file %s\n", psxname); 64 exit (0); 65 } 66 67 while (scan_line (f, buffer) != EOF) { 68 int N; 69 float dXps; 70 int Nread = sscanf (buffer, "%d %f", &N, &dXps); 71 if (Nread != 2) continue; 72 if (N < 1) continue; 73 if (N > 255) continue; 74 font[N].dXps = dXps; 75 } 76 fclose (f); 77 78 f = fopen (bdfname, "r"); 79 if (f == (FILE *) NULL) { 80 fprintf (stderr, "failed to open file %s\n", bdfname); 53 81 exit (0); 54 82 } … … 112 140 strcpy (font[i].name, "blank"); 113 141 } 114 fprintf (stdout, "static unsigned char %s_%d_bits[] = {", argv[2], i);142 fprintf (stdout, "static unsigned char %s_%d_bits[] = {", fontname, i); 115 143 for (j = 0; j < font[i].Nb; j++) { 116 144 if (!(j % 12)) fprintf (stdout, "\n"); … … 121 149 } 122 150 123 fprintf (stdout, "static RotFont %sfont[] = {\n", argv[2]);151 fprintf (stdout, "static RotFont %sfont[] = {\n", fontname); 124 152 for (i = 0; i < 255; i++) { 125 fprintf (stdout, "{% d, %d, %d, %s_%d_bits},\n",126 font[i].dx, font[i].dy, font[i]. ascent, argv[2], i);127 } 128 fprintf (stdout, "{% d, %d, %d, %s_%d_bits}};\n",129 font[i].dx, font[i].dy, font[i]. ascent, argv[2], i);153 fprintf (stdout, "{%3d, %3d, %5.2f, %3d, %s_%d_bits},\n", 154 font[i].dx, font[i].dy, font[i].dXps, font[i].ascent, fontname, i); 155 } 156 fprintf (stdout, "{%3d, %3d, %5.2f, %3d, %s_%d_bits}};\n", 157 font[i].dx, font[i].dy, font[i].dXps, font[i].ascent, fontname, i); 130 158 131 159 … … 178 206 179 207 } 180
Note:
See TracChangeset
for help on using the changeset viewer.
