diff --git a/projects/mtg/bin/Res/graphics/f3.asc b/projects/mtg/bin/Res/graphics/f3.asc index 65d42cc71..8a093a9c2 100644 Binary files a/projects/mtg/bin/Res/graphics/f3.asc and b/projects/mtg/bin/Res/graphics/f3.asc differ diff --git a/projects/mtg/bin/Res/graphics/f3.gbk b/projects/mtg/bin/Res/graphics/f3.gbk index 27a7062b4..e5dbf010a 100644 Binary files a/projects/mtg/bin/Res/graphics/f3.gbk and b/projects/mtg/bin/Res/graphics/f3.gbk differ diff --git a/projects/mtg/bin/Res/graphics/magic.asc b/projects/mtg/bin/Res/graphics/magic.asc index 20a2e0022..8132607e6 100644 Binary files a/projects/mtg/bin/Res/graphics/magic.asc and b/projects/mtg/bin/Res/graphics/magic.asc differ diff --git a/projects/mtg/bin/Res/graphics/magic.gbk b/projects/mtg/bin/Res/graphics/magic.gbk index caf4bd927..d6eab9f16 100644 Binary files a/projects/mtg/bin/Res/graphics/magic.gbk and b/projects/mtg/bin/Res/graphics/magic.gbk differ diff --git a/projects/mtg/bin/Res/graphics/simon.asc b/projects/mtg/bin/Res/graphics/simon.asc index 4579b6fb0..ed38f01b2 100644 Binary files a/projects/mtg/bin/Res/graphics/simon.asc and b/projects/mtg/bin/Res/graphics/simon.asc differ diff --git a/projects/mtg/bin/Res/graphics/simon.gbk b/projects/mtg/bin/Res/graphics/simon.gbk index 74d0f8015..99bf8605f 100644 Binary files a/projects/mtg/bin/Res/graphics/simon.gbk and b/projects/mtg/bin/Res/graphics/simon.gbk differ diff --git a/projects/mtg/bin/Res/graphics/smallface.asc b/projects/mtg/bin/Res/graphics/smallface.asc index 9e89f7bd0..48a8a25e8 100644 Binary files a/projects/mtg/bin/Res/graphics/smallface.asc and b/projects/mtg/bin/Res/graphics/smallface.asc differ diff --git a/projects/mtg/bin/Res/graphics/smallface.gbk b/projects/mtg/bin/Res/graphics/smallface.gbk index 3508581dc..608dedc80 100644 Binary files a/projects/mtg/bin/Res/graphics/smallface.gbk and b/projects/mtg/bin/Res/graphics/smallface.gbk differ diff --git a/projects/mtg/tools/neofont/Makefile b/projects/mtg/tools/neofont/Makefile index 22411128e..5b32bd4b2 100644 --- a/projects/mtg/tools/neofont/Makefile +++ b/projects/mtg/tools/neofont/Makefile @@ -10,3 +10,7 @@ neofont : neofont.o clean : @rm -f neofont *.o *.asc *.gbk + +update : neofont fallback.ttf gkai00mp.ttf mono.ttf + @./neofont && mv *.asc *.gbk ../../Res/graphics/ + diff --git a/projects/mtg/tools/neofont/README b/projects/mtg/tools/neofont/README index 7b26653dd..6146da182 100644 --- a/projects/mtg/tools/neofont/README +++ b/projects/mtg/tools/neofont/README @@ -1,2 +1,2 @@ -fallback.ttf from http://android.git.kernel.org/?p=platform/frameworks/base.git;a=tree;f=data/fonts;hb=HEAD +fallback.ttf & mono.ttf from http://android.git.kernel.org/?p=platform/frameworks/base.git;a=tree;f=data/fonts;hb=HEAD gkai00mp.ttf from http://cle.linux.org.tw/fonts/Arphic/ diff --git a/projects/mtg/tools/neofont/mono.ttf b/projects/mtg/tools/neofont/mono.ttf new file mode 100644 index 000000000..6e79dad17 Binary files /dev/null and b/projects/mtg/tools/neofont/mono.ttf differ diff --git a/projects/mtg/tools/neofont/neofont.c b/projects/mtg/tools/neofont/neofont.c index 4a8ce33f8..03bf9f5f9 100644 --- a/projects/mtg/tools/neofont/neofont.c +++ b/projects/mtg/tools/neofont/neofont.c @@ -27,6 +27,85 @@ unsigned short to_unicode(char * szStr) #endif } +unsigned char islot[5][16 * 16 / 2]; +unsigned char pspicons[5] = {0xA1, 0xf7, 0xf0, 0xc1, 0xf5}; + +int render_icon12(const char * szFilename) +{ + FT_Face face; + unsigned char i, j, y; + + if (FT_New_Face(m_library, szFilename, 0, &face) != 0) + return -1; + + if (FT_Set_Char_Size(face, 0, 20 * 64, 72, 0) != 0) { + FT_Done_Face(face); + return -1; + } + + for (j = 0; j < 5; j ++) { + unsigned char s[3] = {(unsigned char)0xa1, pspicons[j], 0}; + unsigned short code = to_unicode((char *)s); + memset(islot[j], 0, 12 * 12 / 2); + if (code && FT_Load_Char(face, code, FT_LOAD_RENDER) == 0) { + if (face->glyph->bitmap.buffer != NULL && face->glyph->bitmap_top > 0) { + if (j == 0) continue; + unsigned char left = 1; + for (y = 0; y < face->glyph->bitmap.rows; y++) { + unsigned char h = 1 + y; + unsigned char l = face->glyph->bitmap.pitch; + unsigned char u = 0; + for (u = 0; u < l; u++) + islot[j][(h * 12 + left + u) / 2] + |= (face->glyph->bitmap.buffer[y * face->glyph->bitmap.pitch + u] + & 0xF0) >> 4 * (1 - (left + u) & 1); + } + } + } + } + + FT_Done_Face(face); + return 0; +} + +int render_icon16(const char * szFilename) +{ + FT_Face face; + unsigned char i, j, y; + + if (FT_New_Face(m_library, szFilename, 0, &face) != 0) + return -1; + + if (FT_Set_Char_Size(face, 0, 30 * 64, 72, 0) != 0) { + FT_Done_Face(face); + return -1; + } + for (j = 0; j < 5; j ++) + { + unsigned char s[3] = {(unsigned char)0xa1, pspicons[j], 0}; + unsigned short code = to_unicode((char *)s); + memset(islot[j], 0, 16 * 16 / 2); + if (code && FT_Load_Char(face, code, FT_LOAD_RENDER) == 0) { + if (face->glyph->bitmap.buffer != NULL && face->glyph->bitmap_top > 0) { + if (j == 0) continue; + unsigned char left = 1; + for (y = 0; y < face->glyph->bitmap.rows; y++) { + unsigned char h = 2 + y; + unsigned char l = face->glyph->bitmap.pitch; + unsigned char u = 0; + for (u = 0; u < l; u++) + islot[j][(h * 16 + left + u) / 2] + |= (face->glyph->bitmap.buffer[y * face->glyph->bitmap.pitch + u] + & 0xF0) >> 4 * (1 - (left + u) & 1); + } + } + } + } + + FT_Done_Face(face); + return 0; +} + int render_cn12(const char * szFilename, const char * szOutputname) { unsigned char zslot[12 * 12 / 2]; @@ -77,7 +156,15 @@ int render_cn12(const char * szFilename, const char * szOutputname) } } } - if (i == 0xA1 && j == 0xA1) memset(zslot, 0, 12 * 12 / 2); + if (i == 0xA1) { + switch (j) { + case 0xA1: memcpy(zslot, islot[0], 12 * 12 / 2); break; + case 0xF7: memcpy(zslot, islot[1], 12 * 12 / 2); break; + case 0xF0: memcpy(zslot, islot[2], 12 * 12 / 2); break; + case 0xC1: memcpy(zslot, islot[3], 12 * 12 / 2); break; + case 0xF5: memcpy(zslot, islot[4], 12 * 12 / 2); break; + } + } fwrite(zslot, sizeof(unsigned char), 12 * 12 / 2, fp); } } @@ -97,11 +184,12 @@ int render_cn16(const char * szFilename, const char * szOutputname) if (FT_New_Face(m_library, szFilename, 0, &face) != 0) return -1; - + if (FT_Set_Char_Size(face, 0, 16 * 64, 72, 0) != 0 || (fp = fopen(szOutputname,"w")) == NULL) { FT_Done_Face(face); return -1; } + #if 0 // GBK encoding for (i = 0x81; i < 0xFF; i ++) { @@ -137,7 +225,15 @@ int render_cn16(const char * szFilename, const char * szOutputname) } } } - if (i == 0xA1 && j == 0xA1) memset(zslot, 0, 16 * 16 / 2); + if (i == 0xA1) { + switch (j) { + case 0xA1: memcpy(zslot, islot[0], 16 * 16 / 2); break; + case 0xF7: memcpy(zslot, islot[1], 16 * 16 / 2); break; + case 0xF0: memcpy(zslot, islot[2], 16 * 16 / 2); break; + case 0xC1: memcpy(zslot, islot[3], 16 * 16 / 2); break; + case 0xF5: memcpy(zslot, islot[4], 16 * 16 / 2); break; + } + } fwrite(zslot, sizeof(unsigned char), 16 * 16 / 2, fp); } } @@ -196,7 +292,7 @@ int render_en12(const char * szFilename, const char * szOutputname) if (FT_New_Face(m_library, szFilename, 0, &face) != 0) return -1; - if (FT_Set_Char_Size(face, 0, 10 * 64, 72, 0) != 0 || (fp = fopen(szOutputname,"w")) == NULL) { + if (FT_Set_Char_Size(face, 0, 11 * 64, 72, 0) != 0 || (fp = fopen(szOutputname,"w")) == NULL) { FT_Done_Face(face); return -1; } @@ -236,7 +332,7 @@ int render_en16(const char * szFilename, const char * szOutputname) if (FT_New_Face(m_library, szFilename, 0, &face) != 0) return -1; - if (FT_Set_Char_Size(face, 0, 12 * 64, 72, 0) != 0 || (fp = fopen(szOutputname,"w")) == NULL) { + if (FT_Set_Char_Size(face, 0, 14 * 64, 72, 0) != 0 || (fp = fopen(szOutputname,"w")) == NULL) { FT_Done_Face(face); return -1; } @@ -246,7 +342,7 @@ int render_en16(const char * szFilename, const char * szOutputname) if (code > 0x20 && FT_Load_Char(face, code, FT_LOAD_RENDER) == 0) { if (face->glyph->bitmap.buffer != NULL && face->glyph->bitmap_top > 0) { for (y = 0; y < face->glyph->bitmap.rows && y < 16 && y - face->glyph->bitmap_top < 2; y++) { - unsigned char h = 16 - 2 - face->glyph->bitmap_top + y; + unsigned char h = 15 - 2 - face->glyph->bitmap_top + y; unsigned char u = 0; unsigned char left = face->glyph->bitmap.pitch > 8 ? 1 : 0; for (u = 0; u < left + face->glyph->bitmap.pitch; u++) @@ -274,15 +370,18 @@ int main() ic = iconv_open("unicode", "gb2312"); if (ic == 0) printf("Error initializing iconv!\n"); + render_icon12("fallback.ttf"); render_cn12("fallback.ttf", "simon.gbk"); - render_en12("fallback.ttf", "simon.asc"); - render_cn16("fallback.ttf", "f3.gbk"); - render_en16("fallback.ttf", "f3.asc"); - render_cn16("gkai00mp.ttf", "magic.gbk"); - render_en16("gkai00mp.ttf", "magic.asc"); + render_en12("mono.ttf", "simon.asc"); render_cn12("gkai00mp.ttf", "smallface.gbk"); render_en12("gkai00mp.ttf", "smallface.asc"); + render_icon16("fallback.ttf"); + render_cn16("fallback.ttf", "f3.gbk"); + render_en16("mono.ttf", "f3.asc"); + render_cn16("gkai00mp.ttf", "magic.gbk"); + render_en16("gkai00mp.ttf", "magic.asc"); + iconv_close(ic); FT_Done_FreeType(m_library); printf("done\n");