Commit 814654ef authored by Huw D M Davies's avatar Huw D M Davies Committed by Alexandre Julliard

Lay down the infrastructure for gdi font rendering.

Partial implementation of GetGylphOutline and GetOutlineTextMetrics for gdi fonts.
parent 37a4639e
......@@ -407,7 +407,8 @@ else
freetype/tttables.h \
freetype/ftnames.h \
freetype/ftsnames.h \
freetype/ttnameid.h)
freetype/ttnameid.h \
freetype/ftoutln.h)
CPPFLAGS="$ac_save_CPPFLAGS"
wine_cv_msg_freetype=no
fi
......
......@@ -6,10 +6,13 @@ MODULE = gdi32
SOVERSION = 1.0
ALTNAMES = gdi dispdib wing
IMPORTS = kernel32 ntdll
EXTRALIBS = @FREETYPELIBS@
EXTRAINCL = @FREETYPEINCL@
C_SRCS = \
bidi16.c \
driver.c \
freetype.c \
gdi_main.c \
printdrv.c \
thunk.c \
......
......@@ -37,14 +37,9 @@ static HBRUSH TTYDRV_DC_BRUSH_SelectObject(DC *dc, HBRUSH hbrush)
*/
static HFONT TTYDRV_DC_FONT_SelectObject(DC* dc, HFONT hfont)
{
HFONT hPreviousFont;
TRACE("(%p, 0x%04x)\n", dc, hfont);
hPreviousFont = dc->hFont;
dc->hFont = hfont;
return hPreviousFont;
return TRUE; /* Use device font */
}
/***********************************************************************
......
......@@ -130,7 +130,6 @@ static VOID ScaleFont(const AFM *afm, LONG lfHeight, PSFONT *font,
HFONT PSDRV_FONT_SelectObject( DC * dc, HFONT hfont )
{
LOGFONTW lf;
HFONT16 prevfont = dc->hFont;
PSDRV_PDEVICE *physDev = (PSDRV_PDEVICE *)dc->physDev;
BOOL bd = FALSE, it = FALSE;
AFMLISTENTRY *afmle;
......@@ -143,8 +142,6 @@ HFONT PSDRV_FONT_SelectObject( DC * dc, HFONT hfont )
debugstr_w(lf.lfFaceName), lf.lfHeight, lf.lfItalic,
lf.lfWeight);
dc->hFont = hfont;
if(lf.lfItalic)
it = TRUE;
if(lf.lfWeight > 550)
......@@ -258,7 +255,7 @@ HFONT PSDRV_FONT_SelectObject( DC * dc, HFONT hfont )
physDev->font.tm.tmDigitizedAspectX = physDev->logPixelsY;
physDev->font.tm.tmDigitizedAspectY = physDev->logPixelsX;
return prevfont;
return TRUE; /* We'll use a device font for now */
}
/***********************************************************************
......
......@@ -178,7 +178,6 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
{
EMRSELECTOBJECT emr;
DWORD index;
HFONT hOldFont;
int i;
/* If the object is a stock font object, do not need to create it.
......@@ -195,17 +194,15 @@ static HFONT EMFDRV_FONT_SelectObject( DC * dc, HFONT hFont )
goto found;
}
}
if (!(index = EMFDRV_CreateFontIndirect(dc, hFont ))) return 0;
if (!(index = EMFDRV_CreateFontIndirect(dc, hFont ))) return GDI_ERROR;
found:
emr.emr.iType = EMR_SELECTOBJECT;
emr.emr.nSize = sizeof(emr);
emr.ihObject = index;
if(!EMFDRV_WriteRecord( dc, &emr.emr ))
return FALSE;
return GDI_ERROR;
hOldFont = dc->hFont;
dc->hFont = hFont;
return hOldFont;
return FALSE;
}
......
......@@ -178,13 +178,12 @@ static BOOL MFDRV_CreateFontIndirect(DC *dc, HFONT16 hFont, LOGFONT16 *logfont)
*/
static HFONT MFDRV_FONT_SelectObject( DC * dc, HFONT hfont )
{
HFONT16 prevHandle = dc->hFont;
LOGFONT16 lf16;
if (!GetObject16( hfont, sizeof(lf16), &lf16 )) return 0;
if (!GetObject16( hfont, sizeof(lf16), &lf16 )) return GDI_ERROR;
if (MFDRV_CreateFontIndirect(dc, hfont, &lf16))
return prevHandle;
return 0;
return FALSE;
return GDI_ERROR;
}
/******************************************************************
......
......@@ -75,12 +75,10 @@ BOOL WIN16DRV_GetTextMetrics( DC *dc, TEXTMETRICW *metrics )
HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont)
{
WIN16DRV_PDEVICE *physDev = (WIN16DRV_PDEVICE *)dc->physDev;
HPEN prevHandle = dc->hFont;
int nSize;
if (!GetObject16( hfont, sizeof(physDev->lf), &physDev->lf )) return 0;
dc->hFont = hfont;
if (!GetObject16( hfont, sizeof(physDev->lf), &physDev->lf ))
return GDI_ERROR;
TRACE("WIN16DRV_FONT_SelectObject %s h=%d\n",
debugstr_a(physDev->lf.lfFaceName), physDev->lf.lfHeight);
......@@ -146,11 +144,11 @@ HFONT WIN16DRV_FONT_SelectObject( DC * dc, HFONT hfont)
physDev->tm.tmMaxCharWidth,
physDev->tm.tmWeight);
return prevHandle;
return TRUE; /* We'll use a device font */
}
/***********************************************************************
* GetCharWidth32A (GDI32.@)
* WIN16DRV_GetCharWidth
*/
BOOL WIN16DRV_GetCharWidth( DC *dc, UINT firstChar, UINT lastChar,
LPINT buffer )
......
......@@ -3146,12 +3146,14 @@ LPIFONTINFO16 XFONT_GetFontInfo( X_PHYSFONT pFont )
*/
HFONT X11DRV_FONT_SelectObject( DC* dc, HFONT hfont )
{
HFONT hPrevFont = 0;
LOGFONTW logfont;
LOGFONT16 lf;
X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
if (!GetObjectW( hfont, sizeof(logfont), &logfont )) return 0;
if (!GetObjectW( hfont, sizeof(logfont), &logfont )) return GDI_ERROR;
/* If we want to use a gdi font, we should check for XRender extension
and return FALSE here */
EnterCriticalSection( &crtsc_fonts_X11 );
......@@ -3215,12 +3217,9 @@ HFONT X11DRV_FONT_SelectObject( DC* dc, HFONT hfont )
logfont.lfCharSet = charsetMatched;
}
hPrevFont = dc->hFont;
dc->hFont = hfont;
LeaveCriticalSection( &crtsc_fonts_X11 );
return hPrevFont;
return TRUE; /* Use a device font */
}
......
......@@ -229,6 +229,9 @@
/* Define if you have the <freetype/ftnames.h> header file. */
#undef HAVE_FREETYPE_FTNAMES_H
/* Define if you have the <freetype/ftoutln.h> header file. */
#undef HAVE_FREETYPE_FTOUTLN_H
/* Define if you have the <freetype/ftsnames.h> header file. */
#undef HAVE_FREETYPE_FTSNAMES_H
......
......@@ -70,7 +70,18 @@ extern void FONT_TextMetric16ToW(const TEXTMETRIC16 *ptm16, LPTEXTMETRICW ptm32
extern void FONT_TextMetricAToW(const TEXTMETRICA *ptm32A, LPTEXTMETRICW ptm32W );
extern void FONT_NewTextMetricEx16ToW(const NEWTEXTMETRICEX16*, LPNEWTEXTMETRICEXW);
extern void FONT_EnumLogFontEx16ToW(const ENUMLOGFONTEX16*, LPENUMLOGFONTEXW);
extern BOOL ENGINE_InitFonts(void);
extern DWORD WineEngAddRefFont(GdiFont);
extern GdiFont WineEngCreateFontInstance(HFONT);
extern DWORD WineEngDecRefFont(GdiFont);
extern DWORD WineEngEnumFonts(LPLOGFONTW, DEVICEFONTENUMPROC, LPARAM);
extern BOOL WineEngGetCharWidth(GdiFont, UINT, UINT, LPINT);
extern DWORD WineEngGetGlyphOutline(GdiFont, UINT glyph, UINT format,
LPGLYPHMETRICS, DWORD buflen, LPVOID buf,
const MAT2*);
extern UINT WineEngGetOutlineTextMetrics(GdiFont, UINT, LPOUTLINETEXTMETRICW);
extern BOOL WineEngGetTextExtentPoint(GdiFont, LPCWSTR, INT, LPSIZE);
extern BOOL WineEngGetTextMetrics(GdiFont, LPTEXTMETRICW);
extern BOOL WineEngInit(void);
#endif /* __WINE_FONT_H */
......@@ -50,6 +50,8 @@ typedef struct tagGDIOBJHDR
typedef BOOL16 CALLBACK (*DCHOOKPROC)(HDC16,WORD,DWORD,LPARAM);
typedef struct tagGdiFont *GdiFont;
typedef struct tagDC
{
GDIOBJHDR header;
......@@ -81,6 +83,7 @@ typedef struct tagDC
HANDLE16 hDevice;
HPALETTE16 hPalette;
GdiFont gdiFont;
GdiPath path;
WORD ROPmode;
......
......@@ -57,6 +57,7 @@ DC *DC_AllocDC( const DC_FUNCTIONS *funcs )
dc->hBitmap = 0;
dc->hDevice = 0;
dc->hPalette = GetStockObject( DEFAULT_PALETTE );
dc->gdiFont = 0;
dc->ROPmode = R2_COPYPEN;
dc->polyFillMode = ALTERNATE;
dc->stretchBltMode = BLACKONWHITE;
......@@ -311,6 +312,13 @@ HDC16 WINAPI GetDCState16( HDC16 hdc )
}
else
newdc->hClipRgn = 0;
if(dc->gdiFont) {
WineEngAddRefFont(dc->gdiFont);
newdc->gdiFont = dc->gdiFont;
} else
newdc->gdiFont = 0;
GDI_ReleaseObj( handle );
GDI_ReleaseObj( hdc );
return handle;
......@@ -767,6 +775,7 @@ BOOL WINAPI DeleteDC( HDC hdc )
if (dc->hGCClipRgn) DeleteObject( dc->hGCClipRgn );
if (dc->pAbortProc) THUNK_Free( (FARPROC)dc->pAbortProc );
if (dc->hookThunk) THUNK_Free( (FARPROC)dc->hookThunk );
if (dc->gdiFont) WineEngDecRefFont( dc->gdiFont );
PATH_DestroyGdiPath(&dc->path);
GDI_FreeObject( hdc, dc );
......
......@@ -244,6 +244,9 @@ BOOL GDI_Init(void)
}
if (hkey) RegCloseKey( hkey );
WineEngInit();
return TRUE;
}
......@@ -732,7 +735,46 @@ HANDLE WINAPI GetCurrentObject(HDC hdc,UINT type)
}
return ret;
}
/***********************************************************************
* FONT_SelectObject
*
* If the driver supports vector fonts we create a gdi font first and
* then call the driver to give it a chance to supply its own device
* font. If the driver wants to do this it returns TRUE and we can
* delete the gdi font, if the driver wants to use the gdi font it
* should return FALSE, to signal an error return GDI_ERROR. For
* drivers that don't support vector fonts they must supply their own
* font.
*/
static HGDIOBJ FONT_SelectObject(DC *dc, HGDIOBJ hFont)
{
HGDIOBJ ret = FALSE;
if(dc->gdiFont) {
WineEngDecRefFont(dc->gdiFont);
dc->gdiFont = 0;
}
if(GetDeviceCaps(dc->hSelf, TEXTCAPS) & TC_VA_ABLE)
dc->gdiFont = WineEngCreateFontInstance(hFont);
if(dc->funcs->pSelectObject)
ret = dc->funcs->pSelectObject(dc, hFont);
if(ret && dc->gdiFont) {
WineEngDecRefFont(dc->gdiFont);
dc->gdiFont = 0;
}
if(ret == GDI_ERROR)
ret = FALSE; /* SelectObject returns FALSE on error */
else {
ret = dc->hFont;
dc->hFont = hFont;
}
return ret;
}
/***********************************************************************
* SelectObject (GDI.45)
......@@ -752,7 +794,12 @@ HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ handle )
DC * dc = DC_GetDCUpdate( hdc );
if (!dc) return 0;
TRACE("hdc=%04x %04x\n", hdc, handle );
if (dc->funcs->pSelectObject)
/* Fonts get a rather different treatment so we'll handle them
separately */
if(GetObjectType(handle) == OBJ_FONT)
ret = FONT_SelectObject(dc, handle);
else if (dc->funcs->pSelectObject)
ret = dc->funcs->pSelectObject( dc, handle );
GDI_ReleaseObj( hdc );
......
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