annotate TOOLS/mpfc/mpfc-ce.c @ 5795:6ee426749843

Fix audio only absolute seeking
author albeu
date Tue, 23 Apr 2002 13:26:56 +0000
parents be5942e385e5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1155
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
1 /*
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
2
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
3 mplayer font creator for central-europe (latin-1 etc) charset
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
4
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
5 This program uses gd & freetype2 library to draw each characters then
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
6 write the image to stdout.
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
7
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
8 Written by Sunjin Yang <lethean@realtime.ssu.ac.kr> May 03, 2001.
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
9 Modified by Arpad Gereoffy <arpi@thot.banki.hu> Jun 18, 2001.
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
10
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
11 */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
12
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
13 #include <gd.h>
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
14 #include <stdio.h>
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
15 #include <string.h>
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
16 #include <errno.h>
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
17
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
18 #define UPSCALE_FACTOR 2
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
19
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
20 #define X_ALIGN (8*UPSCALE_FACTOR)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
21 #define ALIGNED(x) (((x)+(X_ALIGN-1))&(~(X_ALIGN-1)))
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
22
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
23 #define DEF_FONT_SIZE 16.0
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
24
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
25 #define DEF_CHAR_GAP 6
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
26 #define CHAR_SKIP(gap) (gap / 4)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
27
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
28 #define AUTHOR "Sunjin Yang <lethean@realtime.ssu.ac.kr>"
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
29 #define VERSION "0.1"
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
30
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
31 struct code_range {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
32 int start, end;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
33 };
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
34
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
35 /* basic alphabet character range */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
36 //static struct code_range ascii_range = { 0x21, 0x7E };
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
37 static struct code_range ascii_range = { 0x20, 0x1FF };
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
38
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
39 #ifdef USE_UNIFIED_KOREAN
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
40
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
41 /* Unified Hangul Code Encoding */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
42 static struct code_range first_byte_range[] = {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
43 { 0x81, 0xFE }, { 0, 0 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
44 };
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
45 static struct code_range second_byte_range[] = {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
46 { 0x41, 0x5A }, { 0x61, 0x7A }, { 0x81, 0x9F }, { 0xA0, 0xBF },
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
47 { 0xC0, 0xDF }, { 0xE0, 0xFE }, { 0, 0 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
48 };
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
49
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
50 #else
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
51
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
52 /* KSX 1001:1992 */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
53 static struct code_range first_byte_range[] = {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
54 { 0xA1, 0xAC }, { 0xB0, 0xFD }, { 0, 0 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
55 };
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
56 static struct code_range second_byte_range[] = {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
57 { 0xA1, 0xAF }, { 0xB0, 0xBF }, { 0xC0, 0xCF }, { 0xD0, 0xDF },
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
58 { 0xE0, 0xEF }, { 0xF0, 0xFE }, { 0, 0 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
59 };
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
60
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
61 #endif
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
62
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
63 #define _output(msg...) fprintf(stdout, ##msg)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
64
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
65 /* debugging macros */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
66 #define _print(msg...) fprintf(stderr, ##msg)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
67 #define _info(msg...) { _print("mpfc: "); _print(##msg); _print("\n"); }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
68 #define _abort(msg...) { _info(##msg); exit(1); }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
69
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
70 static double size;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
71 static int gap,vgap;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
72 static char *name, *font, *eng_font, *kor_font;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
73 static int file_index;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
74 static char filename[20];
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
75
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
76 static int base_x, char_count;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
77 static gdImagePtr char_image[65536];
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
78
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
79 static gdImagePtr concat_char_images(void)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
80 {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
81 gdImagePtr ret;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
82 int width, height, i, x,black, white;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
83
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
84 /* get image's width & height */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
85 height = size + (vgap * 2);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
86 for (width = 0, i = 0; i < char_count; i++)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
87 width += ALIGNED(char_image[i]->sx);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
88
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
89 ret = gdImageCreate(width, height);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
90
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
91 /* background color (first allocated) */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
92 black = gdImageColorResolve(ret, 0, 0, 0);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
93 // white = gdImageColorResolve(ret, 255, 255, 255);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
94 for(x=1;x<=255;x++)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
95 white = gdImageColorResolve(ret, x,x,x);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
96
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
97 width = 0;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
98 for (i = 0; i < char_count; i++) {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
99 gdImageCopy(ret, char_image[i], /* dst, src */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
100 width + 0, 0, /* dstX, dstY */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
101 0, 0, /* srcX, srcY */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
102 char_image[i]->sx, char_image[i]->sy); /* size */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
103 width += ALIGNED(char_image[i]->sx);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
104 gdImageDestroy(char_image[i]);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
105 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
106 char_count = 0;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
107
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
108 return ret;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
109 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
110
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
111 static gdImagePtr create_char_image(int code)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
112 {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
113 gdImagePtr im;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
114 int rect[8], black, white, width, height, x, y;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
115 char *err;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
116 char s[10];
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
117
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
118 #if 1
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
119 sprintf(s,"&#%d;",code);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
120 #else
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
121 if(code>=0x100){
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
122 s[0]=code>>8;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
123 s[1]=code&0xFF;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
124 s[2]=0;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
125 } else {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
126 s[0]=code;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
127 s[1]=0;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
128 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
129 #endif
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
130
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
131 /* obtain border rectangle so that we can size the image. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
132 err = gdImageStringTTF(NULL, &rect[0], 0, font, size, .0, 0, 0, s);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
133 if (err)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
134 _abort("%s\n", err);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
135
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
136 /* create an image big enough for a string plus a little whitespace. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
137 width = rect[2] - rect[6] + gap;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
138 height = size + (vgap * 2);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
139 im = gdImageCreate(width, height);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
140
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
141 /* background color (first allocated) */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
142 black = gdImageColorResolve(im, 0, 0, 0);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
143 for(x=1;x<=255;x++)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
144 white = gdImageColorResolve(im, x,x,x);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
145 // white = gdImageColorResolve(im, 255, 255, 255);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
146
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
147 /* render the string, offset origin to center string.
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
148 note that we use top-left coordinate for adjustment
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
149 since gd origin is in top-left with y increasing downwards. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
150 x = (gap / 2) - rect[6];
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
151 y = (vgap) - rect[7] + (size + rect[7]);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
152 err = gdImageStringTTF(im, &rect[0], white, font, size, .0, x, y, s);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
153 if (err)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
154 _abort("%s\n", err);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
155
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
156 //if (*s == '"') _output("'%s' ", s); else _output("\"%s\" ", s);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
157 _output("0x%x %d %d\n", code,
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
158 (base_x + CHAR_SKIP(gap))/UPSCALE_FACTOR -1,
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
159 (base_x + width - CHAR_SKIP(gap))/UPSCALE_FACTOR - 0);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
160 base_x += ALIGNED(width);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
161 // base_x = (base_x+width+7)&(~7); // align to 8-pixel boundary for fast MMX code
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
162
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
163 return im;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
164 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
165
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
166 void make_charset_font(struct code_range *first, struct code_range *second)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
167 {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
168 gdImagePtr im;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
169 FILE *fd;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
170 int i, j;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
171
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
172 base_x = 0;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
173 char_count = 0;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
174
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
175 _output("[files]\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
176 //_output("alpha %s%d_a.raw\n", name, file_index);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
177 _output("alpha %s%02d_a.raw\n", name, file_index);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
178 _output("bitmap %s%02d_b.raw\n\n", name, file_index);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
179 _output("[characters]\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
180
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
181 for (i = first->start; i <= first->end; i++) {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
182 if (!second) {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
183 char_image[char_count++] = create_char_image(i);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
184 } else
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
185 for (j = second->start; j <= second->end; j++) {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
186 char_image[char_count++]= create_char_image((i<<8)|j);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
187 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
188 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
189
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
190 _output("\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
191
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
192 /* concatenate each character images into one image. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
193 im = concat_char_images();
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
194
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
195 /* get filename and create one with it. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
196 sprintf(filename, "%s%02d_b.png", name, file_index++);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
197 fd = fopen(filename, "w+");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
198 if (!fd)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
199 _abort(strerror(errno));
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
200
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
201 /* write image to the PNG file. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
202 gdImagePng(im, fd);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
203
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
204 fclose(fd);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
205
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
206 /* destroy it */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
207 gdImageDestroy(im);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
208 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
209
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
210 int main(int argc, char **argv)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
211 {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
212 int i, j;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
213
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
214 if (argc < 4)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
215 _abort("usage:%s name eng-ttf kor-ttf [size gap vgap]",argv[0]);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
216
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
217 /* get program parameter like font names, size... */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
218 name = argv[1];
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
219 eng_font = argv[2];
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
220 kor_font = argv[3];
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
221 size = DEF_FONT_SIZE;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
222 gap = DEF_CHAR_GAP;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
223 vgap = DEF_CHAR_GAP;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
224 if (argc > 4) {
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
225 float __s; sscanf(argv[4], "%f", &__s);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
226 size = (double)__s;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
227 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
228 if (argc > 5)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
229 sscanf(argv[5], "%d", &gap);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
230 if (argc > 6)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
231 sscanf(argv[6], "%d", &vgap);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
232
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
233 /* write basic font information. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
234 _output("[info]\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
235 _output("name \"%s version %s - created by %s\"\n",
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
236 name, VERSION, AUTHOR);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
237 _output("descversion 1\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
238 _output("spacewidth %d\n", (int)(size / 2));
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
239 _output("charspace -%d\n", CHAR_SKIP(gap) + 1);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
240 _output("; height %d\n\n", (int)size + DEF_CHAR_GAP);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
241
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
242 /* write general OSD fonts information. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
243 _output("[files]\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
244 _output("alpha arpi_osd_a.raw\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
245 _output("bitmap arpi_osd_b.raw\n\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
246 _output("[characters]\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
247 _output("0x01 0 36\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
248 _output("0x02 35 71\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
249 _output("0x03 70 106\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
250 _output("0x04 116 152\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
251 _output("0x05 164 200\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
252 _output("0x06 209 245\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
253 _output("0x07 256 292\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
254 _output("0x08 305 342\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
255 _output("0x09 354 400\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
256 _output("0x0A 407 442\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
257 _output("0x0B 457 494\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
258 _output("[files]\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
259 _output("alpha arpi_progress_a.raw\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
260 _output("bitmap arpi_progress_b.raw\n\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
261 _output("[characters]\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
262 _output("0x10 4 21\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
263 _output("0x11 30 41\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
264 _output("0x12 50 66\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
265 _output("0x13 74 85\n\n");
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
266
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
267
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
268 file_index = 0;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
269
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
270 /* create basic alphabet character set. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
271 font = eng_font;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
272 make_charset_font(&ascii_range, NULL);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
273
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
274 #if 0
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
275 /* create korean character set. */
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
276 font = kor_font;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
277 for (i = 0; first_byte_range[i].start != 0; i++)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
278 for (j = 0; second_byte_range[j].start != 0; j++)
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
279 make_charset_font(&first_byte_range[i], &second_byte_range[j]);
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
280 #endif
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
281
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
282 return 0;
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
283 }
be5942e385e5 original and CE version of mpfc
arpi_esp
parents:
diff changeset
284