winex11.drv: Simplify X11DRV_SelectFont
Dmitry Timoshkov
dmitry at codeweavers.com
Tue Oct 7 03:26:52 CDT 2008
---
dlls/winex11.drv/x11drv.h | 2 +-
dlls/winex11.drv/x11font.h | 4 +-
dlls/winex11.drv/xfont.c | 65 +++++++------------------------------------
dlls/winex11.drv/xrender.c | 13 +++++----
4 files changed, 21 insertions(+), 63 deletions(-)
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index e5a40aa..c87bb83 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -265,7 +265,7 @@ extern int client_side_antialias_with_render;
extern int using_client_side_fonts;
extern void X11DRV_XRender_Init(void);
extern void X11DRV_XRender_Finalize(void);
-extern BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE*, HFONT);
+extern BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE*, const LOGFONTA *);
extern void X11DRV_XRender_DeleteDC(X11DRV_PDEVICE*);
extern BOOL X11DRV_XRender_ExtTextOut(X11DRV_PDEVICE *physDev, INT x, INT y, UINT flags,
const RECT *lprect, LPCWSTR wstr,
diff --git a/dlls/winex11.drv/x11font.h b/dlls/winex11.drv/x11font.h
index 27eb82e..10d55e6 100644
--- a/dlls/winex11.drv/x11font.h
+++ b/dlls/winex11.drv/x11font.h
@@ -206,7 +206,7 @@ typedef struct
UINT16 count;
UINT16 lru;
UINT16 lfchecksum;
- LOGFONT16 lf;
+ LOGFONTA lf;
} fontObject;
typedef struct
@@ -215,7 +215,7 @@ typedef struct
fontInfo* pfi;
UINT16 height;
UINT16 flags;
- LPLOGFONT16 plf;
+ LPLOGFONTA plf;
WORD internal_charset;
} fontMatch;
diff --git a/dlls/winex11.drv/xfont.c b/dlls/winex11.drv/xfont.c
index 6d8ff78..47a6114 100644
--- a/dlls/winex11.drv/xfont.c
+++ b/dlls/winex11.drv/xfont.c
@@ -375,32 +375,10 @@ static inline BOOL is_stock_font( HFONT font )
return FALSE;
}
-
-static void FONT_LogFontWTo16( const LOGFONTW* font32, LPLOGFONT16 font16 )
-{
- font16->lfHeight = font32->lfHeight;
- font16->lfWidth = font32->lfWidth;
- font16->lfEscapement = font32->lfEscapement;
- font16->lfOrientation = font32->lfOrientation;
- font16->lfWeight = font32->lfWeight;
- font16->lfItalic = font32->lfItalic;
- font16->lfUnderline = font32->lfUnderline;
- font16->lfStrikeOut = font32->lfStrikeOut;
- font16->lfCharSet = font32->lfCharSet;
- font16->lfOutPrecision = font32->lfOutPrecision;
- font16->lfClipPrecision = font32->lfClipPrecision;
- font16->lfQuality = font32->lfQuality;
- font16->lfPitchAndFamily = font32->lfPitchAndFamily;
- WideCharToMultiByte( CP_ACP, 0, font32->lfFaceName, -1,
- font16->lfFaceName, LF_FACESIZE, NULL, NULL );
- font16->lfFaceName[LF_FACESIZE-1] = 0;
-}
-
-
/***********************************************************************
* Checksums
*/
-static UINT16 __lfCheckSum( const LOGFONT16 *plf )
+static UINT16 __lfCheckSum( const LOGFONTA *plf )
{
CHAR font[LF_FACESIZE];
UINT16 checksum = 0;
@@ -2403,7 +2381,7 @@ static int XFONT_GetDefResolution( int log_pixels_x, int log_pixels_y )
static UINT XFONT_Match( fontMatch* pfm )
{
fontInfo* pfi = pfm->pfi; /* device font to match */
- LPLOGFONT16 plf = pfm->plf; /* wanted logical font */
+ LPLOGFONTA plf = pfm->plf; /* wanted logical font */
UINT penalty = 0;
BOOL bR6 = pfm->flags & FO_MATCH_XYINDEP; /* from text_caps */
BOOL bScale = pfi->fi_flags & FI_SCALABLE;
@@ -2719,7 +2697,7 @@ static void XFONT_GrowFreeList(int start, int end)
}
}
-static fontObject* XFONT_LookupCachedFont( const LOGFONT16 *plf, UINT16* checksum )
+static fontObject* XFONT_LookupCachedFont( const LOGFONTA *plf, UINT16* checksum )
{
UINT16 cs = __lfCheckSum( plf );
int i = fontMRU, prev = -1;
@@ -2733,7 +2711,7 @@ static fontObject* XFONT_LookupCachedFont( const LOGFONT16 *plf, UINT16* checksu
/* FIXME: something more intelligent here ? */
if( !memcmp( plf, &fontCache[i].lf,
- sizeof(LOGFONT16) - LF_FACESIZE ) &&
+ sizeof(LOGFONTA) - LF_FACESIZE ) &&
!strcmp( plf->lfFaceName, fontCache[i].lf.lfFaceName) )
{
/* remove temporarily from the lru list */
@@ -3009,7 +2987,7 @@ static BOOL XFONT_SetX11Trans( fontObject *pfo )
/***********************************************************************
* X Device Font Objects
*/
-static X_PHYSFONT XFONT_RealizeFont( LPLOGFONT16 plf,
+static X_PHYSFONT XFONT_RealizeFont( LPLOGFONTA plf,
LPCSTR* faceMatched, BOOL bSubFont,
WORD internal_charset,
WORD* pcharsetMatched )
@@ -3102,7 +3080,7 @@ static X_PHYSFONT XFONT_RealizeFont( LPLOGFONT16 plf,
{
WORD charset_sub;
WORD charsetMatchedSub;
- LOGFONT16 lfSub;
+ LOGFONTA lfSub;
LPCSTR faceMatchedSub;
for ( i = 0; i < X11FONT_REFOBJS_MAX; i++ )
@@ -3201,17 +3179,16 @@ LPIFONTINFO16 XFONT_GetFontInfo( X_PHYSFONT pFont )
*/
HFONT X11DRV_SelectFont( X11DRV_PDEVICE *physDev, HFONT hfont, HANDLE gdiFont )
{
- LOGFONTW logfont;
- LOGFONT16 lf;
+ LOGFONTA lf;
TRACE("hdc=%p, hfont=%p\n", physDev->hdc, hfont);
- if (!GetObjectW( hfont, sizeof(logfont), &logfont )) return HGDI_ERROR;
+ if (!GetObjectA( hfont, sizeof(lf), &lf )) return HGDI_ERROR;
TRACE("gdiFont = %p\n", gdiFont);
if(gdiFont && using_client_side_fonts) {
- X11DRV_XRender_SelectFont(physDev, hfont);
+ X11DRV_XRender_SelectFont(physDev, &lf);
physDev->has_gdi_font = TRUE;
return FALSE;
}
@@ -3223,8 +3200,6 @@ HFONT X11DRV_SelectFont( X11DRV_PDEVICE *physDev, HFONT hfont, HANDLE gdiFont )
if( CHECK_PFONT(physDev->font) )
XFONT_ReleaseCacheEntry( __PFONT(physDev->font) );
- FONT_LogFontWTo16(&logfont, &lf);
-
/* stock fonts ignore the mapping mode */
if (!is_stock_font( hfont ))
{
@@ -3252,33 +3227,15 @@ HFONT X11DRV_SelectFont( X11DRV_PDEVICE *physDev, HFONT hfont, HANDLE gdiFont )
{
/* Fixup aliases before passing to RealizeFont */
/* alias = Windows name in the alias table */
- LPCSTR alias = XFONT_UnAlias( lf.lfFaceName );
LPCSTR faceMatched;
WORD charsetMatched;
+ XFONT_UnAlias( lf.lfFaceName );
+
TRACE("hfont=%p\n", hfont); /* to connect with the trace from RealizeFont */
physDev->font = XFONT_RealizeFont( &lf, &faceMatched,
FALSE, lf.lfCharSet,
&charsetMatched );
-
- /* set face to the requested facename if it matched
- * so that GetTextFace can get the correct face name
- */
- if (alias && !strcmp(faceMatched, lf.lfFaceName))
- MultiByteToWideChar(CP_ACP, 0, alias, -1,
- logfont.lfFaceName, LF_FACESIZE);
- else
- MultiByteToWideChar(CP_ACP, 0, faceMatched, -1,
- logfont.lfFaceName, LF_FACESIZE);
-
- /*
- * In X, some encodings may have the same lfFaceName.
- * for example:
- * -misc-fixed-*-iso8859-1
- * -misc-fixed-*-jisx0208.1990-0
- * so charset should be saved...
- */
- logfont.lfCharSet = charsetMatched;
}
LeaveCriticalSection( &crtsc_fonts_X11 );
diff --git a/dlls/winex11.drv/xrender.c b/dlls/winex11.drv/xrender.c
index 08bb71f..9d1a5b6 100644
--- a/dlls/winex11.drv/xrender.c
+++ b/dlls/winex11.drv/xrender.c
@@ -53,7 +53,7 @@ static XRenderPictFormat *pict_formats[2];
typedef struct
{
- LOGFONTW lf;
+ LOGFONTA lf;
SIZE devsize; /* size in device coords */
DWORD hash;
} LFANDSIZE;
@@ -267,7 +267,7 @@ static BOOL fontcmp(LFANDSIZE *p1, LFANDSIZE *p2)
if(p1->hash != p2->hash) return TRUE;
if(memcmp(&p1->devsize, &p2->devsize, sizeof(p1->devsize))) return TRUE;
if(memcmp(&p1->lf, &p2->lf, offsetof(LOGFONTW, lfFaceName))) return TRUE;
- return strcmpW(p1->lf.lfFaceName, p2->lf.lfFaceName);
+ return lstrcmpA(p1->lf.lfFaceName, p2->lf.lfFaceName);
}
#if 0
@@ -502,7 +502,8 @@ static void lfsz_calc_hash(LFANDSIZE *plfsz)
hash ^= plfsz->devsize.cy;
for(i = 0, ptr = (DWORD*)&plfsz->lf; i < 7; i++, ptr++)
hash ^= *ptr;
- for(i = 0, ptr = (DWORD*)plfsz->lf.lfFaceName; i < LF_FACESIZE/2; i++, ptr++) {
+ for(i = 0, ptr = (DWORD*)plfsz->lf.lfFaceName; i < LF_FACESIZE/4; i++, ptr++)
+ {
WCHAR *pwc = (WCHAR *)ptr;
if(!*pwc) break;
hash ^= *ptr;
@@ -530,14 +531,14 @@ void X11DRV_XRender_Finalize(void)
/***********************************************************************
* X11DRV_XRender_SelectFont
*/
-BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE *physDev, HFONT hfont)
+BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE *physDev, const LOGFONTA *lf)
{
LFANDSIZE lfsz;
- GetObjectW(hfont, sizeof(lfsz.lf), &lfsz.lf);
+ lfsz.lf = *lf;
TRACE("h=%d w=%d weight=%d it=%d charset=%d name=%s\n",
lfsz.lf.lfHeight, lfsz.lf.lfWidth, lfsz.lf.lfWeight,
- lfsz.lf.lfItalic, lfsz.lf.lfCharSet, debugstr_w(lfsz.lf.lfFaceName));
+ lfsz.lf.lfItalic, lfsz.lf.lfCharSet, debugstr_a(lfsz.lf.lfFaceName));
lfsz.devsize.cx = X11DRV_XWStoDS( physDev, lfsz.lf.lfWidth );
lfsz.devsize.cy = X11DRV_YWStoDS( physDev, lfsz.lf.lfHeight );
lfsz_calc_hash(&lfsz);
--
1.6.0.2
More information about the wine-patches
mailing list