IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 18, 2015, 8:17:23 PM (11 years ago)
Author:
eugene
Message:

update rotfont to have different ps and bDraw widths

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150625/Ohana/src/libkapa/rotfont/fixfont.c

    r5854 r38885  
    11# include <stdio.h>
    22# include <math.h>
     3# include <stdlib.h>
     4# include <string.h>
    35# define TRUE 1
    46# define FALSE 0
     
    2426
    2527typedef struct {
    26   int dx, dy, ascent, Nb;
     28  int dx;
     29  int dy;
     30  float dXps;
     31  int ascent;
     32  int Nb;
    2733  unsigned char *bits;
    2834  char name[64];
     
    3238int scan_line (FILE *f, char *line);
    3339
    34 main (int argc, char **argv) {
     40int main (int argc, char **argv) {
    3541
    3642  int BitMap, Nvalue, code;
     
    4349  FILE *f;
    4450
    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");
    4753    exit (0);
    4854  }
    4955
    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");
    5162  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);
    5381    exit (0);
    5482  }
     
    112140      strcpy (font[i].name, "blank");
    113141    }
    114     fprintf (stdout, "static unsigned char %s_%d_bits[] = {", argv[2], i);
     142    fprintf (stdout, "static unsigned char %s_%d_bits[] = {", fontname, i);
    115143    for (j = 0; j < font[i].Nb; j++) {
    116144      if (!(j % 12)) fprintf (stdout, "\n");
     
    121149  }
    122150 
    123   fprintf (stdout, "static RotFont %sfont[] = {\n", argv[2]);
     151  fprintf (stdout, "static RotFont %sfont[] = {\n", fontname);
    124152  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);
    130158
    131159     
     
    178206
    179207}
    180 
Note: See TracChangeset for help on using the changeset viewer.