| version 1.1.1.1, 2003/10/16 17:58:46 | version 1.5, 2005/02/13 05:31:26 | 
| Line 11  typedef struct { | Line 11  typedef struct { | 
 | // ¤¢¤È¤Ï³ÈÄ¥¡Á | // ¤¢¤È¤Ï³ÈÄ¥¡Á | 
 | HDC                     hdcimage; | HDC                     hdcimage; | 
 | HBITMAP         hBitmap; | HBITMAP         hBitmap; | 
| BYTE            *image; | UINT8           *image; | 
 | HFONT           hfont; | HFONT           hfont; | 
 | RECT            rect; | RECT            rect; | 
 | int                     bmpwidth; | int                     bmpwidth; | 
| Line 20  typedef struct { | Line 20  typedef struct { | 
 | } _FNTMNG, *FNTMNG; | } _FNTMNG, *FNTMNG; | 
 |  |  | 
 |  |  | 
| static const TCHAR deffontface[] = "£Í£Ó ¥´¥·¥Ã¥¯"; | static const OEMCHAR deffontface[] = OEMTEXT("£Í£Ó ¥´¥·¥Ã¥¯"); | 
| static const TCHAR deffontface2[] = "£Í£Ó £Ð¥´¥·¥Ã¥¯"; | 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                     i; | 
 | int                     fontalign; | int                     fontalign; | 
| Line 35  void *fontmng_create(int size, UINT type | Line 35  void *fontmng_create(int size, UINT type | 
 | int                     fontwidth; | int                     fontwidth; | 
 | int                     fontheight; | int                     fontheight; | 
 | int                     weight; | int                     weight; | 
| DWORD           pitch; | UINT            pitch; | 
 |  |  | 
 | if (size < 0) { | if (size < 0) { | 
 | size *= -1; | size *= -1; | 
| Line 73  void *fontmng_create(int size, UINT type | Line 73  void *fontmng_create(int size, UINT type | 
 | ret->bmpalign = (((ret->bmpwidth + 31) / 8) & ~3); | ret->bmpalign = (((ret->bmpwidth + 31) / 8) & ~3); | 
 |  |  | 
 |  |  | 
| bi = (BITMAPINFO *)(((BYTE *)(ret + 1)) + fontalign); | bi = (BITMAPINFO *)(((UINT8 *)(ret + 1)) + fontalign); | 
 | bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | 
 | bi->bmiHeader.biWidth = ret->bmpwidth; | bi->bmiHeader.biWidth = ret->bmpwidth; | 
 | bi->bmiHeader.biHeight = ret->bmpheight; | bi->bmiHeader.biHeight = ret->bmpheight; | 
| Line 117  void *fontmng_create(int size, UINT type | Line 117  void *fontmng_create(int size, UINT type | 
 | return(ret); | return(ret); | 
 | } | } | 
 |  |  | 
 |  |  | 
 | void fontmng_destroy(void *hdl) { | void fontmng_destroy(void *hdl) { | 
 |  |  | 
 | FNTMNG  fhdl; | FNTMNG  fhdl; | 
| Line 132  void fontmng_destroy(void *hdl) { | Line 131  void fontmng_destroy(void *hdl) { | 
 | } | } | 
 |  |  | 
 |  |  | 
 |  | // ---- | 
 |  |  | 
 | static void getlength1(FNTMNG fhdl, FNTDAT fdat, | static void getlength1(FNTMNG fhdl, FNTDAT fdat, | 
| const char *string, int length) { | const OEMCHAR *string, int length) { | 
 |  |  | 
 | SIZE    fntsize; | SIZE    fntsize; | 
 |  |  | 
| if ((fhdl->fonttype & FDAT_PROPORTIONAL) && | if (GetTextExtentPoint32(fhdl->hdcimage, string, length, &fntsize)) { | 
| (GetTextExtentPoint32(fhdl->hdcimage, string, length, &fntsize))) { |  | 
 | fntsize.cx = min(fntsize.cx, fhdl->bmpwidth); | fntsize.cx = min(fntsize.cx, fhdl->bmpwidth); | 
 | fdat->width = fntsize.cx; | fdat->width = fntsize.cx; | 
 | fdat->pitch = fntsize.cx; | fdat->pitch = fntsize.cx; | 
 | } | } | 
 | else if (length < 2) { |  | 
 | fdat->width = fhdl->fontwidth; |  | 
 | fdat->pitch = (fhdl->fontsize + 1) >> 1; |  | 
 | } |  | 
 | else { | else { | 
 | fdat->width = fhdl->fontwidth; | fdat->width = fhdl->fontwidth; | 
| fdat->pitch = fhdl->fontsize; | fdat->pitch = (fhdl->fontsize + 1) >> 1; | 
 | } | } | 
 | fdat->height = fhdl->fontheight; | fdat->height = fhdl->fontheight; | 
 | } | } | 
 |  |  | 
 |  | static void fontmng_getchar(FNTMNG fhdl, FNTDAT fdat, const OEMCHAR *string) { | 
 |  |  | 
| BOOL fontmng_getsize(void *hdl, const char *string, POINT_T *pt) { | 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); | 
|  | } | 
|  |  | 
|  | BRESULT fontmng_getsize(void *hdl, const OEMCHAR *string, POINT_T *pt) { | 
 |  |  | 
 | char    buf[4]; |  | 
 | _FNTDAT fdat; |  | 
 | int             width; | int             width; | 
 |  | OEMCHAR buf[4]; | 
 |  | _FNTDAT fdat; | 
 | int             leng; | int             leng; | 
 |  |  | 
 | width = 0; |  | 
 | if ((hdl == NULL) || (string == NULL)) { | if ((hdl == NULL) || (string == NULL)) { | 
 | goto fmgs_exit; | goto fmgs_exit; | 
 | } | } | 
 |  |  | 
| buf[2] = '\0'; | width = 0; | 
| do { | while(1) { | 
| buf[0] = *string++; | leng = milstr_charsize(string); | 
| if ((((buf[0] ^ 0x20) - 0xa1) & 0xff) < 0x3c) { | if (!leng) { | 
| buf[1] = *string++; |  | 
| if (buf[1] == '\0') { |  | 
| break; |  | 
| } |  | 
| leng = 2; |  | 
| } |  | 
| else if (buf[0]) { |  | 
| buf[1] = '\0'; |  | 
| leng = 1; |  | 
| } |  | 
| else { |  | 
 | break; | break; | 
 | } | } | 
 |  | CopyMemory(buf, string, leng * sizeof(OEMCHAR)); | 
 |  | buf[leng] = '\0'; | 
 |  | string += leng; | 
 | getlength1((FNTMNG)hdl, &fdat, buf, leng); | getlength1((FNTMNG)hdl, &fdat, buf, leng); | 
 | width += fdat.pitch; | width += fdat.pitch; | 
| } while(1); | } | 
 |  |  | 
 | if (pt) { | if (pt) { | 
 | pt->x = width; | pt->x = width; | 
| Line 198  fmgs_exit: | Line 195  fmgs_exit: | 
 | return(FAILURE); | return(FAILURE); | 
 | } | } | 
 |  |  | 
 |  | BRESULT fontmng_getdrawsize(void *hdl, const OEMCHAR *string, POINT_T *pt) { | 
 |  |  | 
| BOOL fontmng_getdrawsize(void *hdl, const char *string, POINT_T *pt) { | OEMCHAR buf[4]; | 
|  |  | 
| char    buf[4]; |  | 
 | _FNTDAT fdat; | _FNTDAT fdat; | 
 | int             width; | int             width; | 
 | int             posx; | int             posx; | 
| Line 213  BOOL fontmng_getdrawsize(void *hdl, cons | Line 209  BOOL fontmng_getdrawsize(void *hdl, cons | 
 |  |  | 
 | width = 0; | width = 0; | 
 | posx = 0; | posx = 0; | 
| buf[2] = '\0'; | while(1) { | 
| do { | leng = milstr_charsize(string); | 
| buf[0] = *string++; | if (!leng) { | 
| 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 { |  | 
 | break; | break; | 
 | } | } | 
 |  | CopyMemory(buf, string, leng * sizeof(OEMCHAR)); | 
 |  | buf[leng] = '\0'; | 
 |  | string += leng; | 
 | getlength1((FNTMNG)hdl, &fdat, buf, leng); | getlength1((FNTMNG)hdl, &fdat, buf, leng); | 
 | width = posx + max(fdat.width, fdat.pitch); | width = posx + max(fdat.width, fdat.pitch); | 
 | posx += fdat.pitch; | posx += fdat.pitch; | 
| } while(1); | } | 
 |  |  | 
 | if (pt) { | if (pt) { | 
 | pt->x = width; | pt->x = width; | 
| Line 245  fmgds_exit: | Line 232  fmgds_exit: | 
 | return(FAILURE); | 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) { | static void fontmng_setpat(FNTMNG fhdl, FNTDAT fdat) { | 
 |  |  | 
| DWORD   remx; | UINT    remx; | 
| DWORD   remy; | UINT    remy; | 
| BYTE    *src; | UINT8   *src; | 
| BYTE    *dst; | UINT8   *dst; | 
| BYTE    *s; | UINT8   *s; | 
| BYTE    bit; | UINT8   bit; | 
| BYTE    b1 = 0;                         // for cygwin | UINT8   b1 = 0;                         // for cygwin | 
 | int             align; | int             align; | 
 |  |  | 
 | align = fhdl->bmpalign; | align = fhdl->bmpalign; | 
| Line 275  static void fontmng_setpat(FNTMNG fhdl, | Line 249  static void fontmng_setpat(FNTMNG fhdl, | 
 | goto fmsp_end; | goto fmsp_end; | 
 | } | } | 
 |  |  | 
| dst = (BYTE *)(fdat + 1); | dst = (UINT8 *)(fdat + 1); | 
 | align *= -1; | align *= -1; | 
 |  |  | 
 | remy = fdat->height; | remy = fdat->height; | 
| Line 301  fmsp_end: | Line 275  fmsp_end: | 
 |  |  | 
 | // ---- | // ---- | 
 |  |  | 
| FNTDAT fontmng_get(void *hdl, const char *string) { | FNTDAT fontmng_get(void *hdl, const OEMCHAR *string) { | 
 |  |  | 
 | FNTMNG  fhdl; | FNTMNG  fhdl; | 
 | FNTDAT  fdat; | FNTDAT  fdat; |