GetTextCharsetInfo should return the charset that the driver is

actually using, rather than that specified in the LOGFONT.
This commit is contained in:
Huw D M Davies 2001-10-10 20:25:04 +00:00 committed by Alexandre Julliard
parent 9d382c6531
commit fef698c892
1 changed files with 12 additions and 14 deletions

View File

@ -32,19 +32,17 @@ DEFAULT_DEBUG_CHANNEL(text);
*/ */
LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP) LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
{ {
LOGFONTW lf;
UINT cp = CP_ACP; UINT cp = CP_ACP;
INT lenW; INT lenW;
LPWSTR strW; LPWSTR strW;
CHARSETINFO csi; CHARSETINFO csi;
int charset = GetTextCharset(hdc);
GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf);
/* Hmm, nicely designed api this one! */ /* Hmm, nicely designed api this one! */
if(TranslateCharsetInfo((DWORD*)(UINT)lf.lfCharSet, &csi, TCI_SRCCHARSET)) if(TranslateCharsetInfo((DWORD*)charset, &csi, TCI_SRCCHARSET))
cp = csi.ciACP; cp = csi.ciACP;
else { else {
switch(lf.lfCharSet) { switch(charset) {
case SYMBOL_CHARSET: case SYMBOL_CHARSET:
cp = CP_SYMBOL; cp = CP_SYMBOL;
break; break;
@ -74,7 +72,7 @@ LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
default: default:
FIXME("Can't find codepage for charset %d\n", lf.lfCharSet); FIXME("Can't find codepage for charset %d\n", charset);
break; break;
} }
} }
@ -226,6 +224,10 @@ UINT16 WINAPI GetTextCharset16(HDC16 hdc)
* Should it return a UINT32 instead of an INT32? * Should it return a UINT32 instead of an INT32?
* => YES and YES, from win32.hlp from Borland * => YES and YES, from win32.hlp from Borland
* *
* This returns the actual charset selected by the driver rather than the
* value in lf.lfCharSet during CreateFont, to get that use
* GetObject(GetCurrentObject(...),...)
*
* RETURNS * RETURNS
* Success: Character set identifier * Success: Character set identifier
* Failure: DEFAULT_CHARSET * Failure: DEFAULT_CHARSET
@ -235,20 +237,16 @@ UINT WINAPI GetTextCharsetInfo(
LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */ LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
DWORD flags) /* [in] Reserved - must be 0 */ DWORD flags) /* [in] Reserved - must be 0 */
{ {
HGDIOBJ hFont;
UINT charSet = DEFAULT_CHARSET; UINT charSet = DEFAULT_CHARSET;
LOGFONTW lf;
CHARSETINFO csinfo; CHARSETINFO csinfo;
TEXTMETRICW tm;
hFont = GetCurrentObject(hdc, OBJ_FONT); if(!GetTextMetricsW(hdc, &tm)) return DEFAULT_CHARSET;
if (hFont == 0) charSet = tm.tmCharSet;
return(DEFAULT_CHARSET);
if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
charSet = lf.lfCharSet;
if (fs != NULL) { if (fs != NULL) {
if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET)) if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
return (DEFAULT_CHARSET); return DEFAULT_CHARSET;
memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE)); memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
} }
return charSet; return charSet;