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