Commit 18d7573c authored by Alexandre Julliard's avatar Alexandre Julliard

Authors: Huw D M Davies <hdavies@codeweavers.com>, Charles Loep <charles@codeweavers.com>

Various fixes for gdi font handling code including: - Using TTs VDMX table to ensure that we get exactly that same size font that Windows uses. - Fixes to many members of the metrics structures. - Font cache. - Rotated text support. - Support for GGO_GRAY?_BITMAP (ready for anti-aliased text). - Support for GGO_NATIVE.
parent ba7ccc4c
......@@ -419,6 +419,10 @@ else
freetype/ttnameid.h \
freetype/ftoutln.h \
freetype/internal/sfnt.h)
AC_TRY_CPP([#include <ft2build.h>
#include <freetype/fttrigon.h>],
AC_DEFINE(HAVE_FREETYPE_FTTRIGON_H, 1,
[Define if you have the <freetype/fttrigon.h> header file.]))
CPPFLAGS="$ac_save_CPPFLAGS"
wine_cv_msg_freetype=no
fi
......
......@@ -475,6 +475,9 @@
/* Define if FreeType 2 is installed */
#undef HAVE_FREETYPE
/* Define if you have the <freetype/fttrigon.h> header file. */
#undef HAVE_FREETYPE_FTTRIGON_H
/* Define if we can use ppdev.h for parallel port access */
#undef HAVE_PPDEV
......
......@@ -73,9 +73,8 @@ extern void FONT_EnumLogFontEx16ToW(const ENUMLOGFONTEX16*, LPENUMLOGFONTEXW);
extern LPWSTR FONT_mbtowc(HDC, LPCSTR, INT, INT*, UINT*);
extern DWORD WineEngAddRefFont(GdiFont);
extern GdiFont WineEngCreateFontInstance(HFONT);
extern DWORD WineEngDecRefFont(GdiFont);
extern BOOL WineEngDestroyFontInstance(HFONT handle);
extern DWORD WineEngEnumFonts(LPLOGFONTW, DEVICEFONTENUMPROC, LPARAM);
extern BOOL WineEngGetCharWidth(GdiFont, UINT, UINT, LPINT);
extern DWORD WineEngGetFontData(GdiFont, DWORD, DWORD, LPVOID, DWORD);
......
......@@ -521,4 +521,6 @@ extern void CLIPPING_UpdateGCRegion( DC * dc );
/* objects/enhmetafile.c */
extern HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk );
#define WINE_GGO_GRAY16_BITMAP 0x7f
#endif /* __WINE_GDI_H */
......@@ -316,7 +316,6 @@ HDC16 WINAPI GetDCState16( HDC16 hdc )
newdc->hClipRgn = 0;
if(dc->gdiFont) {
WineEngAddRefFont(dc->gdiFont);
newdc->gdiFont = dc->gdiFont;
} else
newdc->gdiFont = 0;
......@@ -775,7 +774,6 @@ BOOL WINAPI DeleteDC( HDC hdc )
if (dc->hClipRgn) DeleteObject( dc->hClipRgn );
if (dc->hVisRgn) DeleteObject( dc->hVisRgn );
if (dc->hGCClipRgn) DeleteObject( dc->hGCClipRgn );
if (dc->gdiFont) WineEngDecRefFont( dc->gdiFont );
PATH_DestroyGdiPath(&dc->path);
GDI_FreeObject( hdc, dc );
......
......@@ -1648,7 +1648,33 @@ BOOL16 WINAPI GetCharABCWidths16( HDC16 hdc, UINT16 firstChar, UINT16 lastChar,
BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
LPABC abc )
{
return GetCharABCWidthsW( hdc, firstChar, lastChar, abc );
INT i, wlen, count = (INT)(lastChar - firstChar + 1);
LPSTR str;
LPWSTR wstr;
BOOL ret = TRUE;
if(count <= 0) return FALSE;
str = HeapAlloc(GetProcessHeap(), 0, count);
for(i = 0; i < count; i++)
str[i] = (BYTE)(firstChar + i);
wstr = FONT_mbtowc(hdc, str, count, &wlen, NULL);
for(i = 0; i < wlen; i++)
{
if(!GetCharABCWidthsW(hdc, wstr[i], wstr[i], abc))
{
ret = FALSE;
break;
}
abc++;
}
HeapFree(GetProcessHeap(), 0, str);
HeapFree(GetProcessHeap(), 0, wstr);
return ret;
}
......@@ -1671,20 +1697,22 @@ BOOL WINAPI GetCharABCWidthsA(HDC hdc, UINT firstChar, UINT lastChar,
BOOL WINAPI GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar,
LPABC abc )
{
DC *dc = DC_GetDCPtr(hdc);
int i;
LPINT widths = HeapAlloc(GetProcessHeap(),0,(lastChar-firstChar+1)*sizeof(INT));
FIXME("(%04x,%04x,%04x,%p), returns slightly bogus values.\n", hdc, firstChar, lastChar, abc);
GetCharWidth32A(hdc,firstChar,lastChar,widths);
GLYPHMETRICS gm;
BOOL ret = FALSE;
if(dc->gdiFont) {
for (i=firstChar;i<=lastChar;i++) {
abc[i-firstChar].abcA = 0; /* left distance */
abc[i-firstChar].abcB = widths[i-firstChar];/* width */
abc[i-firstChar].abcC = 0; /* right distance */
GetGlyphOutlineW(hdc, i, GGO_METRICS, &gm, 0, NULL, NULL);
abc[i-firstChar].abcA = gm.gmptGlyphOrigin.x;
abc[i-firstChar].abcB = gm.gmBlackBoxX;
abc[i-firstChar].abcC = gm.gmCellIncX - gm.gmptGlyphOrigin.x - gm.gmBlackBoxX;
}
HeapFree(GetProcessHeap(),0,widths);
return TRUE;
ret = TRUE;
}
GDI_ReleaseObj(hdc);
return ret;
}
......@@ -1708,8 +1736,20 @@ DWORD WINAPI GetGlyphOutlineA( HDC hdc, UINT uChar, UINT fuFormat,
LPGLYPHMETRICS lpgm, DWORD cbBuffer,
LPVOID lpBuffer, const MAT2 *lpmat2 )
{
return GetGlyphOutlineW(hdc, uChar, fuFormat, lpgm, cbBuffer, lpBuffer,
LPWSTR p = NULL;
DWORD ret;
UINT c;
if(!(fuFormat & GGO_GLYPH_INDEX)) {
p = FONT_mbtowc(hdc, (char*)&uChar, 1, NULL, NULL);
c = p[0];
} else
c = uChar;
ret = GetGlyphOutlineW(hdc, c, fuFormat, lpgm, cbBuffer, lpBuffer,
lpmat2);
if(p)
HeapFree(GetProcessHeap(), 0, p);
return ret;
}
/***********************************************************************
......
......@@ -450,6 +450,17 @@ void GDI_CheckNotLock(void)
/***********************************************************************
* FONT_DeleteObject
*
*/
static BOOL FONT_DeleteObject(HGDIOBJ hfont, FONTOBJ *fontobj)
{
WineEngDestroyFontInstance( hfont );
return GDI_FreeObject( hfont, fontobj );
}
/***********************************************************************
* DeleteObject (GDI.69)
* SysDeleteObject (GDI.605)
*/
......@@ -495,7 +506,7 @@ BOOL WINAPI DeleteObject( HGDIOBJ obj )
{
case PEN_MAGIC: return GDI_FreeObject( obj, header );
case BRUSH_MAGIC: return BRUSH_DeleteObject( obj, (BRUSHOBJ*)header );
case FONT_MAGIC: return GDI_FreeObject( obj, header );
case FONT_MAGIC: return FONT_DeleteObject( obj, (FONTOBJ*)header );
case PALETTE_MAGIC: return PALETTE_DeleteObject(obj,(PALETTEOBJ*)header);
case BITMAP_MAGIC: return BITMAP_DeleteObject( obj, (BITMAPOBJ*)header);
case REGION_MAGIC: return REGION_DeleteObject( obj, (RGNOBJ*)header );
......@@ -752,19 +763,15 @@ static HGDIOBJ FONT_SelectObject(DC *dc, HGDIOBJ hFont)
{
HGDIOBJ ret = FALSE;
if(dc->gdiFont) {
WineEngDecRefFont(dc->gdiFont);
dc->gdiFont = 0;
}
if(dc->hFont != hFont || dc->gdiFont == NULL) {
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;
}
......
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