|
|
| version 1.3, 2005/02/09 20:11:35 | version 1.8, 2006/12/23 23:34:32 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #ifndef __GNUC__ | |
| #include <snanls.h> | |
| #endif | |
| #include "fontmng.h" | #include "fontmng.h" |
| Line 22 typedef struct { | Line 25 typedef struct { |
| static const OEMCHAR deffontface[] = OEMTEXT("£Í£Ó ¥´¥·¥Ã¥¯"); | static const OEMCHAR deffontface[] = OEMTEXT("£Í£Ó ¥´¥·¥Ã¥¯"); |
| static const OEMCHAR deffontface2[] = OEMTEXT("£Í£Ó £Ð¥´¥·¥Ã¥¯"); | static const OEMCHAR deffontface2[] = OEMTEXT("£Í£Ó £Ð¥´¥·¥Ã¥¯"); |
| static const OEMCHAR edeffontface[] = OEMTEXT("MS Gothic"); | |
| static const OEMCHAR edeffontface2[] = OEMTEXT("MS PGothic"); | |
| static const OEMCHAR *deffont[4] = { | |
| deffontface, deffontface2, | |
| edeffontface, edeffontface2}; | |
| void *fontmng_create(int size, UINT type, const OEMCHAR *fontface) { | void *fontmng_create(int size, UINT type, const OEMCHAR *fontface) { |
| Line 35 void *fontmng_create(int size, UINT type | Line 43 void *fontmng_create(int size, UINT type |
| int fontwidth; | int fontwidth; |
| int fontheight; | int fontheight; |
| int weight; | int weight; |
| UINT pitch; | int deffontnum; |
| DWORD pitch; | |
| DWORD charset; | |
| if (size < 0) { | if (size < 0) { |
| size *= -1; | size *= -1; |
| Line 92 void *fontmng_create(int size, UINT type | Line 102 void *fontmng_create(int size, UINT type |
| bi->bmiColors[i].rgbReserved = PC_RESERVED; | bi->bmiColors[i].rgbReserved = PC_RESERVED; |
| } | } |
| hdc = GetDC(NULL); | hdc = GetDC(NULL); |
| ret->hBitmap = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, | ret->hBitmap = CreateDIBSection(hdc, bi, DIB_RGB_COLORS, |
| (void **)&ret->image, NULL, 0); | (void **)&ret->image, NULL, 0); |
| ret->hdcimage = CreateCompatibleDC(hdc); | ret->hdcimage = CreateCompatibleDC(hdc); |
| Line 103 void *fontmng_create(int size, UINT type | Line 113 void *fontmng_create(int size, UINT type |
| weight = (type & FDAT_BOLD)?FW_BOLD:FW_REGULAR; | weight = (type & FDAT_BOLD)?FW_BOLD:FW_REGULAR; |
| pitch = (type & FDAT_PROPORTIONAL)?VARIABLE_PITCH:FIXED_PITCH; | pitch = (type & FDAT_PROPORTIONAL)?VARIABLE_PITCH:FIXED_PITCH; |
| if (fontface == NULL) { | if (fontface == NULL) { |
| fontface = (type & FDAT_PROPORTIONAL)?deffontface2:deffontface; | deffontnum = (type & FDAT_PROPORTIONAL)?1:0; |
| #ifndef __GNUC__ | |
| if (GetOEMCP() != CP_932) | |
| #else | |
| if (GetOEMCP() != 932) | |
| #endif | |
| { | |
| deffontnum += 2; | |
| } | |
| fontface = deffont[deffontnum]; | |
| } | } |
| charset = (type & FDAT_SHIFTJIS)?SHIFTJIS_CHARSET:DEFAULT_CHARSET; | |
| ret->hfont = CreateFont(size, 0, | ret->hfont = CreateFont(size, 0, |
| FW_DONTCARE, FW_DONTCARE, weight, | FW_DONTCARE, FW_DONTCARE, weight, |
| FALSE, FALSE, FALSE, SHIFTJIS_CHARSET, | FALSE, FALSE, FALSE, charset, |
| OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, | OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, |
| NONANTIALIASED_QUALITY, pitch, fontface); | NONANTIALIASED_QUALITY, pitch, fontface); |
| ret->hfont = (HFONT)SelectObject(ret->hdcimage, ret->hfont); | ret->hfont = (HFONT)SelectObject(ret->hdcimage, ret->hfont); |
| Line 117 void *fontmng_create(int size, UINT type | Line 137 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 164 static void fontmng_getchar(FNTMNG fhdl, | Line 183 static void fontmng_getchar(FNTMNG fhdl, |
| BRESULT fontmng_getsize(void *hdl, const OEMCHAR *string, POINT_T *pt) { | BRESULT fontmng_getsize(void *hdl, const OEMCHAR *string, POINT_T *pt) { |
| int width; | |
| OEMCHAR buf[4]; | OEMCHAR buf[4]; |
| _FNTDAT fdat; | _FNTDAT fdat; |
| int width; | |
| int leng; | int leng; |
| width = 0; | |
| if ((hdl == NULL) || (string == NULL)) { | if ((hdl == NULL) || (string == NULL)) { |
| goto fmgs_exit; | goto fmgs_exit; |
| } | } |
| width = 0; | |
| while(1) { | while(1) { |
| leng = milstr_charsize(string); | leng = milstr_charsize(string); |
| if (!leng) { | if (!leng) { |