Fix GetTextCharsetInfo
Huw D M Davies
h.davies1 at physics.ox.ac.uk
Wed Oct 10 11:34:33 CDT 2001
Huw D M Davies <hdavies at codeweavers.com>
GetTextCharsetInfo should return the charset that the driver is
actually using, rather than that specified in the LOGFONT.
-------------- next part --------------
Index: objects/text.c
===================================================================
RCS file: /home/wine/wine/objects/text.c,v
retrieving revision 1.38
diff -u -r1.38 text.c
--- objects/text.c 2001/09/20 18:58:05 1.38
+++ objects/text.c 2001/10/10 15:12:15
@@ -32,19 +32,17 @@
*/
LPWSTR FONT_mbtowc(HDC hdc, LPCSTR str, INT count, INT *plenW, UINT *pCP)
{
- LOGFONTW lf;
UINT cp = CP_ACP;
INT lenW;
LPWSTR strW;
CHARSETINFO csi;
+ int charset = GetTextCharset(hdc);
- GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf);
-
/* 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;
else {
- switch(lf.lfCharSet) {
+ switch(charset) {
case SYMBOL_CHARSET:
cp = CP_SYMBOL;
break;
@@ -74,7 +72,7 @@
default:
- FIXME("Can't find codepage for charset %d\n", lf.lfCharSet);
+ FIXME("Can't find codepage for charset %d\n", charset);
break;
}
}
@@ -226,6 +224,10 @@
* Should it return a UINT32 instead of an INT32?
* => 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
* Success: Character set identifier
* Failure: DEFAULT_CHARSET
@@ -235,20 +237,16 @@
LPFONTSIGNATURE fs, /* [out] Pointer to struct to receive data */
DWORD flags) /* [in] Reserved - must be 0 */
{
- HGDIOBJ hFont;
UINT charSet = DEFAULT_CHARSET;
- LOGFONTW lf;
CHARSETINFO csinfo;
+ TEXTMETRICW tm;
- hFont = GetCurrentObject(hdc, OBJ_FONT);
- if (hFont == 0)
- return(DEFAULT_CHARSET);
- if ( GetObjectW(hFont, sizeof(LOGFONTW), &lf) != 0 )
- charSet = lf.lfCharSet;
+ if(!GetTextMetricsW(hdc, &tm)) return DEFAULT_CHARSET;
+ charSet = tm.tmCharSet;
if (fs != NULL) {
if (!TranslateCharsetInfo((LPDWORD)charSet, &csinfo, TCI_SRCCHARSET))
- return (DEFAULT_CHARSET);
+ return DEFAULT_CHARSET;
memcpy(fs, &csinfo.fs, sizeof(FONTSIGNATURE));
}
return charSet;
More information about the wine-patches
mailing list