gdi32: Use RtlUshortByteSwap to read big endian words.

This commit is contained in:
Huw Davies 2006-04-04 12:12:41 +01:00 committed by Alexandre Julliard
parent be720179b6
commit d8a2fb971b
1 changed files with 29 additions and 18 deletions

View File

@ -35,6 +35,7 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winternl.h"
#include "winerror.h" #include "winerror.h"
#include "winreg.h" #include "winreg.h"
#include "wingdi.h" #include "wingdi.h"
@ -168,7 +169,11 @@ MAKE_FUNCPTR(FcPatternGet);
#define FT_ENCODING_APPLE_ROMAN ft_encoding_apple_roman #define FT_ENCODING_APPLE_ROMAN ft_encoding_apple_roman
#endif #endif
#define GET_BE_WORD(ptr) MAKEWORD( ((BYTE *)(ptr))[1], ((BYTE *)(ptr))[0] ) #ifdef WORDS_BIGENDIAN
#define GET_BE_WORD(x) (x)
#else
#define GET_BE_WORD(x) RtlUshortByteSwap(x)
#endif
/* This is bascially a copy of FT_Bitmap_Size with an extra element added */ /* This is bascially a copy of FT_Bitmap_Size with an extra element added */
typedef struct { typedef struct {
@ -1898,10 +1903,16 @@ typedef struct {
BYTE yEndRatio; BYTE yEndRatio;
} Ratios; } Ratios;
typedef struct {
WORD recs;
BYTE startsz;
BYTE endsz;
} VDMX_group;
static LONG load_VDMX(GdiFont font, LONG height) static LONG load_VDMX(GdiFont font, LONG height)
{ {
BYTE hdr[6], tmp[2], group[4]; WORD hdr[3], tmp;
VDMX_group group;
BYTE devXRatio, devYRatio; BYTE devXRatio, devYRatio;
USHORT numRecs, numRatios; USHORT numRecs, numRatios;
DWORD result, offset = -1; DWORD result, offset = -1;
@ -1921,8 +1932,8 @@ static LONG load_VDMX(GdiFont font, LONG height)
devXRatio = 1; devXRatio = 1;
devYRatio = 1; devYRatio = 1;
numRecs = GET_BE_WORD(&hdr[2]); numRecs = GET_BE_WORD(hdr[1]);
numRatios = GET_BE_WORD(&hdr[4]); numRatios = GET_BE_WORD(hdr[2]);
TRACE("numRecs = %d numRatios = %d\n", numRecs, numRatios); TRACE("numRecs = %d numRatios = %d\n", numRecs, numRatios);
for(i = 0; i < numRatios; i++) { for(i = 0; i < numRatios; i++) {
@ -1942,7 +1953,7 @@ static LONG load_VDMX(GdiFont font, LONG height)
devYRatio <= ratio.yEndRatio)) devYRatio <= ratio.yEndRatio))
{ {
offset = (3 * 2) + (numRatios * 4) + (i * 2); offset = (3 * 2) + (numRatios * 4) + (i * 2);
WineEngGetFontData(font, MS_VDMX_TAG, offset, tmp, 2); WineEngGetFontData(font, MS_VDMX_TAG, offset, &tmp, 2);
offset = GET_BE_WORD(tmp); offset = GET_BE_WORD(tmp);
break; break;
} }
@ -1953,14 +1964,14 @@ static LONG load_VDMX(GdiFont font, LONG height)
return ppem; return ppem;
} }
if(WineEngGetFontData(font, MS_VDMX_TAG, offset, group, 4) != GDI_ERROR) { if(WineEngGetFontData(font, MS_VDMX_TAG, offset, &group, 4) != GDI_ERROR) {
USHORT recs; USHORT recs;
BYTE startsz, endsz; BYTE startsz, endsz;
BYTE *vTable; WORD *vTable;
recs = GET_BE_WORD(group); recs = GET_BE_WORD(group.recs);
startsz = group[2]; startsz = group.startsz;
endsz = group[3]; endsz = group.endsz;
TRACE("recs=%d startsz=%d endsz=%d\n", recs, startsz, endsz); TRACE("recs=%d startsz=%d endsz=%d\n", recs, startsz, endsz);
@ -1973,9 +1984,9 @@ static LONG load_VDMX(GdiFont font, LONG height)
if(height > 0) { if(height > 0) {
for(i = 0; i < recs; i++) { for(i = 0; i < recs; i++) {
SHORT yMax = GET_BE_WORD(&vTable[(i * 6) + 2]); SHORT yMax = GET_BE_WORD(vTable[(i * 3) + 1]);
SHORT yMin = GET_BE_WORD(&vTable[(i * 6) + 4]); SHORT yMin = GET_BE_WORD(vTable[(i * 3) + 2]);
ppem = GET_BE_WORD(&vTable[i * 6]); ppem = GET_BE_WORD(vTable[i * 3]);
if(yMax + -yMin == height) { if(yMax + -yMin == height) {
font->yMax = yMax; font->yMax = yMax;
@ -1988,8 +1999,8 @@ static LONG load_VDMX(GdiFont font, LONG height)
ppem = 0; ppem = 0;
goto end; /* failed */ goto end; /* failed */
} }
font->yMax = GET_BE_WORD(&vTable[(i * 6) + 2]); font->yMax = GET_BE_WORD(vTable[(i * 3) + 1]);
font->yMin = GET_BE_WORD(&vTable[(i * 6) + 4]); font->yMin = GET_BE_WORD(vTable[(i * 3) + 2]);
TRACE("ppem %ld found; height=%ld yMax=%d yMin=%d\n", ppem, height, font->yMax, font->yMin); TRACE("ppem %ld found; height=%ld yMax=%d yMin=%d\n", ppem, height, font->yMax, font->yMin);
break; break;
} }
@ -2005,14 +2016,14 @@ static LONG load_VDMX(GdiFont font, LONG height)
for(i = 0; i < recs; i++) { for(i = 0; i < recs; i++) {
USHORT yPelHeight; USHORT yPelHeight;
yPelHeight = GET_BE_WORD(&vTable[i * 6]); yPelHeight = GET_BE_WORD(vTable[i * 3]);
if(yPelHeight > ppem) if(yPelHeight > ppem)
break; /* failed */ break; /* failed */
if(yPelHeight == ppem) { if(yPelHeight == ppem) {
font->yMax = GET_BE_WORD(&vTable[(i * 6) + 2]); font->yMax = GET_BE_WORD(vTable[(i * 3) + 1]);
font->yMin = GET_BE_WORD(&vTable[(i * 6) + 4]); font->yMin = GET_BE_WORD(vTable[(i * 3) + 2]);
TRACE("ppem %ld found; yMax=%d yMin=%d\n", ppem, font->yMax, font->yMin); TRACE("ppem %ld found; yMax=%d yMin=%d\n", ppem, font->yMax, font->yMin);
break; break;
} }