--- np2/win9x/fontmng.cpp 2005/02/07 14:46:14 1.2 +++ np2/win9x/fontmng.cpp 2005/02/09 20:11:35 1.3 @@ -20,11 +20,11 @@ typedef struct { } _FNTMNG, *FNTMNG; -static const TCHAR deffontface[] = "£Í£Ó ¥´¥·¥Ã¥¯"; -static const TCHAR deffontface2[] = "£Í£Ó £Ð¥´¥·¥Ã¥¯"; +static const OEMCHAR deffontface[] = OEMTEXT("£Í£Ó ¥´¥·¥Ã¥¯"); +static const OEMCHAR deffontface2[] = OEMTEXT("£Í£Ó £Ð¥´¥·¥Ã¥¯"); -void *fontmng_create(int size, UINT type, const TCHAR *fontface) { +void *fontmng_create(int size, UINT type, const OEMCHAR *fontface) { int i; int fontalign; @@ -132,32 +132,39 @@ void fontmng_destroy(void *hdl) { } +// ---- + static void getlength1(FNTMNG fhdl, FNTDAT fdat, - const char *string, int length) { + const OEMCHAR *string, int length) { SIZE fntsize; - if ((fhdl->fonttype & FDAT_PROPORTIONAL) && - (GetTextExtentPoint32(fhdl->hdcimage, string, length, &fntsize))) { + if (GetTextExtentPoint32(fhdl->hdcimage, string, length, &fntsize)) { fntsize.cx = min(fntsize.cx, fhdl->bmpwidth); fdat->width = fntsize.cx; fdat->pitch = fntsize.cx; } - else if (length < 2) { - fdat->width = fhdl->fontwidth; - fdat->pitch = (fhdl->fontsize + 1) >> 1; - } else { fdat->width = fhdl->fontwidth; - fdat->pitch = fhdl->fontsize; + fdat->pitch = (fhdl->fontsize + 1) >> 1; } fdat->height = fhdl->fontheight; } +static void fontmng_getchar(FNTMNG fhdl, FNTDAT fdat, const OEMCHAR *string) { + + int leng; + + FillRect(fhdl->hdcimage, &fhdl->rect, + (HBRUSH)GetStockObject(BLACK_BRUSH)); + leng = milstr_charsize(string); + TextOut(fhdl->hdcimage, 0, 0, string, leng); + getlength1(fhdl, fdat, string, leng); +} -BOOL fontmng_getsize(void *hdl, const char *string, POINT_T *pt) { +BRESULT fontmng_getsize(void *hdl, const OEMCHAR *string, POINT_T *pt) { - char buf[4]; + OEMCHAR buf[4]; _FNTDAT fdat; int width; int leng; @@ -167,26 +174,17 @@ BOOL fontmng_getsize(void *hdl, const ch goto fmgs_exit; } - buf[2] = '\0'; - do { - 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 { + while(1) { + leng = milstr_charsize(string); + if (!leng) { break; } + CopyMemory(buf, string, leng * sizeof(OEMCHAR)); + buf[leng] = '\0'; + string += leng; getlength1((FNTMNG)hdl, &fdat, buf, leng); width += fdat.pitch; - } while(1); + } if (pt) { pt->x = width; @@ -198,10 +196,9 @@ fmgs_exit: return(FAILURE); } +BRESULT fontmng_getdrawsize(void *hdl, const OEMCHAR *string, POINT_T *pt) { -BOOL fontmng_getdrawsize(void *hdl, const char *string, POINT_T *pt) { - - char buf[4]; + OEMCHAR buf[4]; _FNTDAT fdat; int width; int posx; @@ -213,27 +210,18 @@ BOOL fontmng_getdrawsize(void *hdl, cons width = 0; posx = 0; - buf[2] = '\0'; - do { - 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 { + while(1) { + leng = milstr_charsize(string); + if (!leng) { break; } + CopyMemory(buf, string, leng * sizeof(OEMCHAR)); + buf[leng] = '\0'; + string += leng; getlength1((FNTMNG)hdl, &fdat, buf, leng); width = posx + max(fdat.width, fdat.pitch); posx += fdat.pitch; - } while(1); + } if (pt) { pt->x = width; @@ -245,19 +233,6 @@ fmgds_exit: return(FAILURE); } - -static void fontmng_getchar(FNTMNG fhdl, FNTDAT fdat, const char *string) { - - int leng; - - FillRect(fhdl->hdcimage, &fhdl->rect, - (HBRUSH)GetStockObject(BLACK_BRUSH)); - leng = strlen(string); - TextOut(fhdl->hdcimage, 0, 0, string, leng); - getlength1(fhdl, fdat, string, leng); -} - - static void fontmng_setpat(FNTMNG fhdl, FNTDAT fdat) { UINT remx; @@ -301,7 +276,7 @@ fmsp_end: // ---- -FNTDAT fontmng_get(void *hdl, const char *string) { +FNTDAT fontmng_get(void *hdl, const OEMCHAR *string) { FNTMNG fhdl; FNTDAT fdat;