--- np2/sdl/fontmng.c 2004/06/25 11:47:11 1.3 +++ np2/sdl/fontmng.c 2005/02/13 05:31:26 1.5 @@ -175,7 +175,7 @@ static BOOL fdatgetcache(FNTMNG fhdl, co fhdl->cachehead = pos; } if (pfdat) { - *pfdat = (FNTDAT)(((BYTE *)(fhdl + 1)) + (pos * fhdl->fontalign)); + *pfdat = (FNTDAT)(((UINT8 *)(fhdl + 1)) + (pos * fhdl->fontalign)); } return(r); } @@ -220,7 +220,7 @@ static void getlength1(FNTMNG fhdl, FNTD SDL_Surface *text; if (fhdl->fonttype & FDAT_PROPORTIONAL) { - codecnv_sjis2utf(utext, 2, string, length); + codecnv_euctoucs2(utext, NELEMENTS(utext), string, length); text = TTF_RenderUNICODE_Solid(fhdl->ttf_font, utext, white); setfdathead(fhdl, fdat, length, text); if (text) { @@ -232,14 +232,14 @@ 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; -const BYTE *ptr; +const UINT8 *ptr; if ((x >= 0) && (x < s->w) && (y >= 0) && (y < s->h)) { bpp = s->format->BytesPerPixel; - ptr = (BYTE *)s->pixels + (y * s->pitch) + (x * bpp); + ptr = (UINT8 *)s->pixels + (y * s->pitch) + (x * bpp); switch(bpp) { case 1: return((ptr[0] != 0)?FDAT_DEPTH:0); @@ -257,15 +257,15 @@ static void getfont1(FNTMNG fhdl, FNTDAT UINT16 utext[2]; SDL_Surface *text; - BYTE *dst; + UINT8 *dst; int x; int y; int depth; - codecnv_sjis2utf(utext, 2, string, length); + codecnv_euctoucs2(utext, NELEMENTS(utext), string, length); text = TTF_RenderUNICODE_Solid(fhdl->ttf_font, utext, white); setfdathead(fhdl, fdat, length, text); - dst = (BYTE *)(fdat + 1); + dst = (UINT8 *)(fdat + 1); if (text) { if (fhdl->fonttype & FDAT_ALIAS) { for (y=0; yheight; y++) { @@ -274,7 +274,7 @@ static void getfont1(FNTMNG fhdl, FNTDAT depth += getpixeldepth(text, x*2+1, y*2+0); depth += getpixeldepth(text, x*2+0, y*2+1); depth += getpixeldepth(text, x*2+1, y*2+1); - *dst++ = (BYTE)((depth + 2) / 4); + *dst++ = (UINT8)((depth + 2) / 4); } } } @@ -292,43 +292,30 @@ static void getfont1(FNTMNG fhdl, FNTDAT } } -BOOL fontmng_getsize(void *hdl, const char *string, POINT_T *pt) { +BRESULT fontmng_getsize(void *hdl, const char *string, POINT_T *pt) { - FNTMNG fhdl; - char buf[4]; - _FNTDAT fdat; int width; int leng; + _FNTDAT fdat; if ((hdl == NULL) || (string == NULL)) { goto fmgs_exit; } - fhdl = (FNTMNG)hdl; width = 0; - buf[2] = '\0'; while(1) { - buf[0] = *string++; - if ((((buf[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c) { - buf[1] = *string++; - if (buf[1] == '\0') { - break; - } - leng = 2; - } - else if (buf[0]) { - buf[1] = '\0'; - leng = 1; - } - else { + leng = milstr_charsize(string); + if (!leng) { break; } - getlength1(fhdl, &fdat, buf, leng); + getlength1((FNTMNG)hdl, &fdat, string, leng); + string += leng; width += fdat.pitch; } + if (pt) { pt->x = width; - pt->y = fhdl->fontsize; + pt->y = ((FNTMNG)hdl)->fontsize; } return(SUCCESS); @@ -336,46 +323,32 @@ fmgs_exit: return(FAILURE); } -BOOL fontmng_getdrawsize(void *hdl, const char *string, POINT_T *pt) { +BRESULT fontmng_getdrawsize(void *hdl, const char *string, POINT_T *pt) { - FNTMNG fhdl; - char buf[4]; - _FNTDAT fdat; int width; - int leng; int posx; + int leng; + _FNTDAT fdat; if ((hdl == NULL) || (string == NULL)) { goto fmgds_exit; } - fhdl = (FNTMNG)hdl; width = 0; posx = 0; - buf[2] = '\0'; while(1) { - buf[0] = *string++; - if ((((buf[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c) { - buf[1] = *string++; - if (buf[1] == '\0') { - break; - } - leng = 2; - } - else if (buf[0]) { - buf[1] = '\0'; - leng = 1; - } - else { + leng = milstr_charsize(string); + if (!leng) { break; } - getlength1(fhdl, &fdat, buf, leng); + getlength1((FNTMNG)hdl, &fdat, string, leng); + string += leng; width = posx + max(fdat.width, fdat.pitch); posx += fdat.pitch; } if (pt) { pt->x = width; - pt->y = fhdl->fontsize; + pt->y = ((FNTMNG)hdl)->fontsize; } return(SUCCESS); @@ -402,11 +375,7 @@ FNTDAT fontmng_get(void *hdl, const char fdat = (FNTDAT)(fhdl + 1); #endif - leng = 1; - if (((((string[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c) && - (string[1] != '\0')) { - leng = 2; - } + leng = milstr_charsize(string); getfont1(fhdl, fdat, string, leng); return(fdat); @@ -500,9 +469,9 @@ static void getfont1(FNTMNG fhdl, FNTDAT const char *string, int length) { int c; -const BYTE *src; +const UINT8 *src; int width; - BYTE *dst; + UINT8 *dst; int x; int y; @@ -513,7 +482,7 @@ const BYTE *src; src = ankfont + (c * ANKFONTSIZE); width = *src++; setfdathead(fhdl, fdat, width); - dst = (BYTE *)(fdat + 1); + dst = (UINT8 *)(fdat + 1); ZeroMemory(dst, fdat->width * fdat->height); dst += ((fdat->height - ANKFONTSIZE) / 2) * fdat->width; dst += (fdat->width - width) / 2; @@ -526,7 +495,7 @@ const BYTE *src; } } -BOOL fontmng_getsize(void *hdl, const char *string, POINT_T *pt) { +BRESULT fontmng_getsize(void *hdl, const char *string, POINT_T *pt) { FNTMNG fhdl; char buf[4]; @@ -570,7 +539,7 @@ fmgs_exit: return(FAILURE); } -BOOL fontmng_getdrawsize(void *hdl, const char *string, POINT_T *pt) { +BRESULT fontmng_getdrawsize(void *hdl, const char *string, POINT_T *pt) { FNTMNG fhdl; char buf[4];