/* Copyright (C) 2001 by Alex Kompel */ /* NetHack may be freely redistributed. See license for details. */ /* font management and such */ #include "mhfont.h" #define MAXFONTS 64 /* font table - 64 fonts ought to be enough */ static struct font_table_entry { int code; HFONT hFont; } font_table[MAXFONTS] ; static int font_table_size = 0; HFONT version_splash_font; HFONT extrainfo_splash_font; #define NHFONT_CODE(win, attr) (((attr&0xFF)<<8)|(win_type&0xFF)) static void __cdecl font_table_cleanup(void); /* create font based on window type, charater attributes and window device context */ HGDIOBJ mswin_get_font(int win_type, int attr, HDC hdc, BOOL replace) { HFONT fnt = NULL; LOGFONT lgfnt; int font_size; int font_index; static BOOL once = FALSE; if( !once ) { once = TRUE; atexit(font_table_cleanup); } ZeroMemory( &lgfnt, sizeof(lgfnt) ); /* try find font in the table */ for(font_index=0; font_index=MAXFONTS ) panic( "font table overflow!" ); font_table_size++; } else { DeleteObject(font_table[font_index].hFont); } font_table[font_index].code = NHFONT_CODE(win_type, attr); font_table[font_index].hFont = fnt; 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; for(i=0; i