Commit 78b041cf authored by Alexandre Julliard's avatar Alexandre Julliard

Better encapsulation of the font and metafile objects.

parent c6476e90
...@@ -796,20 +796,19 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) ...@@ -796,20 +796,19 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
GdiFont ret; GdiFont ret;
Face *face; Face *face;
Family *family = NULL; Family *family = NULL;
WCHAR FaceName[LF_FACESIZE];
BOOL bd, it; BOOL bd, it;
FONTOBJ *font = GDI_GetObjPtr(hfont, FONT_MAGIC); LOGFONTW lf;
LOGFONTW *plf = &font->logfont;
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", 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, debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
plf->lfWeight, plf->lfPitchAndFamily, plf->lfCharSet, plf->lfOrientation, lf.lfWeight, lf.lfPitchAndFamily, lf.lfCharSet, lf.lfOrientation,
plf->lfEscapement); lf.lfEscapement);
/* check the cache first */ /* check the cache first */
for(ret = GdiFontList; ret; ret = ret->next) { for(ret = GdiFontList; ret; ret = ret->next) {
if(ret->hfont == hfont) { if(ret->hfont == hfont) {
GDI_ReleaseObj(hfont);
TRACE("returning cached gdiFont(%p) for hFont %x\n", ret, hfont); TRACE("returning cached gdiFont(%p) for hFont %x\n", ret, hfont);
return ret; return ret;
} }
...@@ -817,45 +816,42 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) ...@@ -817,45 +816,42 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
if(!FontList) /* No fonts installed */ if(!FontList) /* No fonts installed */
{ {
GDI_ReleaseObj(hfont);
TRACE("No fonts installed\n"); TRACE("No fonts installed\n");
return NULL; return NULL;
} }
ret = alloc_font(); ret = alloc_font();
strcpyW(FaceName, plf->lfFaceName); if(lf.lfFaceName[0] != '\0') {
if(FaceName[0] != '\0') {
FontSubst *psub; FontSubst *psub;
for(psub = substlist; psub; psub = psub->next) 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 == -1 ||
psub->from.charset == plf->lfCharSet)) psub->from.charset == lf.lfCharSet))
break; break;
if(psub) { if(psub) {
TRACE("substituting %s -> %s\n", debugstr_w(FaceName), TRACE("substituting %s -> %s\n", debugstr_w(lf.lfFaceName),
debugstr_w(psub->to.name)); debugstr_w(psub->to.name));
strcpyW(FaceName, psub->to.name); strcpyW(lf.lfFaceName, psub->to.name);
} }
for(family = FontList; family; family = family->next) { for(family = FontList; family; family = family->next) {
if(!strcmpiW(family->FamilyName, FaceName)) if(!strcmpiW(family->FamilyName, lf.lfFaceName))
break; break;
} }
if(!family) { /* do other aliases here */ if(!family) { /* do other aliases here */
if(!strcmpiW(FaceName, SystemW)) if(!strcmpiW(lf.lfFaceName, SystemW))
strcpyW(FaceName, defSystem); strcpyW(lf.lfFaceName, defSystem);
else if(!strcmpiW(FaceName, MSSansSerifW)) else if(!strcmpiW(lf.lfFaceName, MSSansSerifW))
strcpyW(FaceName, defSans); strcpyW(lf.lfFaceName, defSans);
else if(!strcmpiW(FaceName, HelvW)) else if(!strcmpiW(lf.lfFaceName, HelvW))
strcpyW(FaceName, defSans); strcpyW(lf.lfFaceName, defSans);
else else
goto not_found; goto not_found;
for(family = FontList; family; family = family->next) { for(family = FontList; family; family = family->next) {
if(!strcmpiW(family->FamilyName, FaceName)) if(!strcmpiW(family->FamilyName, lf.lfFaceName))
break; break;
} }
} }
...@@ -863,17 +859,17 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont) ...@@ -863,17 +859,17 @@ GdiFont WineEngCreateFontInstance(DC *dc, HFONT hfont)
not_found: not_found:
if(!family) { if(!family) {
if(plf->lfPitchAndFamily & FIXED_PITCH || if(lf.lfPitchAndFamily & FIXED_PITCH ||
plf->lfPitchAndFamily & FF_MODERN) lf.lfPitchAndFamily & FF_MODERN)
strcpyW(FaceName, defFixed); strcpyW(lf.lfFaceName, defFixed);
else if(plf->lfPitchAndFamily & FF_ROMAN) else if(lf.lfPitchAndFamily & FF_ROMAN)
strcpyW(FaceName, defSerif); strcpyW(lf.lfFaceName, defSerif);
else if(plf->lfPitchAndFamily & FF_SWISS) else if(lf.lfPitchAndFamily & FF_SWISS)
strcpyW(FaceName, defSans); strcpyW(lf.lfFaceName, defSans);
else else
strcpyW(FaceName, defSans); strcpyW(lf.lfFaceName, defSans);
for(family = FontList; family; family = family->next) { for(family = FontList; family; family = family->next) {
if(!strcmpiW(family->FamilyName, FaceName)) if(!strcmpiW(family->FamilyName, lf.lfFaceName))
break; break;
} }
} }
...@@ -883,8 +879,8 @@ not_found: ...@@ -883,8 +879,8 @@ not_found:
FIXME("just using first face for now\n"); FIXME("just using first face for now\n");
} }
it = plf->lfItalic ? 1 : 0; it = lf.lfItalic ? 1 : 0;
bd = plf->lfWeight > 550 ? 1 : 0; bd = lf.lfWeight > 550 ? 1 : 0;
for(face = family->FirstFace; face; face = face->next) { for(face = family->FirstFace; face; face = face->next) {
if(!(face->Italic ^ it) && !(face->Bold ^ bd)) if(!(face->Italic ^ it) && !(face->Bold ^ bd))
...@@ -895,24 +891,22 @@ not_found: ...@@ -895,24 +891,22 @@ not_found:
if(it && !face->Italic) ret->fake_italic = TRUE; if(it && !face->Italic) ret->fake_italic = TRUE;
if(bd && !face->Bold) ret->fake_bold = 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), TRACE("Choosen %s %s\n", debugstr_w(family->FamilyName),
debugstr_w(face->StyleName)); debugstr_w(face->StyleName));
ret->ft_face = OpenFontFile(ret, face->file, ret->ft_face = OpenFontFile(ret, face->file,
INTERNAL_YWSTODS(dc,plf->lfHeight)); INTERNAL_YWSTODS(dc,lf.lfHeight));
if (!ret->ft_face) if (!ret->ft_face)
{ {
GDI_ReleaseObj(hfont);
free_font( ret ); free_font( ret );
return 0; return 0;
} }
if(ret->charset == SYMBOL_CHARSET) if(ret->charset == SYMBOL_CHARSET)
pFT_Select_Charmap(ret->ft_face, ft_encoding_symbol); pFT_Select_Charmap(ret->ft_face, ft_encoding_symbol);
ret->orientation = plf->lfOrientation; ret->orientation = lf.lfOrientation;
GDI_ReleaseObj(hfont);
TRACE("caching: gdiFont=%p hfont=%x\n", ret, hfont); TRACE("caching: gdiFont=%p hfont=%x\n", ret, hfont);
ret->hfont = hfont; ret->hfont = hfont;
...@@ -928,11 +922,10 @@ static void DumpGdiFontList(void) ...@@ -928,11 +922,10 @@ static void DumpGdiFontList(void)
TRACE("---------- gdiFont Cache ----------\n"); TRACE("---------- gdiFont Cache ----------\n");
for(gdiFont = GdiFontList; gdiFont; gdiFont = gdiFont->next) { for(gdiFont = GdiFontList; gdiFont; gdiFont = gdiFont->next) {
FONTOBJ *font = GDI_GetObjPtr(gdiFont->hfont, FONT_MAGIC); LOGFONTW lf;
LOGFONTW *plf = &font->logfont; GetObjectW( gdiFont->hfont, sizeof(lf), &lf );
TRACE("gdiFont=%p hfont=%x (%s)\n", TRACE("gdiFont=%p hfont=%x (%s)\n",
gdiFont, gdiFont->hfont, debugstr_w(plf->lfFaceName)); gdiFont, gdiFont->hfont, debugstr_w(lf.lfFaceName));
GDI_ReleaseObj(gdiFont->hfont);
} }
} }
...@@ -1867,4 +1860,3 @@ DWORD WineEngGetFontData(GdiFont font, DWORD table, DWORD offset, LPVOID buf, ...@@ -1867,4 +1860,3 @@ DWORD WineEngGetFontData(GdiFont font, DWORD table, DWORD offset, LPVOID buf,
return GDI_ERROR; return GDI_ERROR;
} }
#endif /* HAVE_FREETYPE */ #endif /* HAVE_FREETYPE */
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "windef.h" #include "windef.h"
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "gdi.h" #include "gdi.h"
#include "metafile.h"
#include "mfdrv/metafiledrv.h" #include "mfdrv/metafiledrv.h"
#include "wine/debug.h" #include "wine/debug.h"
......
...@@ -66,6 +66,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(font); ...@@ -66,6 +66,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(font);
#define REMOVE_SUBSETS 1 #define REMOVE_SUBSETS 1
#define UNMARK_SUBSETS 0 #define UNMARK_SUBSETS 0
#define FONTCACHE 32 /* dynamic font cache size */
#define FF_FAMILY (FF_MODERN | FF_SWISS | FF_ROMAN | FF_DECORATIVE | FF_SCRIPT) #define FF_FAMILY (FF_MODERN | FF_SWISS | FF_ROMAN | FF_DECORATIVE | FF_SCRIPT)
......
...@@ -23,52 +23,6 @@ ...@@ -23,52 +23,6 @@
#include "gdi.h" #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 BOOL FONT_Init( UINT16* pTextCaps );
extern void FONT_LogFontATo16( const LOGFONTA* font32, LPLOGFONT16 font16 ); extern void FONT_LogFontATo16( const LOGFONTA* font32, LPLOGFONT16 font16 );
extern void FONT_LogFontWTo16( const LOGFONTW* font32, LPLOGFONT16 font16 ); extern void FONT_LogFontWTo16( const LOGFONTW* font32, LPLOGFONT16 font16 );
......
...@@ -283,6 +283,14 @@ typedef struct tagDC_FUNCS ...@@ -283,6 +283,14 @@ typedef struct tagDC_FUNCS
/* extra stock object: default 1x1 bitmap for memory DCs */ /* extra stock object: default 1x1 bitmap for memory DCs */
#define DEFAULT_BITMAP (STOCK_LAST+1) #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 */ /* Device <-> logical coords conversion */
/* A floating point version of the POINT structure */ /* A floating point version of the POINT structure */
...@@ -595,12 +603,17 @@ extern DC * DC_GetDCUpdate( HDC hdc ); ...@@ -595,12 +603,17 @@ extern DC * DC_GetDCUpdate( HDC hdc );
extern void DC_InitDC( DC * dc ); extern void DC_InitDC( DC * dc );
extern void DC_UpdateXforms( DC * dc ); extern void DC_UpdateXforms( DC * dc );
/* objects/clipping.c */ /* clipping.c */
extern void CLIPPING_UpdateGCRegion( DC * dc ); extern void CLIPPING_UpdateGCRegion( DC * dc );
/* objects/enhmetafile.c */ /* enhmetafile.c */
extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk ); 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 */ /* region.c */
extern HRGN REGION_CropRgn( HRGN hDst, HRGN hSrc, const RECT *lpRect, const POINT *lpPt ); 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 ); extern BOOL REGION_FrameRgn( HRGN dest, HRGN src, INT x, INT y );
......
/*
* 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 */
...@@ -140,6 +140,39 @@ typedef struct ...@@ -140,6 +140,39 @@ typedef struct
LONG dfReserved1[4]; LONG dfReserved1[4];
} FONTINFO16, *LPFONTINFO16; } 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 typedef struct
{ {
INT16 tmHeight; INT16 tmHeight;
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
#include "winbase.h" #include "winbase.h"
#include "wingdi.h" #include "wingdi.h"
#include "winerror.h" #include "winerror.h"
#include "gdi.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "metafile.h"
WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile); WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
...@@ -2189,6 +2189,3 @@ error: ...@@ -2189,6 +2189,3 @@ error:
return 0; return 0;
} }
...@@ -53,6 +53,12 @@ static const struct gdi_obj_funcs font_funcs = ...@@ -53,6 +53,12 @@ static const struct gdi_obj_funcs font_funcs =
typedef struct typedef struct
{ {
GDIOBJHDR header;
LOGFONTW logfont;
} FONTOBJ;
typedef struct
{
LPLOGFONT16 lpLogFontParam; LPLOGFONT16 lpLogFontParam;
FONTENUMPROCEX16 lpEnumFunc; FONTENUMPROCEX16 lpEnumFunc;
LPARAM lpData; LPARAM lpData;
......
...@@ -52,8 +52,6 @@ ...@@ -52,8 +52,6 @@
#include "wine/wingdi16.h" #include "wine/wingdi16.h"
#include "bitmap.h" #include "bitmap.h"
#include "global.h" #include "global.h"
#include "metafile.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(metafile); WINE_DEFAULT_DEBUG_CHANNEL(metafile);
...@@ -67,6 +65,12 @@ typedef struct ...@@ -67,6 +65,12 @@ typedef struct
} METAHEADERDISK; } METAHEADERDISK;
#include "poppack.h" #include "poppack.h"
typedef struct
{
GDIOBJHDR header;
METAHEADER *mh;
} METAFILEOBJ;
#define MFHEADERSIZE (sizeof(METAHEADER)) #define MFHEADERSIZE (sizeof(METAHEADER))
#define MFVERSION 0x300 #define MFVERSION 0x300
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment