mirror of
https://github.com/reactos/wine.git
synced 2025-02-20 12:50:53 +00:00
gdi32: Add support for checking the font's gasp flags.
This commit is contained in:
parent
225de02a29
commit
4ce3af3fad
@ -32,11 +32,18 @@
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
#include "winternl.h"
|
||||
#include "gdi_private.h"
|
||||
#include "wine/exception.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define get_be_word(x) (x)
|
||||
#else
|
||||
#define get_be_word(x) RtlUshortByteSwap(x)
|
||||
#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(font);
|
||||
|
||||
/* Device -> World size conversion */
|
||||
@ -258,10 +265,73 @@ static void FONT_NewTextMetricExWToA(const NEWTEXTMETRICEXW *ptmW, NEWTEXTMETRIC
|
||||
memcpy(&ptmA->ntmFontSig, &ptmW->ntmFontSig, sizeof(FONTSIGNATURE));
|
||||
}
|
||||
|
||||
static DWORD get_font_ppem( HDC hdc )
|
||||
{
|
||||
TEXTMETRICW tm;
|
||||
DWORD ppem;
|
||||
DC *dc = get_dc_ptr( hdc );
|
||||
|
||||
if (!dc) return GDI_ERROR;
|
||||
|
||||
GetTextMetricsW( hdc, &tm );
|
||||
ppem = abs( INTERNAL_YWSTODS( dc, tm.tmAscent + tm.tmDescent - tm.tmInternalLeading ) );
|
||||
release_dc_ptr( dc );
|
||||
return ppem;
|
||||
}
|
||||
|
||||
#define GASP_GRIDFIT 0x01
|
||||
#define GASP_DOGRAY 0x02
|
||||
|
||||
static BOOL get_gasp_flags( HDC hdc, WORD *flags )
|
||||
{
|
||||
DWORD size, gasp_tag = 0x70736167;
|
||||
WORD buf[16]; /* Enough for seven ranges before we need to alloc */
|
||||
WORD *alloced = NULL, *ptr = buf;
|
||||
WORD num_recs, version;
|
||||
DWORD ppem = get_font_ppem( hdc );
|
||||
BOOL ret = FALSE;
|
||||
|
||||
*flags = 0;
|
||||
if (ppem == GDI_ERROR) return FALSE;
|
||||
|
||||
size = GetFontData( hdc, gasp_tag, 0, NULL, 0 );
|
||||
if (size == GDI_ERROR) return FALSE;
|
||||
if (size < 4 * sizeof(WORD)) return FALSE;
|
||||
if (size > sizeof(buf))
|
||||
{
|
||||
ptr = alloced = HeapAlloc( GetProcessHeap(), 0, size );
|
||||
if (!ptr) return FALSE;
|
||||
}
|
||||
|
||||
GetFontData( hdc, gasp_tag, 0, ptr, size );
|
||||
|
||||
version = get_be_word( *ptr++ );
|
||||
num_recs = get_be_word( *ptr++ );
|
||||
|
||||
if (version > 1 || size < (num_recs * 2 + 2) * sizeof(WORD))
|
||||
{
|
||||
FIXME( "Unsupported gasp table: ver %d size %d recs %d\n", version, size, num_recs );
|
||||
goto done;
|
||||
}
|
||||
|
||||
while (num_recs--)
|
||||
{
|
||||
*flags = get_be_word( *(ptr + 1) );
|
||||
if (ppem <= get_be_word( *ptr )) break;
|
||||
ptr += 2;
|
||||
}
|
||||
TRACE( "got flags %04x for ppem %d\n", *flags, ppem );
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
HeapFree( GetProcessHeap(), 0, alloced );
|
||||
return ret;
|
||||
}
|
||||
|
||||
UINT get_font_aa_flags( HDC hdc )
|
||||
{
|
||||
LOGFONTW lf;
|
||||
WORD gasp_flags;
|
||||
|
||||
if (GetObjectType( hdc ) == OBJ_MEMDC)
|
||||
{
|
||||
@ -274,7 +344,10 @@ UINT get_font_aa_flags( HDC hdc )
|
||||
GetObjectW( GetCurrentObject( hdc, OBJ_FONT ), sizeof(lf), &lf );
|
||||
if (lf.lfQuality == NONANTIALIASED_QUALITY) return GGO_BITMAP;
|
||||
|
||||
/* FIXME, check gasp and user prefs */
|
||||
if (get_gasp_flags( hdc, &gasp_flags ) && !(gasp_flags & GASP_DOGRAY))
|
||||
return GGO_BITMAP;
|
||||
|
||||
/* FIXME, check user prefs */
|
||||
return GGO_GRAY4_BITMAP;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user