Last active
August 29, 2015 14:25
-
-
Save deton/acf8f59e27b25d547bb1 to your computer and use it in GitHub Desktop.
bdf2fontx.cをANKフォント対応するパッチ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- bdf2fontx.c.orig 2001-12-07 01:51:03.000000000 +0900 | |
+++ bdf2fontx.c 2015-07-20 14:52:11.000000000 +0900 | |
@@ -106,6 +106,9 @@ void bdfheader(char *name, int *width, i | |
else if (match(coding, "jisx0208") == 0) { | |
*type = 1; | |
} | |
+ else { | |
+ *type = 0; | |
+ } | |
break; | |
} | |
} | |
@@ -199,18 +202,28 @@ int collect(FILE *co, FILE *gl, int widt | |
*ntab = 0; | |
chars = 0; | |
- start = lastcode = 0; | |
+ start = 0; | |
+ lastcode = -1; /* code 0がある場合用 */ | |
convwidth = ((width + 7) / 8) * 8; /* 横ドット数を8の倍数に切り上げ */ | |
while(fgets(s, BUFSIZ, stdin) != NULL) { | |
if (match(s, "ENCODING") == 0) { | |
sscanf(s, "ENCODING %d", &n); | |
- code = jtos(n); | |
+ code = (n < 256) ? n : jtos(n); | |
if (lastcode + 1 != code) { | |
if (start != 0) { | |
fprintf(co, "%04x %04x\n", start, lastcode); | |
++*ntab; | |
} | |
start = code; | |
+ if (type == 0) { /* ANK fontはべた埋め。TODO:順番でない場合 */ | |
+ for (++lastcode; lastcode < code; ++lastcode) { | |
+ for (y = 0; y < height; y++) { | |
+ for (x = convwidth; x > 0; x -= 8) { | |
+ putc(0, gl); | |
+ } | |
+ } | |
+ } | |
+ } | |
} | |
lastcode = code; | |
while (match(s, "BITMAP") != 0) { | |
@@ -239,6 +252,15 @@ int collect(FILE *co, FILE *gl, int widt | |
} | |
fprintf(co, "%x %x\n", start, lastcode); | |
++*ntab; | |
+ if (type == 0) { /* ANK fontは0xffまでべた埋め */ | |
+ for (++lastcode; lastcode < 256; ++lastcode) { | |
+ for (y = 0; y < height; y++) { | |
+ for (x = convwidth; x > 0; x -= 8) { | |
+ putc(0, gl); | |
+ } | |
+ } | |
+ } | |
+ } | |
return(chars); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment