--- np2/wince/fontmng.cpp 2003/10/16 17:59:33 1.1 +++ np2/wince/fontmng.cpp 2005/02/11 21:17:23 1.7 @@ -6,8 +6,8 @@ #if defined(FONTMNG_CACHE) typedef struct { - WORD str; - WORD next; + UINT str; + UINT next; } FNTCTBL; #endif @@ -21,7 +21,7 @@ typedef struct { // あとは拡張〜 HDC hdcimage; HBITMAP hBitmap; - BYTE *image; + UINT8 *image; HFONT hfont; RECT rect; int bmpwidth; @@ -29,15 +29,15 @@ typedef struct { int bmpalign; #if defined(FONTMNG_CACHE) - DWORD caches; - DWORD cachehead; + UINT caches; + UINT cachehead; FNTCTBL cache[FONTMNG_CACHE]; #endif } _FNTMNG, *FNTMNG; -static const TCHAR deffontface[] = STRLITERAL("MS ゴシック"); -static const TCHAR deffontface2[] = STRLITERAL("MS Pゴシック"); +static const TCHAR deffontface[] = _T("MS ゴシック"); +static const TCHAR deffontface2[] = _T("MS Pゴシック"); #ifndef _WIN32_WCE #define TEXTALPHABASE (FDAT_DEPTH * 0x60 / 256) @@ -128,7 +128,7 @@ void *fontmng_create(int size, UINT type ret->bmpheight = bmpheight; ret->bmpalign = (((bmpwidth + 31) / 8) & (~3)); - bi = (BITMAPINFO *)(((BYTE *)(ret + 1)) + fontwork); + bi = (BITMAPINFO *)(((UINT8 *)(ret + 1)) + fontwork); bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bi->bmiHeader.biWidth = ret->bmpwidth; bi->bmiHeader.biHeight = ret->bmpheight; @@ -188,7 +188,6 @@ void *fontmng_create(int size, UINT type return(ret); } - void fontmng_destroy(void *hdl) { FNTMNG fhdl; @@ -203,7 +202,9 @@ void fontmng_destroy(void *hdl) { } -#ifdef _WIN32_WCE +// ---- + +#ifdef UNICODE static void getlength1(FNTMNG fhdl, FNTDAT fdat, LPCTSTR string, int tleng, int length) { @@ -218,9 +219,12 @@ static void getlength1(FNTMNG fhdl, FNTD fdat->height = fhdl->bmpheight >> 1; } else { - fntsize.cx = min(fntsize.cx, fhdl->bmpwidth); - fdat->width = fntsize.cx; - fdat->pitch = fntsize.cx; +#if 1 // PocketPCのみ戻り値が変らしい? + fdat->width = min(fntsize.cx, fhdl->bmpwidth); +#else + fdat->width = min(fntsize.cx + 1, fhdl->bmpwidth); +#endif + fdat->pitch = min(fntsize.cx, fhdl->bmpwidth); fdat->height = fhdl->bmpheight; } } @@ -258,7 +262,6 @@ static void fontmng_getchar(FNTMNG fhdl, getlength1(fhdl, fdat, txtwork, len, leng); } - BOOL fontmng_getsize(void *hdl, const char *string, POINT_T *pt) { TCHAR txtwork[4]; @@ -268,11 +271,10 @@ BOOL fontmng_getsize(void *hdl, const ch DWORD len; int leng; - width = 0; if ((hdl == NULL) || (string == NULL)) { goto fmgs_exit; } - + width = 0; buf[2] = '\0'; do { buf[0] = *string++; @@ -306,7 +308,6 @@ fmgs_exit: return(FAILURE); } - BOOL fontmng_getdrawsize(void *hdl, const char *string, POINT_T *pt) { TCHAR txtwork[4]; @@ -357,7 +358,6 @@ fmgds_exit: return(FAILURE); } - #else static void getlength1(FNTMNG fhdl, FNTDAT fdat, @@ -398,7 +398,6 @@ static void getlength1(FNTMNG fhdl, FNTD } } - static void fontmng_getchar(FNTMNG fhdl, FNTDAT fdat, const char *string) { int leng; @@ -410,7 +409,6 @@ static void fontmng_getchar(FNTMNG fhdl, getlength1(fhdl, fdat, string, leng); } - BOOL fontmng_getsize(void *hdl, const char *string, POINT_T *pt) { char buf[4]; @@ -454,7 +452,6 @@ fmgs_exit: return(FAILURE); } - BOOL fontmng_getdrawsize(void *hdl, const char *string, POINT_T *pt) { char buf[4]; @@ -502,16 +499,17 @@ fmgds_exit: } #endif - static void fontmng_setpat(FNTMNG fhdl, FNTDAT fdat) { - DWORD remx; - DWORD remy; - BYTE *src; - BYTE *dst; - BYTE *s1, *s2; - BYTE bit; - BYTE b1, b2; + UINT remx; + UINT remy; + UINT8 *src; + UINT8 *dst; + UINT8 *s1; + UINT8 *s2; + UINT8 bit; + UINT b1; + UINT b2; int align; int c; @@ -521,7 +519,7 @@ static void fontmng_setpat(FNTMNG fhdl, goto fmsp_end; } - dst = (BYTE *)(fdat + 1); + dst = (UINT8 *)(fdat + 1); align *= -1; if (fhdl->fonttype & FDAT_ALIAS) { @@ -553,7 +551,7 @@ static void fontmng_setpat(FNTMNG fhdl, c += (FDAT_DEPTH - TEXTALPHABASE); } if (c) { - *dst++ = (BYTE)(TEXTALPHABASE + (c / 4)); + *dst++ = (UINT8)(TEXTALPHABASE + (c / 4)); } else { *dst++ = 0; @@ -586,8 +584,7 @@ fmsp_end: return; } - -FNTDAT fontmng_get(void *hdl, const char *string) { +FNTDAT fontmng_get(void *hdl, const OEMCHAR *string) { FNTMNG fhdl; FNTDAT fdat; @@ -600,13 +597,34 @@ FNTDAT fontmng_get(void *hdl, const char #if defined(FONTMNG_CACHE) { FNTCTBL *fct; - DWORD str; - DWORD pos; - DWORD prev; - DWORD cnt; + UINT str; + UINT pos; + UINT prev; + UINT cnt; + +#if defined(OSLANG_SJIS) || defined(OSLANG_SJIS) + int len; + len = milstr_charsize(string); + switch(len) { + default: + str = (UINT8)string[0]; + break; + + case 2: + str = (UINT8)string[0] + (((UINT8)string[1]) << 8); + break; + + case 3: + str = (UINT8)string[0] + (((UINT8)string[1]) << 8) + (((UINT8)string[2]) << 16); + break; - str = string[0] & 0xff; - str |= (string[1] & 0xff) << 8; + case 4: + str = (UINT8)string[0] + (((UINT8)string[1]) << 8) + (((UINT8)string[2]) << 16) + (((UINT8)string[2]) << 24); + break; + } +#else + str = (UINT)string[0]; +#endif fct = fhdl->cache; cnt = fhdl->caches; @@ -620,19 +638,19 @@ FNTDAT fontmng_get(void *hdl, const char } if (prev < FONTMNG_CACHE) { fct[prev].next = fct[pos].next; - fct[pos].next = (WORD)fhdl->cachehead; + fct[pos].next = fhdl->cachehead; fhdl->cachehead = pos; } - return((FNTDAT)(((BYTE *)(fhdl + 1)) + (pos * fhdl->fontalign))); + return((FNTDAT)(((UINT8 *)(fhdl + 1)) + (pos * fhdl->fontalign))); } if (fhdl->caches < FONTMNG_CACHE) { prev = fhdl->caches; fhdl->caches++; } - fct[prev].str = (WORD)str; - fct[prev].next = (WORD)fhdl->cachehead; + fct[prev].str = str; + fct[prev].next = fhdl->cachehead; fhdl->cachehead = prev; - fdat = (FNTDAT)(((BYTE *)(fhdl + 1)) + (prev * fhdl->fontalign)); + fdat = (FNTDAT)(((UINT8 *)(fhdl + 1)) + (prev * fhdl->fontalign)); } #else fdat = (FNTDAT)(fhdl + 1);