|
|
| version 1.2, 2004/06/25 10:39:27 | version 1.4, 2005/02/11 21:17:22 |
|---|---|
| Line 175 static BOOL fdatgetcache(FNTMNG fhdl, co | Line 175 static BOOL fdatgetcache(FNTMNG fhdl, co |
| fhdl->cachehead = pos; | fhdl->cachehead = pos; |
| } | } |
| if (pfdat) { | if (pfdat) { |
| *pfdat = (FNTDAT)(((BYTE *)(fhdl + 1)) + (pos * fhdl->fontalign)); | *pfdat = (FNTDAT)(((UINT8 *)(fhdl + 1)) + (pos * fhdl->fontalign)); |
| } | } |
| return(r); | return(r); |
| } | } |
| Line 232 static void getlength1(FNTMNG fhdl, FNTD | Line 232 static void getlength1(FNTMNG fhdl, FNTD |
| } | } |
| } | } |
| static BYTE getpixeldepth(SDL_Surface *s, int x, int y) { | static UINT8 getpixeldepth(SDL_Surface *s, int x, int y) { |
| int bpp; | int bpp; |
| const BYTE *ptr; | const UINT8 *ptr; |
| if ((x >= 0) && (x < s->w) && (y >= 0) && (y < s->h)) { | if ((x >= 0) && (x < s->w) && (y >= 0) && (y < s->h)) { |
| bpp = s->format->BytesPerPixel; | bpp = s->format->BytesPerPixel; |
| ptr = (BYTE *)s->pixels + (y * s->pitch) + (x * bpp); | ptr = (UINT8 *)s->pixels + (y * s->pitch) + (x * bpp); |
| switch(bpp) { | switch(bpp) { |
| case 1: | case 1: |
| return((ptr[0] != 0)?FDAT_DEPTH:0); | return((ptr[0] != 0)?FDAT_DEPTH:0); |
| Line 257 static void getfont1(FNTMNG fhdl, FNTDAT | Line 257 static void getfont1(FNTMNG fhdl, FNTDAT |
| UINT16 utext[2]; | UINT16 utext[2]; |
| SDL_Surface *text; | SDL_Surface *text; |
| BYTE *dst; | UINT8 *dst; |
| int x; | int x; |
| int y; | int y; |
| int depth; | int depth; |
| Line 265 static void getfont1(FNTMNG fhdl, FNTDAT | Line 265 static void getfont1(FNTMNG fhdl, FNTDAT |
| codecnv_sjis2utf(utext, 2, string, length); | codecnv_sjis2utf(utext, 2, string, length); |
| text = TTF_RenderUNICODE_Solid(fhdl->ttf_font, utext, white); | text = TTF_RenderUNICODE_Solid(fhdl->ttf_font, utext, white); |
| setfdathead(fhdl, fdat, length, text); | setfdathead(fhdl, fdat, length, text); |
| dst = (BYTE *)(fdat + 1); | dst = (UINT8 *)(fdat + 1); |
| if (text) { | if (text) { |
| if (fhdl->fonttype & FDAT_ALIAS) { | if (fhdl->fonttype & FDAT_ALIAS) { |
| for (y=0; y<fdat->height; y++) { | for (y=0; y<fdat->height; y++) { |
| Line 274 static void getfont1(FNTMNG fhdl, FNTDAT | Line 274 static void getfont1(FNTMNG fhdl, FNTDAT |
| depth += getpixeldepth(text, x*2+1, y*2+0); | depth += getpixeldepth(text, x*2+1, y*2+0); |
| depth += getpixeldepth(text, x*2+0, y*2+1); | depth += getpixeldepth(text, x*2+0, y*2+1); |
| depth += getpixeldepth(text, x*2+1, y*2+1); | depth += getpixeldepth(text, x*2+1, y*2+1); |
| *dst++ = (BYTE)((depth + 2) / 4); | *dst++ = (UINT8)((depth + 2) / 4); |
| } | } |
| } | } |
| } | } |
| Line 416 fmg_err: | Line 416 fmg_err: |
| #else | #else |
| #if defined(SIZE_QVGA) | |
| #include "ank10.res" | #include "ank10.res" |
| #else | |
| #include "ank12.res" | |
| #endif | |
| typedef struct { | typedef struct { |
| int fontsize; | int fontsize; |
| Line 439 void *fontmng_create(int size, UINT type | Line 443 void *fontmng_create(int size, UINT type |
| int allocsize; | int allocsize; |
| FNTMNG ret; | FNTMNG ret; |
| if (size < 10) { | if (size < ANKFONTSIZE) { |
| goto fmc_err1; | goto fmc_err1; |
| } | } |
| fontalign = sizeof(_FNTDAT) + (size * size); | fontalign = sizeof(_FNTDAT) + (size * size); |
| Line 489 static void getlength1(FNTMNG fhdl, FNTD | Line 493 static void getlength1(FNTMNG fhdl, FNTD |
| if ((c < 0) || (c >= 0x60)) { | if ((c < 0) || (c >= 0x60)) { |
| c = 0x1f; // ? | c = 0x1f; // ? |
| } | } |
| setfdathead(fhdl, fdat, ank10[c * 10]); | setfdathead(fhdl, fdat, ankfont[c * ANKFONTSIZE]); |
| } | } |
| static void getfont1(FNTMNG fhdl, FNTDAT fdat, | static void getfont1(FNTMNG fhdl, FNTDAT fdat, |
| const char *string, int length) { | const char *string, int length) { |
| int c; | int c; |
| const BYTE *src; | const UINT8 *src; |
| int width; | int width; |
| BYTE *dst; | UINT8 *dst; |
| int x; | int x; |
| int y; | int y; |
| Line 506 const BYTE *src; | Line 510 const BYTE *src; |
| if ((c < 0) || (c >= 0x60)) { | if ((c < 0) || (c >= 0x60)) { |
| c = 0x1f; // ? | c = 0x1f; // ? |
| } | } |
| src = ank10 + c * 10; | src = ankfont + (c * ANKFONTSIZE); |
| width = *src++; | width = *src++; |
| setfdathead(fhdl, fdat, width); | setfdathead(fhdl, fdat, width); |
| dst = (BYTE *)(fdat + 1); | dst = (UINT8 *)(fdat + 1); |
| ZeroMemory(dst, fdat->width * fdat->height); | ZeroMemory(dst, fdat->width * fdat->height); |
| dst += ((fdat->height - 10) / 2) * fdat->width; | dst += ((fdat->height - ANKFONTSIZE) / 2) * fdat->width; |
| dst += (fdat->width - width) / 2; | dst += (fdat->width - width) / 2; |
| for (y=0; y<9; y++) { | for (y=0; y<(ANKFONTSIZE - 1); y++) { |
| dst += fdat->width; | dst += fdat->width; |
| for (x=0; x<width; x++) { | for (x=0; x<width; x++) { |
| dst[x] = (src[0] & (0x80 >> x))?0xff:0x00; | dst[x] = (src[0] & (0x80 >> x))?0xff:0x00; |