File: dbg-bml.c

package info (click to toggle)
vflib3 3.6.14.dfsg-3+nmu3
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 11,536 kB
  • ctags: 3,710
  • sloc: ansic: 35,811; sh: 10,357; asm: 3,290; makefile: 962; lisp: 123; perl: 109; awk: 43
file content (176 lines) | stat: -rw-r--r-- 4,892 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
 * dbg-bml.c - test program for bitmaplist class.
 * by Hirotsugu Kakugawa
 *
 */
/*
 * Copyright (C) 1997 Hirotsugu Kakugawa. 
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
 */


#include <stdio.h>
#include <stdlib.h>
#include "VFlib-3_6.h"
#include "VFsys.h"


int display(int,int,double,double,int,double);
extern double atof();

void  usage(void);

int
main(int argc, char **argv)
{
  char        *vflibcap;
  double      mag, std_mag;
  char        *font_name;
  int         font_id, code;
  int         rp_x, rp_y, mv_x, mv_y; 
  int         delta_x, delta_y, ign_mv;
  VF_BITMAP   bm, composed_bitmap;
  struct vf_s_bitmaplist   the_bitmaplist, *bitmaplist;

  vflibcap = NULL;
  std_mag  = 1.0;
  delta_x  = 0;
  delta_y  = 0;
  ign_mv   = 0;
  mv_x     = 0;
  mv_y     = 0;

  rp_x = 0;
  rp_y = 0;

  bitmaplist = &the_bitmaplist;
  VF_BitmapListInit(bitmaplist);

  argc--; argv++;
  while ((argc > 0) && (*argv[0] == '-')){
    if (strcmp(argv[0], "-v") == 0){
      vflibcap = argv[1];
      argc--; argv++;
    } else if (strcmp(argv[0], "-M") == 0){
      std_mag = atof(argv[1]); 
      argc--; argv++;
    } else if ((strcmp(argv[0], "-h") == 0)
	       || (strcmp(argv[0], "-help") == 0)){
      usage();
    } else {
      break;
    }
    argc--; argv++;
  }

  if (VF_Init(vflibcap, NULL) < 0){
    fprintf(stderr, "Error %d in VF_Init().\n", vf_error);
    exit(0);
  }
     
  mag = std_mag;
  while (argc > 0){
    if (strcmp(argv[0], "-m") == 0){
      mag = atof(argv[1]) * std_mag; 
      argc--; argv++;
    } else if (strcmp(argv[0], "-f") == 0){
      font_name = argv[1];
      argc--; argv++;
      if ((font_id = VF_OpenFont2(font_name, -1, 1, 1)) < 0){
	fprintf(stderr, "Error %d in VF_OpenFont2(%s)\n", 
		vf_error, font_name);
	exit(0);
      }
    } else if (strcmp(argv[0], "-x") == 0){
      mv_x += atoi(argv[1]);
      argc--; argv++;
    } else if (strcmp(argv[0], "-y") == 0){
      mv_y += atoi(argv[1]);
      argc--; argv++;
    } else if (strcmp(argv[0], "-dx") == 0){
      delta_x = atoi(argv[1]);
      argc--; argv++;
    } else if (strcmp(argv[0], "-dy") == 0){
      delta_y = atoi(argv[1]);
      argc--; argv++;
    } else if (strcmp(argv[0], "-n") == 0){
      ign_mv = 1;
    } else if (font_id < 0){
      fprintf(stderr, "Error: Font is not selected.\n");
      exit(0);
    } else if (font_id >= 0){
      sscanf(argv[0], "%i", &code);
      bm = VF_GetBitmap2(font_id, code, mag, mag);
      mag = std_mag;
      if (bm == NULL){
	fprintf(stderr, "Error: Fauiled to obtain a glyph.\n");
	exit(1);
      }
      if (ign_mv == 1){
	mv_x = 0;
	mv_y = 0;
      }
      VF_BitmapListPut(bitmaplist, bm, 
		       rp_x + mv_x + delta_x, rp_y + mv_y + delta_y);
      rp_x += mv_x;
      rp_y += mv_y;
      mv_x = bm->mv_x;
      mv_y = bm->mv_y;

      delta_x = 0;
      delta_y = 0;
      ign_mv  = 0;
    }
    argc--; argv++;
  }

  if ((composed_bitmap = VF_BitmapListCompose(bitmaplist)) != NULL){
    VF_DumpBitmap(composed_bitmap);
  }

  VF_BitmapListFinish(bitmaplist);

  return 0;
}


void
usage(void)
{
  printf("dbg-bml - Debug bitmaplist class\n");
  printf("Usage: bdg-bml [OPTIONS] [ARGS]\n");
  printf("OPTIONS: -v VFLIBCAP  Select vflibcap file\n");
  printf("         -M MAG       Change default magnification\n");
  printf("         -h           Print help\n");
  printf("ARGS:    -f FONT      Change fonts\n");
  printf("         -m MAG       Change magnification\n");
  printf("         -x NPIX      Move ref point NPIX pixels holizontally\n");
  printf("         -y NPIX      Move ref point NPIX pixels vertically\n");
  printf("         -dx NPIX     Shift next glyph NPIX pixels holizontally\n");
  printf("         -dx NPIX     Shift next glyph NPIX pixels vertically\n");
  printf("         -n           Do not move ref point\n");
  printf("         CODE_POINT   Add glyph for CODE_POINT\n");
  printf("  -m has effect on only current font.\n");
  printf("  -dx, -dy and -n have effects on only for next one glyph.\n");
  printf("Example 1:  dbg-bml -f timI24.pcf 0x69 0x66 0x66\n");
  printf("Example 2:  dbg-bml -f timR24.pcf -m 2 0x41\n");
  printf("Example 3:  dbg-bml -f timR24.pcf 0x41 -f timI24.pcf 0x42\n");
  exit(0);
}


/*EOF*/