|
|
1.1 root 1: //
2: // CGROM.DAT 生成
3: //
4: // Copyright (C) 2012-2019 [email protected]
5: //
6:
7: #include <limits.h>
8: #include <stdarg.h>
1.1.1.2 ! root 9: #include <vector>
1.1 root 10: #include <wx/wx.h>
11: #include <wx/file.h>
12: #include <wx/cmdline.h>
13:
14: #define countof(x) (sizeof(x) / sizeof(x[0]))
15: #define ROUND(x, y) (((x) + (y - 1)) / (y))
16: #define ROUND8(x) ROUND(x, 8)
17:
18: /* フォント種別 */
19: enum fonttype_t {
20: FONT_16x16,
21: FONT_8x8,
22: FONT_8x16,
23: FONT_12x12,
24: FONT_12x24,
25: FONT_24x24,
26: FONT_6x12,
27: FONT_MAX,
28: };
29:
30: /* 範囲 */
31: #define R_CTRL (0x0001) /* 制御文字 */
32: #define R_ASCII (0x0002) /* ASCII(20-7F) */
33: #define R_KANA (0x0004) /* カナ(A0-DF) */
34: #define R_HIRA (0x0008) /* ひら(86-BF,E0-FF) */
35: #define R_80 (0x0010) /* \(0x80) */
36: #define R_81 (0x0020) /* 〜(0x81) */
37: #define R_82 (0x0040) /* |(0x82) */
38: #define R_SWITCH (R_80 | R_81 | R_82)
39: #define R_ALL (0x007f) /* 全部 */
40:
41: /* BDF 形式で使われるバウンディングボックス */
42: struct BBX
43: {
44: int w;
45: int h;
46: int x;
47: int y;
48: };
49:
50: /* 1文字分のフォントデータ */
51: struct font_t {
52: int code;
53: unsigned char pattern[3 * 24];
54: };
55:
56: /* グローバル変数 */
1.1.1.2 ! root 57: static wxString fontdir;
! 58: static wxFile cgrom;
1.1 root 59:
60: /* ワーニングを表示 */
1.1.1.2 ! root 61: static void
1.1 root 62: warning(const char *fmt, ...)
63: {
64: va_list ap;
65:
66: printf("Warning: ");
67:
68: va_start(ap, fmt);
69: vprintf(fmt, ap);
70: va_end(ap);
71: }
72:
73: /*
74: * クラス構造
75: *
76: * Font : すべてのフォントの基底
77: * |
78: * +- F24Font : F24形式ファイルから 12x24(一部)と24x24を作るクラス
79: * |
80: * +- BDF : BDF形式ファイルを読み込むすべての基底クラス
81: * |
82: * +- BDF_1byte : 文字コードマッピングが不要な1バイトフォントを出力
83: * | |
84: * | +- BDF_1byte_unicode : Unicode から1バイトフォントを出力
85: * | |
86: * | +- BDF_1byte_jis0208 : JIS X 0208 から1バイトフォントを出力
87: * |
88: * +- BDF_kanji_jis0208 : JIS X 0208 から漢字フォントを出力する
89: */
90:
91: /* フォント基底クラス */
92: class Font
93: {
94: public:
95: Font(const char *fname, int, int, int);
96: ~Font();
97: void SetRange(int flag) { range_flag = flag; }
98: bool debug;
99:
100: protected:
101: bool Open();
102: void Close();
103:
104: static bool IsCtrl(int c) { return (c < 0x20); }
105: static bool IsAscii(int c) { return ((0x20 <= c) && (c < 0x7f)); }
106: static bool IsKana(int c) { return ((0xa0 <= c) && (c < 0xe0)); }
107: static bool IsHira(int c) {
108: if ((0x86 <= c) && (c < 0xa0))
109: return true;
110: if ((0xe0 <= c) && (c <= 0xff))
111: return true;
112: return false;
113: }
114: bool IsRange(int code) const;
115:
116: int pattern_len; /* 1文字分のバイト数 */
117: int offset;
118: const char *filename;
119: FILE *fp;
120: int range_flag; /* 出力範囲フラグ */
121: };
122:
123: /* コンストラクタ */
124: Font::Font(const char *fname, int font_x, int font_y, int out_offset)
125: {
126: debug = false;
127: range_flag = R_ALL;
128: fp = NULL;
129:
130: /* 引数 */
131: filename = fname;
132: pattern_len = ROUND8(font_x) * font_y;
133: offset = out_offset;
134:
135: printf("generate %dx%d from %s\n", font_x, font_y, filename);
136:
137: /* ここでもうオープンする */
138: Open();
139: }
140:
141: /* デストラクタ */
142: Font::~Font()
143: {
144: Close();
145: }
146:
147: /* オープン */
148: bool
149: Font::Open()
150: {
151: char pathname[PATH_MAX];
152:
153: snprintf(pathname, sizeof(pathname), "%s/%s",
154: (const char *)::fontdir.mb_str(), filename);
155:
156: fp = fopen(pathname, "r");
157: if (fp == NULL) {
158: printf("Cannot open: %s\n", pathname);
159: throw 0;
160: }
161:
162: return true;
163: }
164:
165: /* クローズ */
166: void
167: Font::Close()
168: {
169: if (fp) {
170: fclose(fp);
171: }
172: fp = NULL;
173: }
174:
175: /* 文字コードが今回出力を許可された範囲内か */
176: bool
177: Font::IsRange(int code) const
178: {
179: if ((range_flag & R_CTRL) && IsCtrl(code)) {
180: return true;
181: }
182: if ((range_flag & R_ASCII) && IsAscii(code)) {
183: return true;
184: }
185: if ((range_flag & R_KANA) && IsKana(code)) {
186: return true;
187: }
188: if ((range_flag & R_HIRA) && IsHira(code)) {
189: return true;
190: }
191: if ((range_flag & R_80) && (code == 0x80)) {
192: return true;
193: }
194: if ((range_flag & R_81) && (code == 0x81)) {
195: return true;
196: }
197: if ((range_flag & R_82) && (code == 0x82)) {
198: return true;
199: }
200: return false;
201: }
202:
203:
204: /* BDF 基底クラス */
205: class BDF : public Font
206: {
207: typedef Font inherited;
208: public:
209: BDF(const char *fname, int, int, int);
210: virtual ~BDF() { }
211:
212: void Convert();
213:
214: protected:
215: bool ReadProperties();
216: bool ReadNextChar(font_t& data);
217: virtual int GetAddr(int code) const; /* CGROM 収録アドレスを求める */
218: int Unicode2JIS(int unicode) const;
219: int JIS2Addr(int code) const;
220:
221: BBX fontbbx; /* FONTBOUNDINGBOX。.w = 横サイズ、.h = 縦サイズ */
222: int font_descent;
223: };
224:
225: /* コンストラクタ */
226: BDF::BDF(const char *fname, int font_width, int font_height, int out_offset)
227: : inherited(fname, font_width, font_height, out_offset)
228: {
229: font_descent = 0;
230: memset(&fontbbx, 0, sizeof(fontbbx));
231:
232: /* ここでプロパティを読んでおく */
233: ReadProperties();
234: }
235:
236: /*
237: * BDF のプロパティ (ヘッダみたいなもの) を読み込む
238: */
239: bool
240: BDF::ReadProperties()
241: {
242: char buf[100];
243: char *p;
244: int pixel_size; /* 縦サイズ */
245: int quad_width; /* 横サイズ */
246:
247: pixel_size = -1;
248: quad_width = -1;
249:
250: while (fgets(buf, sizeof(buf), fp)) {
251: if (strncmp(buf, "FONTBOUNDINGBOX ", 15) == 0) {
252: /* フォントの縦横サイズ */
253: fontbbx.w = strtol(buf + 15, &p, 10);
254: fontbbx.h = strtol(p, NULL, 10);
255:
256: } else if (strncmp(buf, "PIXEL_SIZE ", 11) == 0) {
257: /* フォントの縦サイズ */
258: pixel_size = strtol(buf + 11, NULL, 10);
259:
260: } else if (strncmp(buf, "QUAD_WIDTH ", 11) == 0) {
261: /* フォントの横サイズ */
262: quad_width = strtol(buf + 11, NULL, 10);
263:
264: } else if (strncmp(buf, "FONT_DESCENT ", 13) == 0) {
265: font_descent = strtol(buf + 13, NULL, 10);
266:
267: } else if (strncmp(buf, "ENDPROPERTIES", 13) == 0) {
268: break;
269: }
270: }
271:
272: /*
273: * PIXEL_SIZE, QUAD_WIDTH のほうを優先。
274: * TTF→BDF では FONTBOUNDINGBOX がうまく適切な値にならないため。
275: * 元から BDF なフォントでは大抵同じ値になってるはず。
276: */
277: if (pixel_size != -1) {
278: fontbbx.h = pixel_size;
279: }
280: if (quad_width != -1) {
281: fontbbx.w = quad_width;
282: }
283:
284: return true;
285: }
286:
287: /*
288: * BDF から次の1文字を読み込んで data に格納する。
289: * 取り出せなければ false を返す。
290: */
291: bool
292: BDF::ReadNextChar(font_t& data)
293: {
294: char buf[100];
295: BBX bbx = {0};
296: bool in_bitmap;
297: int y = 0;
298: int dwidth = 0;
299:
300: in_bitmap = false;
301: while (fgets(buf, sizeof(buf), fp)) {
302: if (strncmp(buf, "STARTCHAR ", 10) == 0) {
303: data.code = strtol(buf + 10, NULL, 16);
304: dwidth = 0;
305: memset(data.pattern, 0, sizeof(data.pattern));
306:
307: } else if (strncmp(buf, "ENCODING ", 9) == 0) {
308: data.code = strtol(buf + 9, NULL, 10);
309:
310: } else if (strncmp(buf, "DWIDTH ", 7) == 0) {
311: dwidth = strtol(buf + 7, NULL, 10);
312: if (dwidth > 24) {
313: printf("unsupported DWIDTH: %d\n", dwidth);
314: throw 0;
315: }
316:
317: } else if (strncmp(buf, "BBX ", 4) == 0) {
318: char *p = buf + 4;
319: bbx.w = strtol(p, &p, 10);
320: bbx.h = strtol(p, &p, 10);
321: bbx.x = strtol(p, &p, 10);
322: bbx.y = strtol(p, &p, 10);
323:
324: if (bbx.w > dwidth) {
325: warning("char %x: BBX.w(%d) > DWIDTH(%d)\n",
326: data.code, bbx.w, dwidth);
327: }
328: if (bbx.h > fontbbx.h) {
329: warning("char %x: BBX.h(%d) > FONTBBX.h(%d)\n",
330: data.code, bbx.h, fontbbx.h);
331: }
332:
333: } else if (strncmp(buf, "BITMAP", 6) == 0) {
334: if (dwidth == 0) {
335: printf("BITMAP without DWIDTH!\n");
336: throw 0;
337: }
338: in_bitmap = true;
339:
340: /* BBX による縦方向の開始行を調整 */
341: y = fontbbx.h - font_descent; // 上から原点までの行数
342: y -= bbx.y; // 上から BBX 底辺までの行数
343: y -= bbx.h; // 上から BBX 上辺までの行数
344: y *= (dwidth + 7) / 8; // バイト数に
345:
346: } else if (strncmp(buf, "ENDCHAR", 7) == 0) {
347: in_bitmap = false;
348: return true;
349:
350: } else if (in_bitmap) {
351: if (y > pattern_len) {
352: printf("char %x: pattern %d > %d bytes\n",
353: data.code, y, pattern_len);
354: throw 0;
355: }
356: int len = strlen(buf) - 1; // '\n'分を引く
357: uint32_t val = strtol(buf, NULL, 16);
358: /* val を左詰めしてから */
359: val <<= (4 - (len / 2)) * 8;
360: /* BBX による横方向の位置調整 */
361: val >>= bbx.x;
362:
363: /*
364: * 1行を構成するバイト列を出力。等幅フォントを作っているので
365: * グリフごとの幅(DWIDTH)ではなく出力したいフォントの幅。
366: */
367: data.pattern[y++] = (val >> 24) & 0xff;
368: if (fontbbx.w > 8) {
369: data.pattern[y++] = (val >> 16) & 0xff;
370: }
371: if (fontbbx.w > 16) {
372: data.pattern[y++] = (val >> 8) & 0xff;
373: }
374: }
375: }
376:
377: /* EOF なので取り出す文字がない */
378: return false;
379: }
380:
381: /* 変換メイン */
382: void
383: BDF::Convert()
384: {
385: font_t data;
386:
387: /* フォントを1文字ずつ読み込んで */
388: while (ReadNextChar(data)) {
389: /* CGROM 収録アドレスを求めて */
390: int addr = GetAddr(data.code);
391: if (addr < 0) {
392: continue;
393: }
394: /* 書き出す */
395: cgrom.Seek(offset + addr * pattern_len);
396: cgrom.Write(data.pattern, pattern_len);
397: }
398: }
399:
400: /* CGROM 収録アドレスを得る */
401: int
402: BDF::GetAddr(int code) const
403: {
404: /* デフォルトはそのまま返す */
405: return code;
406: }
407:
408: /* Unicode を JIS に変換する */
409: int
410: BDF::Unicode2JIS(int unicode) const
411: {
412: wxCSConv convjis("iso-2022-jp");
413:
414: wxString str((wxChar)unicode);
415: const char *jisstr = str.mb_str(convjis);
416: int jiscode = ((unsigned int)jisstr[0] << 8) + jisstr[1];
417:
418: return jiscode;
419: }
420:
421: /* JIS コードから CGROM 収録コードを求めて返す */
422: int
423: BDF::JIS2Addr(int code) const
424: {
425: int jh, jl, addr;
426:
427: /*
428: * JIS コード 7425、7426 (区点84-05、84-06) の2文字は
429: * JIS X 0208:1990 で追加されたものなので、CGROM にはない。
430: */
431: if (code > 0x7424) {
432: return -1;
433: }
434:
435: jh = (code >> 8);
436: jl = (code & 0xff);
437:
438: /* (Unicodeから変換した)コードが JIS の範囲外なら無視 */
439: if (jl < 0x21 || jl >= 0x7f) {
440: return -1;
441: }
442:
443: if (jh < 0x30) {
444: addr = (jh - 0x21) * 94 + (jl - 0x21);
445: } else {
446: addr = (jh - 0x28) * 94 + (jl - 0x21);
447: }
448: return addr;
449: }
450:
451:
452: /*
453: * BDF フォントから1バイトフォントを作るクラス。
454: * 文字コードは ASCII/ISO-8859 か JIS X 0201 など
455: * そのまま1バイトコードにマップできるもの。
456: */
457: class BDF_1byte : public BDF
458: {
459: typedef BDF inherited;
460: public:
461: BDF_1byte(const char *filename, int, int, int);
462: virtual ~BDF_1byte() { }
463: virtual int GetAddr(int code) const;
464: };
465:
466: /* コンストラクタ */
467: BDF_1byte::BDF_1byte(const char *fname, int font_x, int font_y, int out_offset)
468: : inherited(fname, font_x, font_y, out_offset)
469: {
470: }
471:
472: /* CGROM 収録アドレスを返す */
473: int
474: BDF_1byte::GetAddr(int code) const
475: {
476: /* 指定範囲に入っているかどうかだけ */
477: if (IsRange(code)) {
478: return code;
479: }
480: return -1;
481: }
482:
483:
484: /*
485: * BDF 日本語フォントから1バイトフォントを作るクラス。
486: * 文字コードは Unicode。
487: */
488: class BDF_1byte_unicode : public BDF_1byte
489: {
490: typedef BDF_1byte inherited;
491: public:
492: BDF_1byte_unicode(const char *filename, int, int, int);
493: virtual ~BDF_1byte_unicode() { }
494: virtual int GetAddr(int code) const;
495:
496: protected:
497: static const wxChar table_uni[];
498: };
499:
500: /* コンストラクタ */
501: BDF_1byte_unicode::BDF_1byte_unicode(const char *fname, int font_x, int font_y,
502: int out_offset)
503: : inherited(fname, font_x, font_y, out_offset)
504: {
505: }
506:
507: /* CGROM 収録アドレスを返す */
508: int
509: BDF_1byte_unicode::GetAddr(int code) const
510: {
511: for (int i = 0; i < 256; i++) {
512: if (code == table_uni[i]) {
513: return inherited::GetAddr(i);
514: }
515: }
516:
517: return -1;
518: }
519:
520: /*
521: * Unicode を1バイト文字コードに変換するテーブル。
522: * 制御記号(0x01〜0x1b)、矢印(0x1c〜0x1f)、チルダ(0x81)、パイプ(0x82)は
523: * ここでは扱わない。
524: */
525: const wxChar BDF_1byte_unicode::table_uni[] =
1.1.1.2 ! root 526: wxT(" ") // +00
! 527: wxT(" →←↑↓") // +10
! 528: wxT(" !”#$%&’()*+,−./") // +20
! 529: wxT("0123456789:;<=>?") // +30
! 530: wxT("@ABCDEFGHIJKLMNO") // +40
! 531: wxT("PQRSTUVWXYZ[¥]^_") // +50
! 532: wxT("`abcdefghijklmno") // +60
! 533: wxT("pqrstuvwxyz{|} ̄ ") // +70
! 534: wxT("\ をぁぃぅぇぉゃゅょっ") // +80
! 535: wxT(" あいうえおかきくけこさしすせそ") // +90
! 536: wxT(" 。「」、・ヲァィゥェォャュョッ") // +a0
! 537: wxT("ーアイウエオカキクケコサシスセソ") // +b0
! 538: wxT("タチツテトナニヌネノハヒフヘホマ") // +c0
! 539: wxT("ミムメモヤユヨラリルレロワン゛゜") // +d0
! 540: wxT("たちつてとなにぬねのはひふへほま") // +e0
! 541: wxT("みむめもやゆよらりるれろわん "); // +f0
1.1 root 542:
543:
544: /*
545: * BDF 日本語フォントから1バイトフォントを作るクラス。
546: * 文字コードは JIS X 0208 (の非漢字部分)。
547: */
548: class BDF_1byte_jis0208 : public BDF_1byte_unicode
549: {
550: typedef BDF_1byte_unicode inherited;
551: public:
552: BDF_1byte_jis0208(const char *filename, int, int, int);
553: virtual ~BDF_1byte_jis0208() { }
554: virtual int GetAddr(int code) const;
555:
556: protected:
557: static int table_jis[256];
558: static bool table_jis_prepared;
559: };
560:
561: /* JIS コードを1バイト文字コードに変換するテーブル */
562: int BDF_1byte_jis0208::table_jis[256];
563:
564: /* テーブルが用意できているか */
565: bool BDF_1byte_jis0208::table_jis_prepared;
566:
567: /* コンストラクタ */
568: BDF_1byte_jis0208::BDF_1byte_jis0208(const char *fname, int font_x, int font_y,
569: int out_offset)
570: : inherited(fname, font_x, font_y, out_offset)
571: {
572: /* 最初に一度だけ table_uni から table_jis を用意しておく */
573: if (!table_jis_prepared) {
574: for (int i = 0; i < countof(table_jis); i++) {
575: int unicode = table_uni[i];
576: table_jis[i] = Unicode2JIS(unicode);
577: }
578: table_jis_prepared = true;
579: }
580: }
581:
582: /* CGROM 収録アドレスを求める */
583: int
584: BDF_1byte_jis0208::GetAddr(int code) const
585: {
586: for (int i = 0; i < countof(table_jis); i++) {
587: if (code == table_jis[i]) {
588: return i;
589: }
590: }
591:
592: return -1;
593: }
594:
595:
596: /*
597: * BDF フォントから漢字フォントを作るクラス。
598: * 文字コードは JIS X 0208。
599: */
600: class BDF_kanji_jis0208 : public BDF
601: {
602: typedef BDF inherited;
603: public:
604: BDF_kanji_jis0208(const char *fname, int, int, int);
605: virtual ~BDF_kanji_jis0208() { }
606: virtual int GetAddr(int code) const;
607: };
608:
609: /* コンストラクタ */
610: BDF_kanji_jis0208::BDF_kanji_jis0208(const char *fname, int font_x, int font_y,
611: int out_offset)
612: : inherited(fname, font_x, font_y, out_offset)
613: {
614: }
615:
616: /* CGROM 収録コードを求めて返す */
617: int
618: BDF_kanji_jis0208::GetAddr(int code) const
619: {
620: /* JIS コードを変換するだけ */
621: return JIS2Addr(code);
622: }
623:
624:
625: /*
626: * F24 フォントから 12x12(一部)と 24x24 フォントを作るクラス
627: */
628: class F24Font : public Font
629: {
630: public:
631: F24Font(const char *fname, int out_offset);
632: virtual ~F24Font() { }
633: bool Convert();
634: };
635:
636: /* コンストラクタ */
637: F24Font::F24Font(const char *fname, int out_offset)
638: : Font(fname, 24, 24, out_offset)
639: {
640: }
641:
642: /* メイン処理 */
643: bool
644: F24Font::Convert()
645: {
1.1.1.2 ! root 646: std::vector<char> buf(pattern_len * 94); /* 1区94文字分 */
1.1 root 647: int len;
648: int i;
649: int n;
650:
651: /*
652: * 日比谷フォントは先頭に半角256文字分があるので、
653: * これの制御文字/ASCII/カナ部分を 12x24 に使う。ひらがなはない
654: */
655: len = 2 * 24;
656: for (i = 0; i < 256; i++) {
1.1.1.2 ! root 657: n = fread(&buf[0], 1, len, fp);
1.1 root 658: if (n < len) {
659: printf("fread error: %d\n", n);
660: throw 0;
661: }
662: if (IsRange(i)) {
663: cgrom.Seek(0x3d000 + i * len);
1.1.1.2 ! root 664: cgrom.Write(&buf[0], n);
1.1 root 665: }
666: }
667:
668: /* ここから 24x24 全角 */
669: cgrom.Seek(offset);
1.1.1.2 ! root 670: len = buf.size();
1.1 root 671:
672: /* 全角非漢字が8区 */
673: for (i = 1; i < 9; i++) {
1.1.1.2 ! root 674: n = fread(&buf[0], 1, len, fp);
1.1 root 675: if (n < len) {
676: printf("fread error: %d\n", n);
677: throw 0;
678: }
1.1.1.2 ! root 679: cgrom.Write(&buf[0], n);
1.1 root 680: }
681:
682: /* 9区〜15区は JIS X 0208 にはないのでスキップ */
683: for (; i < 16; i++) {
1.1.1.2 ! root 684: fseek(fp, buf.size(), SEEK_CUR);
1.1 root 685: }
686:
687: /* 16区〜83区が第一、第二水準漢字 */
688: for (; i < 84; i++) {
1.1.1.2 ! root 689: n = fread(&buf[0], 1, len, fp);
1.1 root 690: if (n < len) {
691: printf("fread error: %d\n", n);
692: throw 0;
693: }
1.1.1.2 ! root 694: cgrom.Write(&buf[0], n);
1.1 root 695: }
696:
697: /*
698: * 84区 05、06 の2文字は 90JIS で追加されたものなので、
699: * CGROM にはない。
700: */
701: len = pattern_len * 4;
1.1.1.2 ! root 702: n = fread(&buf[0], 1, len, fp);
1.1 root 703: if (n < len) {
704: printf("fread error: %d\n", n);
705: throw 0;
706: }
1.1.1.2 ! root 707: cgrom.Write(&buf[0], n);
1.1 root 708:
709: return true;
710: }
711:
712:
713: /*
714: * アプリケーションクラス
715: */
716: class MyApp : public wxApp
717: {
718: public:
719: virtual bool OnInit();
720: void MakeCGROM();
721: void MakeMon();
722:
723: private:
724: wxString outfile;
725: static const wxCmdLineEntryDesc desc[];
726: };
727:
1.1.1.2 ! root 728: // IMPLEMENT_APP() は闇マクロすぎて clang のちからには耐えられない
! 729: #if defined(__clang__)
! 730: #pragma clang diagnostic push
! 731: #pragma clang diagnostic ignored "-Weverything"
! 732: #endif
1.1 root 733: IMPLEMENT_APP(MyApp)
1.1.1.2 ! root 734: #if defined(__clang__)
! 735: #pragma clang diagnostic pop
! 736: #endif
1.1 root 737:
738: const wxCmdLineEntryDesc MyApp::desc[] = {
739: { wxCMD_LINE_OPTION, "f", "f", "font dir (default: ./fonts)", },
740: { wxCMD_LINE_OPTION, "o", "o", "output filename (default: ./cgrom.dat)", },
741: { wxCMD_LINE_SWITCH, "m", "m", "make monitor cgrom", },
742: { wxCMD_LINE_NONE, },
743: };
744:
745: bool MyApp::OnInit()
746: {
747: /* 引数解析 */
748: wxCmdLineParser cmd(argc, argv);
749: cmd.SetDesc(desc);
750: cmd.Parse();
751: ::fontdir = "./fonts";
752: outfile = "./cgrom.dat";
753: cmd.Found("f", &::fontdir);
754: cmd.Found("o", &outfile);
755:
756: if (cmd.Found("m")) {
757: // モニタウィンドウ用 12dot
758: MakeMon();
759: } else {
760: // それ以外なら X680x0 CGROM
761: MakeCGROM();
762: }
763:
764: /* 即終了する */
765: return false;
766: }
767:
768: // X680x0 CGROM を作成する
769: void
770: MyApp::MakeCGROM()
771: {
772: /* 出力ファイルを空で作成 */
773: printf("output file: %s\n", (const char *)outfile.mb_str());
774: if (!cgrom.Create(outfile, wxFile::write)) {
775: return;
776: }
777: cgrom.Seek(768 * 1024 - 1);
778: cgrom.Write("", 1);
779:
780: try {
781: BDF_1byte_jis0208 r8("misaki_gothic-hikanji.bdf", 8, 8, 0x3a000);
782: r8.Convert();
783:
784: BDF_1byte o8("nono-8x8.bdf", 8, 8, 0x3a000);
785: o8.Convert();
786:
787: BDF_1byte_jis0208 r12("shnmk12min-hikanji.bdf", 12, 12, 0x3b800);
788: r12.Convert();
789:
790: BDF_1byte o12x12("nono-12x12.bdf", 12, 12, 0x3b800);
791: o12x12.Convert();
792:
793: BDF_1byte h8("milkjf_8x16r.bdf", 8, 16, 0x3a800);
794: h8.Convert();
795:
796: BDF_1byte o8x16("nono-8x16.bdf", 8, 16, 0x3a800);
797: o8x16.Convert();
798:
799: BDF_1byte h6("shnm6x12r.bdf", 6, 12, 0xbf400);
800: h6.SetRange(R_ASCII | R_KANA);
801: h6.Convert();
802:
803: BDF_1byte o6("nono-6x12.bdf", 6, 12, 0xbf400);
804: o6.Convert();
805:
806: BDF_1byte_unicode t6("ume-tmo3-6x12-hira.bdf", 6, 12, 0xbf400);
807: t6.SetRange(R_HIRA);
808: t6.Convert();
809:
810: BDF_kanji_jis0208 k16("shnmk16min.bdf", 16, 16, 0);
811: k16.Convert();
812:
813: /* これだけ変則で 12x24 と 24x24 を生成する */
814: F24Font k24("MIN.F24", 0x40000);
815: /* これは 12x24 についての指定 */
816: k24.SetRange(R_CTRL | R_ASCII | R_KANA);
817: k24.Convert();
818:
819: BDF_1byte o24("nono-12x24.bdf", 12, 24, 0x3d000);
820: o24.Convert();
821:
822: BDF_1byte_unicode t12("ume-tmo3-12x24-hira.bdf", 12, 24, 0x3d000);
823: t12.SetRange(R_HIRA);
824: t12.Convert();
825: } catch (...) {
826: }
827:
828: cgrom.Close();
829: }
830:
831: // モニタウィンドウ用 12dot フォントデータ
832: void
833: MyApp::MakeMon()
834: {
835: // 出力ファイルを空で作成
836: printf("output file: %s\n", (const char *)outfile.mb_str());
837: if (!cgrom.Create(outfile, wxFile::write)) {
838: return;
839: }
840: try {
841: BDF_kanji_jis0208 k12("knmzn12x.bdf", 12, 12, 0);
842: k12.Convert();
843: } catch (...) {
844: }
845:
846: cgrom.Close();
847: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.