From 2b31ea2c96b3eb9bae153c53ff5bff2d41675eae Mon Sep 17 00:00:00 2001 From: "nethack.allison" Date: Sun, 3 Nov 2002 15:16:22 +0000 Subject: [PATCH] NH 3.4.0 fonts on Win2K / Japanese (from ) Here is one more patch (see attachment). It does TranslateCharsetInfo to map codepage to a character set. I am not sure if it will help though. Japanese Windows is using codepage 932 and I don't think IBMgraphics will work too well in this codepage. AFAIK, there is no way in win32 to force arbitrary codepage for a font (CP 437 in case of Nethack). That means IBMgraphics is unlikely to work if the system locale is set to something other than US or Western Europe (CP 437 & 850). - --- win/win32/mhfont.c | 25 ++++++++++++++++++++----- win/win32/mhfont.h | 1 + win/win32/mhmap.c | 3 ++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/win/win32/mhfont.c b/win/win32/mhfont.c index b23e56211..ecbb4776a 100644 --- a/win/win32/mhfont.c +++ b/win/win32/mhfont.c @@ -34,7 +34,7 @@ void mswin_init_splashfonts(HWND hWnd) lgfnt.lfItalic = FALSE; // italic attribute option lgfnt.lfUnderline = FALSE; // underline attribute option lgfnt.lfStrikeOut = FALSE; // strikeout attribute option - lgfnt.lfCharSet = OEM_CHARSET; // character set identifier + lgfnt.lfCharSet = ANSI_CHARSET; // character set identifier lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision lgfnt.lfQuality = DEFAULT_QUALITY; // output quality @@ -87,7 +87,7 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace) lgfnt.lfItalic = FALSE; // italic attribute option lgfnt.lfUnderline = FALSE; // underline attribute option lgfnt.lfStrikeOut = FALSE; // strikeout attribute option - lgfnt.lfCharSet = iflags.IBMgraphics? OEM_CHARSET : ANSI_CHARSET; // character set identifier + lgfnt.lfCharSet = mswin_charset(); // character set identifier lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision lgfnt.lfQuality = DEFAULT_QUALITY; // output quality @@ -109,7 +109,7 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace) lgfnt.lfItalic = (attr==ATR_BLINK)? TRUE: FALSE; // italic attribute option lgfnt.lfUnderline = (attr==ATR_ULINE)? TRUE : FALSE; // underline attribute option lgfnt.lfStrikeOut = FALSE; // strikeout attribute option - lgfnt.lfCharSet = iflags.IBMgraphics? OEM_CHARSET : ANSI_CHARSET; // character set identifier + lgfnt.lfCharSet = mswin_charset(); // character set identifier lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision lgfnt.lfQuality = DEFAULT_QUALITY; // output quality @@ -132,7 +132,7 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace) lgfnt.lfItalic = (attr==ATR_BLINK)? TRUE: FALSE; // italic attribute option lgfnt.lfUnderline = (attr==ATR_ULINE)? TRUE : FALSE; // underline attribute option lgfnt.lfStrikeOut = FALSE; // strikeout attribute option - lgfnt.lfCharSet = iflags.IBMgraphics? OEM_CHARSET : ANSI_CHARSET; // character set identifier + lgfnt.lfCharSet = mswin_charset(); // character set identifier lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision lgfnt.lfQuality = DEFAULT_QUALITY; // output quality @@ -154,7 +154,7 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace) lgfnt.lfItalic = (attr==ATR_BLINK)? TRUE: FALSE; // italic attribute option lgfnt.lfUnderline = (attr==ATR_ULINE)? TRUE : FALSE; // underline attribute option lgfnt.lfStrikeOut = FALSE; // strikeout attribute option - lgfnt.lfCharSet = iflags.IBMgraphics? OEM_CHARSET : ANSI_CHARSET; // character set identifier + lgfnt.lfCharSet = mswin_charset(); // character set identifier lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision lgfnt.lfQuality = DEFAULT_QUALITY; // output quality @@ -183,6 +183,21 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace) return fnt; } +UINT mswin_charset() +{ + CHARSETINFO cis; + if( iflags.IBMgraphics ) + if( TranslateCharsetInfo((DWORD*)GetOEMCP(), &cis, TCI_SRCCODEPAGE) ) + return cis.ciCharset; + else + return OEM_CHARSET; + else + if( TranslateCharsetInfo((DWORD*)GetACP(), &cis, TCI_SRCCODEPAGE) ) + return cis.ciCharset; + else + return ANSI_CHARSET; +} + void __cdecl font_table_cleanup(void) { int i; diff --git a/win/win32/mhfont.h b/win/win32/mhfont.h index b9cc23404..2f88cdfcc 100644 --- a/win/win32/mhfont.h +++ b/win/win32/mhfont.h @@ -11,5 +11,6 @@ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace); void mswin_init_splashfonts(HWND hWnd); void mswin_destroy_splashfonts(void); +UINT mswin_charset(); #endif /* MSWINFont_h */ diff --git a/win/win32/mhmap.c b/win/win32/mhmap.c index b6dad2732..ffbad0549 100644 --- a/win/win32/mhmap.c +++ b/win/win32/mhmap.c @@ -6,6 +6,7 @@ #include "mhmap.h" #include "mhmsg.h" #include "mhinput.h" +#include "mhfont.h" #include "patchlevel.h" @@ -159,7 +160,7 @@ void mswin_map_stretch(HWND hWnd, LPSIZE lpsz, BOOL redraw) lgfnt.lfItalic = FALSE; // italic attribute option lgfnt.lfUnderline = FALSE; // underline attribute option lgfnt.lfStrikeOut = FALSE; // strikeout attribute option - lgfnt.lfCharSet = iflags.IBMgraphics? OEM_CHARSET : ANSI_CHARSET; // character set identifier + lgfnt.lfCharSet = mswin_charset(); // character set identifier lgfnt.lfOutPrecision = OUT_DEFAULT_PRECIS; // output precision lgfnt.lfClipPrecision = CLIP_DEFAULT_PRECIS; // clipping precision lgfnt.lfQuality = DEFAULT_QUALITY; // output quality