--- xmil/win9x/fontmng.cpp 2004/08/01 05:31:31 1.1 +++ xmil/win9x/fontmng.cpp 2004/08/03 12:50:54 1.2 @@ -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,6 +132,7 @@ void fontmng_destroy(void *hdl) { } +#if !defined(UNICODE) static void getlength1(FNTMNG fhdl, FNTDAT fdat, const char *string, int length) { @@ -154,6 +155,57 @@ static void getlength1(FNTMNG fhdl, FNTD fdat->height = fhdl->fontheight; } +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); +} +#else +static void getlength1(FNTMNG fhdl, FNTDAT fdat, + const char *string, int length) { + + TCHAR work[4]; + int leng; + SIZE fntsize; + + if (fhdl->fonttype & FDAT_PROPORTIONAL) { + leng = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, string, -1, + work, NELEMENTS(work)) - 1; + GetTextExtentPoint32(fhdl->hdcimage, work, leng, &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->height = fhdl->fontheight; +} + +static void fontmng_getchar(FNTMNG fhdl, FNTDAT fdat, const char *string) { + + TCHAR work[4]; + int leng; + + FillRect(fhdl->hdcimage, &fhdl->rect, + (HBRUSH)GetStockObject(BLACK_BRUSH)); + leng = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, string, -1, + work, NELEMENTS(work)) - 1; + TextOut(fhdl->hdcimage, 0, 0, work, leng); + getlength1(fhdl, fdat, string, leng); +} +#endif + BOOL fontmng_getsize(void *hdl, const char *string, POINT_T *pt) { @@ -198,7 +250,6 @@ fmgs_exit: return(FAILURE); } - BOOL fontmng_getdrawsize(void *hdl, const char *string, POINT_T *pt) { char buf[4]; @@ -245,19 +296,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) { DWORD remx;