diff --git a/dlls/gdi/freetype.c b/dlls/gdi/freetype.c index 016384a3432bd03ef11c11e1e229494e3e0974f1..d70480e312beaa6e4990938b2936889349a04c63 100644 --- a/dlls/gdi/freetype.c +++ b/dlls/gdi/freetype.c @@ -796,20 +796,19 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) GdiFont ret; Face *face; Family *family = NULL; - WCHAR FaceName[LF_FACESIZE]; BOOL bd, it; - FONTOBJ *font = GDI_GetObjPtr(hfont, FONT_MAGIC); - LOGFONTW *plf = &font->logfont; + LOGFONTW lf; + + if (!GetObjectW( hfont, sizeof(lf), &lf )) return NULL; TRACE("%s, h=%ld, it=%d, weight=%ld, PandF=%02x, charset=%d orient %ld escapement %ld\n", - debugstr_w(plf->lfFaceName), plf->lfHeight, plf->lfItalic, - plf->lfWeight, plf->lfPitchAndFamily, plf->lfCharSet, plf->lfOrientation, - plf->lfEscapement); + debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic, + lf.lfWeight, lf.lfPitchAndFamily, lf.lfCharSet, lf.lfOrientation, + lf.lfEscapement); /* check the cache first */ for(ret = GdiFontList; ret; ret = ret->next) { if(ret->hfont == hfont) { - GDI_ReleaseObj(hfont); TRACE("returning cached gdiFont(%p) for hFont %x\n", ret, hfont); return ret; } @@ -817,45 +816,42 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) if(!FontList) /* No fonts installed */ { - GDI_ReleaseObj(hfont); TRACE("No fonts installed\n"); return NULL; } ret = alloc_font(); - strcpyW(FaceName, plf->lfFaceName); - - if(FaceName[0] != '\0') { + if(lf.lfFaceName[0] != '\0') { FontSubst *psub; for(psub = substlist; psub; psub = psub->next) - if(!strcmpiW(FaceName, psub->from.name) && + if(!strcmpiW(lf.lfFaceName, psub->from.name) && (psub->from.charset == -1 || - psub->from.charset == plf->lfCharSet)) + psub->from.charset == lf.lfCharSet)) break; if(psub) { - TRACE("substituting %s -> %s\n", debugstr_w(FaceName), + TRACE("substituting %s -> %s\n", debugstr_w(lf.lfFaceName), debugstr_w(psub->to.name)); - strcpyW(FaceName, psub->to.name); + strcpyW(lf.lfFaceName, psub->to.name); } for(family = FontList; family; family = family->next) { - if(!strcmpiW(family->FamilyName, FaceName)) + if(!strcmpiW(family->FamilyName, lf.lfFaceName)) break; } if(!family) { /* do other aliases here */ - if(!strcmpiW(FaceName, SystemW)) - strcpyW(FaceName, defSystem); - else if(!strcmpiW(FaceName, MSSansSerifW)) - strcpyW(FaceName, defSans); - else if(!strcmpiW(FaceName, HelvW)) - strcpyW(FaceName, defSans); + if(!strcmpiW(lf.lfFaceName, SystemW)) + strcpyW(lf.lfFaceName, defSystem); + else if(!strcmpiW(lf.lfFaceName, MSSansSerifW)) + strcpyW(lf.lfFaceName, defSans); + else if(!strcmpiW(lf.lfFaceName, HelvW)) + strcpyW(lf.lfFaceName, defSans); else goto not_found; for(family = FontList; family; family = family->next) { - if(!strcmpiW(family->FamilyName, FaceName)) + if(!strcmpiW(family->FamilyName, lf.lfFaceName)) break; } } @@ -863,17 +859,17 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) not_found: if(!family) { - if(plf->lfPitchAndFamily & FIXED_PITCH || - plf->lfPitchAndFamily & FF_MODERN) - strcpyW(FaceName, defFixed); - else if(plf->lfPitchAndFamily & FF_ROMAN) - strcpyW(FaceName, defSerif); - else if(plf->lfPitchAndFamily & FF_SWISS) - strcpyW(FaceName, defSans); + if(lf.lfPitchAndFamily & FIXED_PITCH || + lf.lfPitchAndFamily & FF_MODERN) + strcpyW(lf.lfFaceName, defFixed); + else if(lf.lfPitchAndFamily & FF_ROMAN) + strcpyW(lf.lfFaceName, defSerif); + else if(lf.lfPitchAndFamily & FF_SWISS) + strcpyW(lf.lfFaceName, defSans); else - strcpyW(FaceName, defSans); + strcpyW(lf.lfFaceName, defSans); for(family = FontList; family; family = family->next) { - if(!strcmpiW(family->FamilyName, FaceName)) + if(!strcmpiW(family->FamilyName, lf.lfFaceName)) break; } } @@ -883,8 +879,8 @@ not_found: FIXME("just using first face for now\n"); } - it = plf->lfItalic ? 1 : 0; - bd = plf->lfWeight > 550 ? 1 : 0; + it = lf.lfItalic ? 1 : 0; + bd = lf.lfWeight > 550 ? 1 : 0; for(face = family->FirstFace; face; face = face->next) { if(!(face->Italic ^ it) && !(face->Bold ^ bd)) @@ -895,24 +891,22 @@ not_found: if(it && !face->Italic) ret->fake_italic = TRUE; if(bd && !face->Bold) ret->fake_bold = TRUE; } - ret->charset = get_nearest_charset(face, plf->lfCharSet); + ret->charset = get_nearest_charset(face, lf.lfCharSet); TRACE("Choosen %s %s\n", debugstr_w(family->FamilyName), debugstr_w(face->StyleName)); ret->ft_face = OpenFontFile(ret, face->file, - INTERNAL_YWSTODS(dc,plf->lfHeight)); + INTERNAL_YWSTODS(dc,lf.lfHeight)); if (!ret->ft_face) { - GDI_ReleaseObj(hfont); free_font( ret ); return 0; } if(ret->charset == SYMBOL_CHARSET) pFT_Select_Charmap(ret->ft_face, ft_encoding_symbol); - ret->orientation = plf->lfOrientation; - GDI_ReleaseObj(hfont); + ret->orientation = lf.lfOrientation; TRACE("caching: gdiFont=%p hfont=%x\n", ret, hfont); ret->hfont = hfont; @@ -928,11 +922,10 @@ static void DumpGdiFontList(void) TRACE("---------- gdiFont Cache ----------\n"); for(gdiFont = GdiFontList; gdiFont; gdiFont = gdiFont->next) { - FONTOBJ *font = GDI_GetObjPtr(gdiFont->hfont, FONT_MAGIC); - LOGFONTW *plf = &font->logfont; + LOGFONTW lf; + GetObjectW( gdiFont->hfont, sizeof(lf), &lf ); TRACE("gdiFont=%p hfont=%x (%s)\n", - gdiFont, gdiFont->hfont, debugstr_w(plf->lfFaceName)); - GDI_ReleaseObj(gdiFont->hfont); + gdiFont, gdiFont->hfont, debugstr_w(lf.lfFaceName)); } } @@ -1867,4 +1860,3 @@ DWORD WineEngGetFontData(GdiFont font, DWORD table, DWORD offset, LPVOID buf, return GDI_ERROR; } #endif /* HAVE_FREETYPE */ - diff --git a/dlls/gdi/mfdrv/init.c b/dlls/gdi/mfdrv/init.c index f926186a697b3f6349fb32b8c575f9e8383b84d6..e2457b9241ddb5b2672f3a9db18c5e3fab67f1f3 100644 --- a/dlls/gdi/mfdrv/init.c +++ b/dlls/gdi/mfdrv/init.c @@ -21,7 +21,6 @@ #include "windef.h" #include "wine/winbase16.h" #include "gdi.h" -#include "metafile.h" #include "mfdrv/metafiledrv.h" #include "wine/debug.h" diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c index 563829ca0f8e97fc02b441b95d859a57afa858f3..9b33d04b94cca1e63210778638f9b65641f20556 100644 --- a/graphics/x11drv/xfont.c +++ b/graphics/x11drv/xfont.c @@ -66,6 +66,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(font); #define REMOVE_SUBSETS 1 #define UNMARK_SUBSETS 0 +#define FONTCACHE 32 /* dynamic font cache size */ #define FF_FAMILY (FF_MODERN | FF_SWISS | FF_ROMAN | FF_DECORATIVE | FF_SCRIPT) diff --git a/include/font.h b/include/font.h index 8ec8100440d5a7368238aecaf22a7a9ef346df04..e45394504c17b16315153d2d1613e7888bb9f111 100644 --- a/include/font.h +++ b/include/font.h @@ -23,52 +23,6 @@ #include "gdi.h" -#include "pshpack1.h" - - /* GDI logical font object */ -typedef struct -{ - GDIOBJHDR header; - LOGFONTW logfont; -} FONTOBJ; - -typedef struct { - WORD dfVersion; - DWORD dfSize; - CHAR dfCopyright[60]; - WORD dfType; - WORD dfPoints; - WORD dfVertRes; - WORD dfHorizRes; - WORD dfAscent; - WORD dfInternalLeading; - WORD dfExternalLeading; - BYTE dfItalic; - BYTE dfUnderline; - BYTE dfStrikeOut; - WORD dfWeight; - BYTE dfCharSet; - WORD dfPixWidth; - WORD dfPixHeight; - BYTE dfPitchAndFamily; - WORD dfAvgWidth; - WORD dfMaxWidth; - BYTE dfFirstChar; - BYTE dfLastChar; - BYTE dfDefaultChar; - BYTE dfBreakChar; - WORD dfWidthBytes; - DWORD dfDevice; - DWORD dfFace; - DWORD dfReserved; - CHAR szDeviceName[60]; /* FIXME: length unknown */ - CHAR szFaceName[60]; /* dito */ -} FONTDIR16, *LPFONTDIR16; - -#include "poppack.h" - -#define FONTCACHE 32 /* dynamic font cache size */ - extern BOOL FONT_Init( UINT16* pTextCaps ); extern void FONT_LogFontATo16( const LOGFONTA* font32, LPLOGFONT16 font16 ); extern void FONT_LogFontWTo16( const LOGFONTW* font32, LPLOGFONT16 font16 ); diff --git a/include/gdi.h b/include/gdi.h index 6b4efd80507e76ed69cfeb9a7f8258178cb5f3c1..9b96f424d214662ffeef47ce43901f0ada13ebc5 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -283,6 +283,14 @@ typedef struct tagDC_FUNCS /* extra stock object: default 1x1 bitmap for memory DCs */ #define DEFAULT_BITMAP (STOCK_LAST+1) +/* Metafile defines */ + +#define META_EOF 0x0000 +/* values of mtType in METAHEADER. Note however that the disk image of a disk + based metafile has mtType == 1 */ +#define METAFILE_MEMORY 1 +#define METAFILE_DISK 2 + /* Device <-> logical coords conversion */ /* A floating point version of the POINT structure */ @@ -595,12 +603,17 @@ extern DC * DC_GetDCUpdate( HDC hdc ); extern void DC_InitDC( DC * dc ); extern void DC_UpdateXforms( DC * dc ); -/* objects/clipping.c */ +/* clipping.c */ extern void CLIPPING_UpdateGCRegion( DC * dc ); -/* objects/enhmetafile.c */ +/* enhmetafile.c */ extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk ); +/* metafile.c */ +extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh); +extern HMETAFILE16 MF_Create_HMETAFILE16(METAHEADER *mh); +extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCSTR filename); + /* region.c */ extern HRGN REGION_CropRgn( HRGN hDst, HRGN hSrc, const RECT *lpRect, const POINT *lpPt ); extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y ); diff --git a/include/metafile.h b/include/metafile.h deleted file mode 100644 index 420306768a34c7b1dccb53e3478cd1943ee8c608..0000000000000000000000000000000000000000 --- a/include/metafile.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Metafile definitions - * - * Copyright David W. Metcalfe, 1994 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __WINE_METAFILE_H -#define __WINE_METAFILE_H - -#include "gdi.h" -#include "windef.h" -#include "wingdi.h" - - /* GDI32 metafile object */ -typedef struct -{ - GDIOBJHDR header; - METAHEADER *mh; -} METAFILEOBJ; - -#define META_EOF 0x0000 - -/* values of mtType in METAHEADER. Note however that the disk image of a disk - based metafile has mtType == 1 */ -#define METAFILE_MEMORY 1 -#define METAFILE_DISK 2 - -extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh); -extern HMETAFILE16 MF_Create_HMETAFILE16(METAHEADER *mh); -extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCSTR filename); - -#endif /* __WINE_METAFILE_H */ - diff --git a/include/wine/wingdi16.h b/include/wine/wingdi16.h index d1bcee0844c4b9f2ea57477940c4e7de37bc3d7e..bae40db65ca7d18bb33076ece2fd43b36713d0f0 100644 --- a/include/wine/wingdi16.h +++ b/include/wine/wingdi16.h @@ -140,6 +140,39 @@ typedef struct LONG dfReserved1[4]; } FONTINFO16, *LPFONTINFO16; +typedef struct { + WORD dfVersion; + DWORD dfSize; + CHAR dfCopyright[60]; + WORD dfType; + WORD dfPoints; + WORD dfVertRes; + WORD dfHorizRes; + WORD dfAscent; + WORD dfInternalLeading; + WORD dfExternalLeading; + BYTE dfItalic; + BYTE dfUnderline; + BYTE dfStrikeOut; + WORD dfWeight; + BYTE dfCharSet; + WORD dfPixWidth; + WORD dfPixHeight; + BYTE dfPitchAndFamily; + WORD dfAvgWidth; + WORD dfMaxWidth; + BYTE dfFirstChar; + BYTE dfLastChar; + BYTE dfDefaultChar; + BYTE dfBreakChar; + WORD dfWidthBytes; + DWORD dfDevice; + DWORD dfFace; + DWORD dfReserved; + CHAR szDeviceName[60]; /* FIXME: length unknown */ + CHAR szFaceName[60]; /* dito */ +} FONTDIR16, *LPFONTDIR16; + typedef struct { INT16 tmHeight; diff --git a/objects/enhmetafile.c b/objects/enhmetafile.c index aa4d9fbc2c74ac09b1aecb000f6e6d9fa6da70ad..671cad534192f8059829dd98a52d34a3172da142 100644 --- a/objects/enhmetafile.c +++ b/objects/enhmetafile.c @@ -40,8 +40,8 @@ #include "winbase.h" #include "wingdi.h" #include "winerror.h" +#include "gdi.h" #include "wine/debug.h" -#include "metafile.h" WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile); @@ -2189,6 +2189,3 @@ error: return 0; } - - - diff --git a/objects/font.c b/objects/font.c index 096b10abcc6e3ae1dcd406cd1604aad4adc06f7f..7a3c7529f50d91fe0050e66394ce25a4deee59cd 100644 --- a/objects/font.c +++ b/objects/font.c @@ -51,6 +51,12 @@ static const struct gdi_obj_funcs font_funcs = #define ENUM_UNICODE 0x00000001 #define ENUM_CALLED 0x00000002 +typedef struct +{ + GDIOBJHDR header; + LOGFONTW logfont; +} FONTOBJ; + typedef struct { LPLOGFONT16 lpLogFontParam; diff --git a/objects/metafile.c b/objects/metafile.c index cc9b6d35cc8a4ce314964d2acdd3e53bfe1f9a41..ad0404a1df1a2cd6ac050632d90c3216d7fe2b63 100644 --- a/objects/metafile.c +++ b/objects/metafile.c @@ -52,8 +52,6 @@ #include "wine/wingdi16.h" #include "bitmap.h" #include "global.h" -#include "metafile.h" - #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(metafile); @@ -67,6 +65,12 @@ typedef struct } METAHEADERDISK; #include "poppack.h" +typedef struct +{ + GDIOBJHDR header; + METAHEADER *mh; +} METAFILEOBJ; + #define MFHEADERSIZE (sizeof(METAHEADER)) #define MFVERSION 0x300