mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-21 12:34:09 +00:00
Better encapsulation of the font and metafile objects.
This commit is contained in:
parent
c6476e90ab
commit
78b041cf52
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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 */
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue