~ubuntu-branches/ubuntu/precise/vflib3/precise

« back to all changes in this revision

Viewing changes to src/dbg-bml.c

  • Committer: Bazaar Package Importer
  • Author(s): Masayuki Hatta
  • Date: 2002-04-15 12:10:24 UTC
  • Revision ID: james.westby@ubuntu.com-20020415121024-cann32wucyfbq22f
Tags: upstream-3.6.12
ImportĀ upstreamĀ versionĀ 3.6.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * dbg-bml.c - test program for bitmaplist class.
 
3
 * by Hirotsugu Kakugawa
 
4
 *
 
5
 */
 
6
/*
 
7
 * Copyright (C) 1997 Hirotsugu Kakugawa. 
 
8
 * All rights reserved.
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or modify
 
11
 * it under the terms of the GNU General Public License as published by
 
12
 * the Free Software Foundation; either version 2, or (at your option)
 
13
 * any later version.
 
14
 * 
 
15
 * This program is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 * GNU General Public License for more details.
 
19
 * 
 
20
 * You should have received a copy of the GNU General Public License
 
21
 * along with this program; if not, write to the Free Software
 
22
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
 
23
 */
 
24
 
 
25
 
 
26
#include <stdio.h>
 
27
#include <stdlib.h>
 
28
#include "VFlib-3_6.h"
 
29
#include "VFsys.h"
 
30
 
 
31
 
 
32
int display(int,int,double,double,int,double);
 
33
extern double atof();
 
34
 
 
35
void  usage(void);
 
36
 
 
37
int
 
38
main(int argc, char **argv)
 
39
{
 
40
  char        *vflibcap;
 
41
  double      mag, std_mag;
 
42
  char        *font_name;
 
43
  int         font_id, code;
 
44
  int         rp_x, rp_y, mv_x, mv_y; 
 
45
  int         delta_x, delta_y, ign_mv;
 
46
  VF_BITMAP   bm, composed_bitmap;
 
47
  struct vf_s_bitmaplist   the_bitmaplist, *bitmaplist;
 
48
 
 
49
  vflibcap = NULL;
 
50
  std_mag  = 1.0;
 
51
  delta_x  = 0;
 
52
  delta_y  = 0;
 
53
  ign_mv   = 0;
 
54
  mv_x     = 0;
 
55
  mv_y     = 0;
 
56
 
 
57
  rp_x = 0;
 
58
  rp_y = 0;
 
59
 
 
60
  bitmaplist = &the_bitmaplist;
 
61
  VF_BitmapListInit(bitmaplist);
 
62
 
 
63
  argc--; argv++;
 
64
  while ((argc > 0) && (*argv[0] == '-')){
 
65
    if (strcmp(argv[0], "-v") == 0){
 
66
      vflibcap = argv[1];
 
67
      argc--; argv++;
 
68
    } else if (strcmp(argv[0], "-M") == 0){
 
69
      std_mag = atof(argv[1]); 
 
70
      argc--; argv++;
 
71
    } else if ((strcmp(argv[0], "-h") == 0)
 
72
               || (strcmp(argv[0], "-help") == 0)){
 
73
      usage();
 
74
    } else {
 
75
      break;
 
76
    }
 
77
    argc--; argv++;
 
78
  }
 
79
 
 
80
  if (VF_Init(vflibcap, NULL) < 0){
 
81
    fprintf(stderr, "Error %d in VF_Init().\n", vf_error);
 
82
    exit(0);
 
83
  }
 
84
     
 
85
  mag = std_mag;
 
86
  while (argc > 0){
 
87
    if (strcmp(argv[0], "-m") == 0){
 
88
      mag = atof(argv[1]) * std_mag; 
 
89
      argc--; argv++;
 
90
    } else if (strcmp(argv[0], "-f") == 0){
 
91
      font_name = argv[1];
 
92
      argc--; argv++;
 
93
      if ((font_id = VF_OpenFont2(font_name, -1, 1, 1)) < 0){
 
94
        fprintf(stderr, "Error %d in VF_OpenFont2(%s)\n", 
 
95
                vf_error, font_name);
 
96
        exit(0);
 
97
      }
 
98
    } else if (strcmp(argv[0], "-x") == 0){
 
99
      mv_x += atoi(argv[1]);
 
100
      argc--; argv++;
 
101
    } else if (strcmp(argv[0], "-y") == 0){
 
102
      mv_y += atoi(argv[1]);
 
103
      argc--; argv++;
 
104
    } else if (strcmp(argv[0], "-dx") == 0){
 
105
      delta_x = atoi(argv[1]);
 
106
      argc--; argv++;
 
107
    } else if (strcmp(argv[0], "-dy") == 0){
 
108
      delta_y = atoi(argv[1]);
 
109
      argc--; argv++;
 
110
    } else if (strcmp(argv[0], "-n") == 0){
 
111
      ign_mv = 1;
 
112
    } else if (font_id < 0){
 
113
      fprintf(stderr, "Error: Font is not selected.\n");
 
114
      exit(0);
 
115
    } else if (font_id >= 0){
 
116
      sscanf(argv[0], "%i", &code);
 
117
      bm = VF_GetBitmap2(font_id, code, mag, mag);
 
118
      mag = std_mag;
 
119
      if (bm == NULL){
 
120
        fprintf(stderr, "Error: Fauiled to obtain a glyph.\n");
 
121
        exit(1);
 
122
      }
 
123
      if (ign_mv == 1){
 
124
        mv_x = 0;
 
125
        mv_y = 0;
 
126
      }
 
127
      VF_BitmapListPut(bitmaplist, bm, 
 
128
                       rp_x + mv_x + delta_x, rp_y + mv_y + delta_y);
 
129
      rp_x += mv_x;
 
130
      rp_y += mv_y;
 
131
      mv_x = bm->mv_x;
 
132
      mv_y = bm->mv_y;
 
133
 
 
134
      delta_x = 0;
 
135
      delta_y = 0;
 
136
      ign_mv  = 0;
 
137
    }
 
138
    argc--; argv++;
 
139
  }
 
140
 
 
141
  if ((composed_bitmap = VF_BitmapListCompose(bitmaplist)) != NULL){
 
142
    VF_DumpBitmap(composed_bitmap);
 
143
  }
 
144
 
 
145
  VF_BitmapListFinish(bitmaplist);
 
146
 
 
147
  return 0;
 
148
}
 
