dwrite/tests: Test for lineGap metric.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
fda63a754a
commit
0d77aaccf1
|
@ -205,6 +205,23 @@ typedef struct {
|
||||||
ULONG maxmemType1;
|
ULONG maxmemType1;
|
||||||
} TT_POST;
|
} TT_POST;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
ULONG version;
|
||||||
|
SHORT ascender;
|
||||||
|
SHORT descender;
|
||||||
|
SHORT linegap;
|
||||||
|
USHORT advanceWidthMax;
|
||||||
|
SHORT minLeftSideBearing;
|
||||||
|
SHORT minRightSideBearing;
|
||||||
|
SHORT xMaxExtent;
|
||||||
|
SHORT caretSlopeRise;
|
||||||
|
SHORT caretSlopeRun;
|
||||||
|
SHORT caretOffset;
|
||||||
|
SHORT reserved[4];
|
||||||
|
SHORT metricDataFormat;
|
||||||
|
USHORT numberOfHMetrics;
|
||||||
|
} TT_HHEA;
|
||||||
|
|
||||||
#include "poppack.h"
|
#include "poppack.h"
|
||||||
|
|
||||||
static IDWriteFactory *create_factory(void)
|
static IDWriteFactory *create_factory(void)
|
||||||
|
@ -1534,10 +1551,11 @@ todo_wine
|
||||||
|
|
||||||
static void get_expected_font_metrics(IDWriteFontFace *fontface, DWRITE_FONT_METRICS1 *metrics)
|
static void get_expected_font_metrics(IDWriteFontFace *fontface, DWRITE_FONT_METRICS1 *metrics)
|
||||||
{
|
{
|
||||||
void *os2_context, *head_context, *post_context;
|
void *os2_context, *head_context, *post_context, *hhea_context;
|
||||||
const TT_OS2_V2 *tt_os2;
|
const TT_OS2_V2 *tt_os2;
|
||||||
const TT_HEAD *tt_head;
|
const TT_HEAD *tt_head;
|
||||||
const TT_POST *tt_post;
|
const TT_POST *tt_post;
|
||||||
|
const TT_HHEA *tt_hhea;
|
||||||
UINT32 size;
|
UINT32 size;
|
||||||
BOOL exists;
|
BOOL exists;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -1548,6 +1566,8 @@ static void get_expected_font_metrics(IDWriteFontFace *fontface, DWRITE_FONT_MET
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_HEAD_TAG, (const void**)&tt_head, &size, &head_context, &exists);
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_HEAD_TAG, (const void**)&tt_head, &size, &head_context, &exists);
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_HHEA_TAG, (const void**)&tt_hhea, &size, &hhea_context, &exists);
|
||||||
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_POST_TAG, (const void**)&tt_post, &size, &post_context, &exists);
|
hr = IDWriteFontFace_TryGetFontTable(fontface, MS_POST_TAG, (const void**)&tt_post, &size, &post_context, &exists);
|
||||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||||
|
|
||||||
|
@ -1564,6 +1584,7 @@ static void get_expected_font_metrics(IDWriteFontFace *fontface, DWRITE_FONT_MET
|
||||||
SHORT descent = GET_BE_WORD(tt_os2->sTypoDescender);
|
SHORT descent = GET_BE_WORD(tt_os2->sTypoDescender);
|
||||||
metrics->ascent = GET_BE_WORD(tt_os2->sTypoAscender);
|
metrics->ascent = GET_BE_WORD(tt_os2->sTypoAscender);
|
||||||
metrics->descent = descent < 0 ? -descent : 0;
|
metrics->descent = descent < 0 ? -descent : 0;
|
||||||
|
metrics->lineGap = GET_BE_WORD(tt_os2->sTypoLineGap);
|
||||||
metrics->hasTypographicMetrics = TRUE;
|
metrics->hasTypographicMetrics = TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1571,6 +1592,15 @@ static void get_expected_font_metrics(IDWriteFontFace *fontface, DWRITE_FONT_MET
|
||||||
/* Some fonts have usWinDescent value stored as signed short, which could be wrongly
|
/* Some fonts have usWinDescent value stored as signed short, which could be wrongly
|
||||||
interpreted as large unsigned value. */
|
interpreted as large unsigned value. */
|
||||||
metrics->descent = abs((SHORT)GET_BE_WORD(tt_os2->usWinDescent));
|
metrics->descent = abs((SHORT)GET_BE_WORD(tt_os2->usWinDescent));
|
||||||
|
|
||||||
|
if (tt_hhea) {
|
||||||
|
SHORT descender = (SHORT)GET_BE_WORD(tt_hhea->descender);
|
||||||
|
INT32 linegap;
|
||||||
|
|
||||||
|
linegap = GET_BE_WORD(tt_hhea->ascender) + abs(descender) + GET_BE_WORD(tt_hhea->linegap) -
|
||||||
|
metrics->ascent - metrics->descent;
|
||||||
|
metrics->lineGap = linegap > 0 ? linegap : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
metrics->strikethroughPosition = GET_BE_WORD(tt_os2->yStrikeoutPosition);
|
metrics->strikethroughPosition = GET_BE_WORD(tt_os2->yStrikeoutPosition);
|
||||||
|
@ -1606,6 +1636,8 @@ static void get_expected_font_metrics(IDWriteFontFace *fontface, DWRITE_FONT_MET
|
||||||
IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
|
IDWriteFontFace_ReleaseFontTable(fontface, os2_context);
|
||||||
if (tt_head)
|
if (tt_head)
|
||||||
IDWriteFontFace_ReleaseFontTable(fontface, head_context);
|
IDWriteFontFace_ReleaseFontTable(fontface, head_context);
|
||||||
|
if (tt_hhea)
|
||||||
|
IDWriteFontFace_ReleaseFontTable(fontface, hhea_context);
|
||||||
if (tt_post)
|
if (tt_post)
|
||||||
IDWriteFontFace_ReleaseFontTable(fontface, post_context);
|
IDWriteFontFace_ReleaseFontTable(fontface, post_context);
|
||||||
}
|
}
|
||||||
|
@ -1619,6 +1651,8 @@ static void check_font_metrics(const WCHAR *nameW, BOOL has_metrics1, const DWRI
|
||||||
expected->ascent);
|
expected->ascent);
|
||||||
ok(got->descent == expected->descent, "font %s: descent %u, expected %u\n", wine_dbgstr_w(nameW), got->descent,
|
ok(got->descent == expected->descent, "font %s: descent %u, expected %u\n", wine_dbgstr_w(nameW), got->descent,
|
||||||
expected->descent);
|
expected->descent);
|
||||||
|
ok(got->lineGap == expected->lineGap, "font %s: lineGap %d, expected %d\n", wine_dbgstr_w(nameW), got->lineGap,
|
||||||
|
expected->lineGap);
|
||||||
ok(got->underlinePosition == expected->underlinePosition, "font %s: underlinePosition %d, expected %d\n",
|
ok(got->underlinePosition == expected->underlinePosition, "font %s: underlinePosition %d, expected %d\n",
|
||||||
wine_dbgstr_w(nameW), got->underlinePosition, expected->underlinePosition);
|
wine_dbgstr_w(nameW), got->underlinePosition, expected->underlinePosition);
|
||||||
ok(got->underlineThickness == expected->underlineThickness, "font %s: underlineThickness %u, "
|
ok(got->underlineThickness == expected->underlineThickness, "font %s: underlineThickness %u, "
|
||||||
|
|
Loading…
Reference in New Issue