149
 
 
150
 
 
151
void
 
152
usage(void)
 
153
{
 
154
  printf("dbg-bml - Debug bitmaplist class\n");
 
155
  printf("Usage: bdg-bml [OPTIONS] [ARGS]\n");
 
156
  printf("OPTIONS: -v VFLIBCAP  Select vflibcap file\n");
 
157
  printf("         -M MAG       Change default magnification\n");
 
158
  printf("         -h           Print help\n");
 
159
  printf("ARGS:    -f FONT      Change fonts\n");
 
160
  printf("         -m MAG       Change magnification\n");
 
161
  printf("         -x NPIX      Move ref point NPIX pixels holizontally\n");
 
162
  printf("         -y NPIX      Move ref point NPIX pixels vertically\n");
 
163
  printf("         -dx NPIX     Shift next glyph NPIX pixels holizontally\n");
 
164
  printf("         -dx NPIX     Shift next glyph NPIX pixels vertically\n");
 
165
  printf("         -n           Do not move ref point\n");
 
166
  printf("         CODE_POINT   Add glyph for CODE_POINT\n");
 
167
  printf("  -m has effect on only current font.\n");
 
168
  printf("  -dx, -dy and -n have effects on only for next one glyph.\n");
 
169
  printf("Example 1:  dbg-bml -f timI24.pcf 0x69 0x66 0x66\n");
 
170
  printf("Example 2:  dbg-bml -f timR24.pcf -m 2 0x41\n");
 
171
  printf("Example 3:  dbg-bml -f timR24.pcf 0x41 -f timI24.pcf 0x42\n");
 
172
  exit(0);
 
173
}
 
174
 
 
175
 
 
176
/*EOF*/