Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/tests/core.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index fa874a5ef5..75146575be 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -330,13 +330,13 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
/* D3DXCreateFont */ ref = get_ref((IUnknown*)device); - hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); check_ref((IUnknown*)device, ref + 1); check_release((IUnknown*)font, 0); check_ref((IUnknown*)device, ref);
- hr = D3DXCreateFontA(device, 0, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + hr = D3DXCreateFontA(device, 0, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); ID3DXFont_Release(font);
@@ -348,13 +348,13 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); ID3DXFont_Release(font);
- hr = D3DXCreateFontA(NULL, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + hr = D3DXCreateFontA(NULL, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
- hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", NULL); + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", NULL); ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
- hr = D3DXCreateFontA(NULL, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", NULL); + hr = D3DXCreateFontA(NULL, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", NULL); ok(hr == D3DERR_INVALIDCALL, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
@@ -368,7 +368,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) desc.OutputPrecision = OUT_DEFAULT_PRECIS; desc.Quality = DEFAULT_QUALITY; desc.PitchAndFamily = DEFAULT_PITCH; - strcpy(desc.FaceName, "Arial"); + strcpy(desc.FaceName, "Tahoma"); hr = D3DXCreateFontIndirectA(device, &desc, &font); ok(hr == D3D_OK, "D3DXCreateFontIndirect returned %#x, expected %#x\n", hr, D3D_OK); ID3DXFont_Release(font); @@ -384,7 +384,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
/* ID3DXFont_GetDevice */ - hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); if(SUCCEEDED(hr)) { IDirect3DDevice9 *bufdev;
@@ -401,7 +401,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
/* ID3DXFont_GetDesc */ - hr = D3DXCreateFontA(device, 12, 8, FW_BOLD, 2, TRUE, ANSI_CHARSET, OUT_RASTER_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH, "Arial", &font); + hr = D3DXCreateFontA(device, 12, 8, FW_BOLD, 2, TRUE, ANSI_CHARSET, OUT_RASTER_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH, "Tahoma", &font); if(SUCCEEDED(hr)) { hr = ID3DXFont_GetDescA(font, NULL); ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); @@ -418,14 +418,14 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(desc.OutputPrecision == OUT_RASTER_PRECIS, "ID3DXFont_GetDesc returned an output precision of %d, expected %d\n", desc.OutputPrecision, OUT_RASTER_PRECIS); ok(desc.Quality == ANTIALIASED_QUALITY, "ID3DXFont_GetDesc returned font quality %d, expected %d\n", desc.Quality, ANTIALIASED_QUALITY); ok(desc.PitchAndFamily == VARIABLE_PITCH, "ID3DXFont_GetDesc returned pitch and family %d, expected %d\n", desc.PitchAndFamily, VARIABLE_PITCH); - ok(strcmp(desc.FaceName, "Arial") == 0, "ID3DXFont_GetDesc returned facename "%s", expected "%s"\n", desc.FaceName, "Arial"); + ok(strcmp(desc.FaceName, "Tahoma") == 0, "ID3DXFont_GetDesc returned facename "%s", expected "%s"\n", desc.FaceName, "Tahoma");
ID3DXFont_Release(font); } else skip("Failed to create a ID3DXFont object\n");
/* ID3DXFont_GetDC + ID3DXFont_GetTextMetrics */ - hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); if(SUCCEEDED(hr)) { HDC hdc;
@@ -466,7 +466,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
/* ID3DXFont_PreloadText */ - hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); if(SUCCEEDED(hr)) { todo_wine { hr = ID3DXFont_PreloadTextA(font, NULL, -1); @@ -493,7 +493,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
/* ID3DXFont_GetGlyphData, ID3DXFont_PreloadGlyphs, ID3DXFont_PreloadCharacters */ - hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); if(SUCCEEDED(hr)) { char c; HDC hdc; @@ -565,7 +565,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) IDirect3DTexture9 *texture;
hr = D3DXCreateFontA(device, tests[i].font_height, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, - OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Arial", &font); + OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); if(FAILED(hr)) { skip("Failed to create a ID3DXFont object\n"); continue;
Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/tests/core.c | 289 ++++++++++++++++++------------------- 1 file changed, 138 insertions(+), 151 deletions(-)
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index 75146575be..537109c59d 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -321,12 +321,19 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) { 72, 256, 8 }, }; const unsigned int size = ARRAY_SIZE(testW); + IDirect3DTexture9 *texture; + IDirect3DDevice9 *bufdev; D3DXFONT_DESCA desc; + TEXTMETRICA metrics, expmetrics; ID3DXSprite *sprite; int ref, i, height; ID3DXFont *font; HRESULT hr; - RECT rect; + POINT cellinc; + RECT rect, blackbox; + BOOL ret; + HDC hdc; + char c;
/* D3DXCreateFont */ ref = get_ref((IUnknown*)device); @@ -385,191 +392,172 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
/* ID3DXFont_GetDevice */ hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); - if(SUCCEEDED(hr)) { - IDirect3DDevice9 *bufdev; + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK);
- hr = ID3DXFont_GetDevice(font, NULL); - ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXFont_GetDevice(font, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL);
- ref = get_ref((IUnknown*)device); - hr = ID3DXFont_GetDevice(font, &bufdev); - ok(hr == D3D_OK, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3D_OK); - check_release((IUnknown*)bufdev, ref); + ref = get_ref((IUnknown*)device); + hr = ID3DXFont_GetDevice(font, &bufdev); + ok(hr == D3D_OK, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3D_OK); + check_release((IUnknown*)bufdev, ref);
- ID3DXFont_Release(font); - } else skip("Failed to create a ID3DXFont object\n"); + ID3DXFont_Release(font);
/* ID3DXFont_GetDesc */ hr = D3DXCreateFontA(device, 12, 8, FW_BOLD, 2, TRUE, ANSI_CHARSET, OUT_RASTER_PRECIS, ANTIALIASED_QUALITY, VARIABLE_PITCH, "Tahoma", &font); - if(SUCCEEDED(hr)) { - hr = ID3DXFont_GetDescA(font, NULL); - ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); - - hr = ID3DXFont_GetDescA(font, &desc); - ok(hr == D3D_OK, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3D_OK); - - ok(desc.Height == 12, "ID3DXFont_GetDesc returned font height %d, expected %d\n", desc.Height, 12); - ok(desc.Width == 8, "ID3DXFont_GetDesc returned font width %d, expected %d\n", desc.Width, 8); - ok(desc.Weight == FW_BOLD, "ID3DXFont_GetDesc returned font weight %d, expected %d\n", desc.Weight, FW_BOLD); - ok(desc.MipLevels == 2, "ID3DXFont_GetDesc returned font miplevels %d, expected %d\n", desc.MipLevels, 2); - ok(desc.Italic == TRUE, "ID3DXFont_GetDesc says Italic was %d, but Italic should be %d\n", desc.Italic, TRUE); - ok(desc.CharSet == ANSI_CHARSET, "ID3DXFont_GetDesc returned font charset %d, expected %d\n", desc.CharSet, ANSI_CHARSET); - ok(desc.OutputPrecision == OUT_RASTER_PRECIS, "ID3DXFont_GetDesc returned an output precision of %d, expected %d\n", desc.OutputPrecision, OUT_RASTER_PRECIS); - ok(desc.Quality == ANTIALIASED_QUALITY, "ID3DXFont_GetDesc returned font quality %d, expected %d\n", desc.Quality, ANTIALIASED_QUALITY); - ok(desc.PitchAndFamily == VARIABLE_PITCH, "ID3DXFont_GetDesc returned pitch and family %d, expected %d\n", desc.PitchAndFamily, VARIABLE_PITCH); - ok(strcmp(desc.FaceName, "Tahoma") == 0, "ID3DXFont_GetDesc returned facename "%s", expected "%s"\n", desc.FaceName, "Tahoma"); + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK);
- ID3DXFont_Release(font); - } else skip("Failed to create a ID3DXFont object\n"); + hr = ID3DXFont_GetDescA(font, NULL); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + + hr = ID3DXFont_GetDescA(font, &desc); + ok(hr == D3D_OK, "ID3DXFont_GetDevice returned %#x, expected %#x\n", hr, D3D_OK); + + ok(desc.Height == 12, "ID3DXFont_GetDesc returned font height %d, expected %d\n", desc.Height, 12); + ok(desc.Width == 8, "ID3DXFont_GetDesc returned font width %d, expected %d\n", desc.Width, 8); + ok(desc.Weight == FW_BOLD, "ID3DXFont_GetDesc returned font weight %d, expected %d\n", desc.Weight, FW_BOLD); + ok(desc.MipLevels == 2, "ID3DXFont_GetDesc returned font miplevels %d, expected %d\n", desc.MipLevels, 2); + ok(desc.Italic == TRUE, "ID3DXFont_GetDesc says Italic was %d, but Italic should be %d\n", desc.Italic, TRUE); + ok(desc.CharSet == ANSI_CHARSET, "ID3DXFont_GetDesc returned font charset %d, expected %d\n", desc.CharSet, ANSI_CHARSET); + ok(desc.OutputPrecision == OUT_RASTER_PRECIS, "ID3DXFont_GetDesc returned an output precision of %d, expected %d\n", desc.OutputPrecision, OUT_RASTER_PRECIS); + ok(desc.Quality == ANTIALIASED_QUALITY, "ID3DXFont_GetDesc returned font quality %d, expected %d\n", desc.Quality, ANTIALIASED_QUALITY); + ok(desc.PitchAndFamily == VARIABLE_PITCH, "ID3DXFont_GetDesc returned pitch and family %d, expected %d\n", desc.PitchAndFamily, VARIABLE_PITCH); + ok(strcmp(desc.FaceName, "Tahoma") == 0, "ID3DXFont_GetDesc returned facename "%s", expected "%s"\n", desc.FaceName, "Tahoma"); + + ID3DXFont_Release(font);
/* ID3DXFont_GetDC + ID3DXFont_GetTextMetrics */ hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); - if(SUCCEEDED(hr)) { - HDC hdc; + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK);
- hdc = ID3DXFont_GetDC(font); - ok(hdc != NULL, "ID3DXFont_GetDC returned an invalid handle\n"); - if(hdc) { - TEXTMETRICA metrics, expmetrics; - BOOL ret; - - ret = ID3DXFont_GetTextMetricsA(font, &metrics); - ok(ret, "ID3DXFont_GetTextMetricsA failed\n"); - ret = GetTextMetricsA(hdc, &expmetrics); - ok(ret, "GetTextMetricsA failed\n"); - - ok(metrics.tmHeight == expmetrics.tmHeight, "Returned height %d, expected %d\n", metrics.tmHeight, expmetrics.tmHeight); - ok(metrics.tmAscent == expmetrics.tmAscent, "Returned ascent %d, expected %d\n", metrics.tmAscent, expmetrics.tmAscent); - ok(metrics.tmDescent == expmetrics.tmDescent, "Returned descent %d, expected %d\n", metrics.tmDescent, expmetrics.tmDescent); - ok(metrics.tmInternalLeading == expmetrics.tmInternalLeading, "Returned internal leading %d, expected %d\n", metrics.tmInternalLeading, expmetrics.tmInternalLeading); - ok(metrics.tmExternalLeading == expmetrics.tmExternalLeading, "Returned external leading %d, expected %d\n", metrics.tmExternalLeading, expmetrics.tmExternalLeading); - ok(metrics.tmAveCharWidth == expmetrics.tmAveCharWidth, "Returned average char width %d, expected %d\n", metrics.tmAveCharWidth, expmetrics.tmAveCharWidth); - ok(metrics.tmMaxCharWidth == expmetrics.tmMaxCharWidth, "Returned maximum char width %d, expected %d\n", metrics.tmMaxCharWidth, expmetrics.tmMaxCharWidth); - ok(metrics.tmWeight == expmetrics.tmWeight, "Returned weight %d, expected %d\n", metrics.tmWeight, expmetrics.tmWeight); - ok(metrics.tmOverhang == expmetrics.tmOverhang, "Returned overhang %d, expected %d\n", metrics.tmOverhang, expmetrics.tmOverhang); - ok(metrics.tmDigitizedAspectX == expmetrics.tmDigitizedAspectX, "Returned digitized x aspect %d, expected %d\n", metrics.tmDigitizedAspectX, expmetrics.tmDigitizedAspectX); - ok(metrics.tmDigitizedAspectY == expmetrics.tmDigitizedAspectY, "Returned digitized y aspect %d, expected %d\n", metrics.tmDigitizedAspectY, expmetrics.tmDigitizedAspectY); - ok(metrics.tmFirstChar == expmetrics.tmFirstChar, "Returned first char %d, expected %d\n", metrics.tmFirstChar, expmetrics.tmFirstChar); - ok(metrics.tmLastChar == expmetrics.tmLastChar, "Returned last char %d, expected %d\n", metrics.tmLastChar, expmetrics.tmLastChar); - ok(metrics.tmDefaultChar == expmetrics.tmDefaultChar, "Returned default char %d, expected %d\n", metrics.tmDefaultChar, expmetrics.tmDefaultChar); - ok(metrics.tmBreakChar == expmetrics.tmBreakChar, "Returned break char %d, expected %d\n", metrics.tmBreakChar, expmetrics.tmBreakChar); - ok(metrics.tmItalic == expmetrics.tmItalic, "Returned italic %d, expected %d\n", metrics.tmItalic, expmetrics.tmItalic); - ok(metrics.tmUnderlined == expmetrics.tmUnderlined, "Returned underlined %d, expected %d\n", metrics.tmUnderlined, expmetrics.tmUnderlined); - ok(metrics.tmStruckOut == expmetrics.tmStruckOut, "Returned struck out %d, expected %d\n", metrics.tmStruckOut, expmetrics.tmStruckOut); - ok(metrics.tmPitchAndFamily == expmetrics.tmPitchAndFamily, "Returned pitch and family %d, expected %d\n", metrics.tmPitchAndFamily, expmetrics.tmPitchAndFamily); - ok(metrics.tmCharSet == expmetrics.tmCharSet, "Returned charset %d, expected %d\n", metrics.tmCharSet, expmetrics.tmCharSet); - } - ID3DXFont_Release(font); - } else skip("Failed to create a ID3DXFont object\n"); + hdc = ID3DXFont_GetDC(font); + ok(hdc != NULL, "ID3DXFont_GetDC returned an invalid handle\n"); + + ret = ID3DXFont_GetTextMetricsA(font, &metrics); + ok(ret, "ID3DXFont_GetTextMetricsA failed\n"); + ret = GetTextMetricsA(hdc, &expmetrics); + ok(ret, "GetTextMetricsA failed\n"); + + ok(metrics.tmHeight == expmetrics.tmHeight, "Returned height %d, expected %d\n", metrics.tmHeight, expmetrics.tmHeight); + ok(metrics.tmAscent == expmetrics.tmAscent, "Returned ascent %d, expected %d\n", metrics.tmAscent, expmetrics.tmAscent); + ok(metrics.tmDescent == expmetrics.tmDescent, "Returned descent %d, expected %d\n", metrics.tmDescent, expmetrics.tmDescent); + ok(metrics.tmInternalLeading == expmetrics.tmInternalLeading, "Returned internal leading %d, expected %d\n", metrics.tmInternalLeading, expmetrics.tmInternalLeading); + ok(metrics.tmExternalLeading == expmetrics.tmExternalLeading, "Returned external leading %d, expected %d\n", metrics.tmExternalLeading, expmetrics.tmExternalLeading); + ok(metrics.tmAveCharWidth == expmetrics.tmAveCharWidth, "Returned average char width %d, expected %d\n", metrics.tmAveCharWidth, expmetrics.tmAveCharWidth); + ok(metrics.tmMaxCharWidth == expmetrics.tmMaxCharWidth, "Returned maximum char width %d, expected %d\n", metrics.tmMaxCharWidth, expmetrics.tmMaxCharWidth); + ok(metrics.tmWeight == expmetrics.tmWeight, "Returned weight %d, expected %d\n", metrics.tmWeight, expmetrics.tmWeight); + ok(metrics.tmOverhang == expmetrics.tmOverhang, "Returned overhang %d, expected %d\n", metrics.tmOverhang, expmetrics.tmOverhang); + ok(metrics.tmDigitizedAspectX == expmetrics.tmDigitizedAspectX, "Returned digitized x aspect %d, expected %d\n", metrics.tmDigitizedAspectX, expmetrics.tmDigitizedAspectX); + ok(metrics.tmDigitizedAspectY == expmetrics.tmDigitizedAspectY, "Returned digitized y aspect %d, expected %d\n", metrics.tmDigitizedAspectY, expmetrics.tmDigitizedAspectY); + ok(metrics.tmFirstChar == expmetrics.tmFirstChar, "Returned first char %d, expected %d\n", metrics.tmFirstChar, expmetrics.tmFirstChar); + ok(metrics.tmLastChar == expmetrics.tmLastChar, "Returned last char %d, expected %d\n", metrics.tmLastChar, expmetrics.tmLastChar); + ok(metrics.tmDefaultChar == expmetrics.tmDefaultChar, "Returned default char %d, expected %d\n", metrics.tmDefaultChar, expmetrics.tmDefaultChar); + ok(metrics.tmBreakChar == expmetrics.tmBreakChar, "Returned break char %d, expected %d\n", metrics.tmBreakChar, expmetrics.tmBreakChar); + ok(metrics.tmItalic == expmetrics.tmItalic, "Returned italic %d, expected %d\n", metrics.tmItalic, expmetrics.tmItalic); + ok(metrics.tmUnderlined == expmetrics.tmUnderlined, "Returned underlined %d, expected %d\n", metrics.tmUnderlined, expmetrics.tmUnderlined); + ok(metrics.tmStruckOut == expmetrics.tmStruckOut, "Returned struck out %d, expected %d\n", metrics.tmStruckOut, expmetrics.tmStruckOut); + ok(metrics.tmPitchAndFamily == expmetrics.tmPitchAndFamily, "Returned pitch and family %d, expected %d\n", metrics.tmPitchAndFamily, expmetrics.tmPitchAndFamily); + ok(metrics.tmCharSet == expmetrics.tmCharSet, "Returned charset %d, expected %d\n", metrics.tmCharSet, expmetrics.tmCharSet); + + ID3DXFont_Release(font);
/* ID3DXFont_PreloadText */ hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); - if(SUCCEEDED(hr)) { - todo_wine { - hr = ID3DXFont_PreloadTextA(font, NULL, -1); - ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); - hr = ID3DXFont_PreloadTextA(font, NULL, 0); - ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK); - hr = ID3DXFont_PreloadTextA(font, NULL, 1); - ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); - hr = ID3DXFont_PreloadTextA(font, "test", -1); - ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK); - - hr = ID3DXFont_PreloadTextW(font, NULL, -1); - ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); - hr = ID3DXFont_PreloadTextW(font, NULL, 0); - ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK); - hr = ID3DXFont_PreloadTextW(font, NULL, 1); - ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); - hr = ID3DXFont_PreloadTextW(font, testW, -1); - ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK); - } + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK);
- check_release((IUnknown*)font, 0); - } else skip("Failed to create a ID3DXFont object\n"); + todo_wine { + hr = ID3DXFont_PreloadTextA(font, NULL, -1); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXFont_PreloadTextA(font, NULL, 0); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadTextA(font, NULL, 1); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXFont_PreloadTextA(font, "test", -1); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK); + + hr = ID3DXFont_PreloadTextW(font, NULL, -1); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXFont_PreloadTextW(font, NULL, 0); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadTextW(font, NULL, 1); + ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); + hr = ID3DXFont_PreloadTextW(font, testW, -1); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK); + } + + check_release((IUnknown*)font, 0);
/* ID3DXFont_GetGlyphData, ID3DXFont_PreloadGlyphs, ID3DXFont_PreloadCharacters */ hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); - if(SUCCEEDED(hr)) { - char c; - HDC hdc; + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); + + hdc = ID3DXFont_GetDC(font); + ok(hdc != NULL, "ID3DXFont_GetDC returned an invalid handle\n"); + + todo_wine { + hr = ID3DXFont_GetGlyphData(font, 0, NULL, &blackbox, &cellinc); + ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_GetGlyphData(font, 0, &texture, NULL, &cellinc); + if(SUCCEEDED(hr)) check_release((IUnknown*)texture, 1); + ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_GetGlyphData(font, 0, &texture, &blackbox, NULL); + if(SUCCEEDED(hr)) check_release((IUnknown*)texture, 1); + ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + } + hr = ID3DXFont_PreloadCharacters(font, 'b', 'a'); + ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadGlyphs(font, 1, 0); + todo_wine ok(hr == D3D_OK, "ID3DXFont_PreloadGlyphs returned %#x, expected %#x\n", hr, D3D_OK); + + hr = ID3DXFont_PreloadCharacters(font, 'a', 'a'); + ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK); + + for(c = 'b'; c <= 'z'; c++) { + WORD glyph; DWORD ret; - HRESULT hr; - RECT blackbox; - POINT cellinc; - IDirect3DTexture9 *texture;
- hdc = ID3DXFont_GetDC(font); + ret = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); + ok(ret != GDI_ERROR, "GetGlyphIndicesA failed\n");
- todo_wine { - hr = ID3DXFont_GetGlyphData(font, 0, NULL, &blackbox, &cellinc); - ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); - hr = ID3DXFont_GetGlyphData(font, 0, &texture, NULL, &cellinc); - if(SUCCEEDED(hr)) check_release((IUnknown*)texture, 1); - ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); - hr = ID3DXFont_GetGlyphData(font, 0, &texture, &blackbox, NULL); - if(SUCCEEDED(hr)) check_release((IUnknown*)texture, 1); - ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); - } - hr = ID3DXFont_PreloadCharacters(font, 'b', 'a'); - ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK); - hr = ID3DXFont_PreloadGlyphs(font, 1, 0); - todo_wine ok(hr == D3D_OK, "ID3DXFont_PreloadGlyphs returned %#x, expected %#x\n", hr, D3D_OK); - - hr = ID3DXFont_PreloadCharacters(font, 'a', 'a'); - ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK); - - for(c = 'b'; c <= 'z'; c++) { - WORD glyph; - - ret = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); - ok(ret != GDI_ERROR, "GetGlyphIndicesA failed\n"); - - hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); - todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); - if(SUCCEEDED(hr)) { - DWORD levels; - D3DSURFACE_DESC desc; - - levels = IDirect3DTexture9_GetLevelCount(texture); - ok(levels == 5, "Got levels %u, expected %u\n", levels, 5); - hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc); - ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n"); - ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8); - ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0); - ok(desc.Width == 256, "Got width %u, expected %u\n", desc.Width, 256); - ok(desc.Height == 256, "Got height %u, expected %u\n", desc.Height, 256); - ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED); - - check_release((IUnknown*)texture, 1); - } + hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); + todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + if(SUCCEEDED(hr)) { + DWORD levels; + D3DSURFACE_DESC desc; + + levels = IDirect3DTexture9_GetLevelCount(texture); + ok(levels == 5, "Got levels %u, expected %u\n", levels, 5); + hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc); + ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n"); + ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8); + ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0); + ok(desc.Width == 256, "Got width %u, expected %u\n", desc.Width, 256); + ok(desc.Height == 256, "Got height %u, expected %u\n", desc.Height, 256); + ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED); + + check_release((IUnknown*)texture, 1); } + }
- hr = ID3DXFont_PreloadCharacters(font, 'a', 'z'); - ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadCharacters(font, 'a', 'z'); + ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK);
- check_release((IUnknown*)font, 0); - } else skip("Failed to create a ID3DXFont object\n"); + check_release((IUnknown*)font, 0);
for (i = 0; i < ARRAY_SIZE(tests); ++i) { - HDC hdc; DWORD ret; - HRESULT hr; WORD glyph; char c = 'a'; - IDirect3DTexture9 *texture;
hr = D3DXCreateFontA(device, tests[i].font_height, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); - if(FAILED(hr)) { - skip("Failed to create a ID3DXFont object\n"); - continue; - } + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK);
hdc = ID3DXFont_GetDC(font);
@@ -616,8 +604,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_RIGHT, 0xffffffff); ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); - height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP, - 0xffffffff); + height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP, 0xffffffff); ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); }
From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
Signed-off-by: Sven Baars sbaars@codeweavers.com --- v2: Removed the -2 test for DrawTextW since it crashes on Windows, and was added as a result of random testing (and not an applcation needing it). Also removed the if statement. I also did this for the other tests in the previous patch.
dlls/d3dx9_36/tests/core.c | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+)
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index 537109c59d..ed4e0cbba8 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -624,6 +624,62 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
ID3DXFont_Release(font); } + + + /* ID3DXFont_DrawTextA, ID3DXFont_DrawTextW */ + hr = D3DXCreateFontA(device, 12, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); + ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); + + todo_wine { + SetRect(&rect, 10, 10, 200, 200); + + height = ID3DXFont_DrawTextA(font, NULL, "test", -2, &rect, 0, 0xFF00FF); + ok(height == 12, "DrawTextA returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextA(font, NULL, "test", -1, &rect, 0, 0xFF00FF); + ok(height == 12, "DrawTextA returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextA(font, NULL, "test", 0, &rect, 0, 0xFF00FF); + ok(height == 0, "DrawTextA returned %d, expected 0.\n", height); + + height = ID3DXFont_DrawTextA(font, NULL, "test", 1, &rect, 0, 0xFF00FF); + ok(height == 12, "DrawTextA returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextA(font, NULL, "test", 2, &rect, 0, 0xFF00FF); + ok(height == 12, "DrawTextA returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextA(font, NULL, "test", -1, NULL, 0, 0xFF00FF); + ok(height == 12, "DrawTextA returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextA(font, NULL, "test", -1, NULL, DT_CALCRECT, 0xFF00FF); + ok(height == 12, "DrawTextA returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextA(font, NULL, NULL, -1, NULL, 0, 0xFF00FF); + ok(height == 0, "DrawTextA returned %d, expected 0.\n", height); + + height = ID3DXFont_DrawTextW(font, NULL, testW, -1, &rect, 0, 0xFF00FF); + ok(height == 12, "DrawTextW returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextW(font, NULL, testW, 0, &rect, 0, 0xFF00FF); + ok(height == 0, "DrawTextW returned %d, expected 0.\n", height); + + height = ID3DXFont_DrawTextW(font, NULL, testW, 1, &rect, 0, 0xFF00FF); + ok(height == 12, "DrawTextW returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 0xFF00FF); + ok(height == 12, "DrawTextW returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, 0, 0xFF00FF); + ok(height == 12, "DrawTextW returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, DT_CALCRECT, 0xFF00FF); + ok(height == 12, "DrawTextW returned %d, expected 12.\n", height); + + height = ID3DXFont_DrawTextW(font, NULL, NULL, -1, NULL, 0, 0xFF00FF); + ok(height == 0, "DrawTextW returned %d, expected 0.\n", height); + } + + ID3DXFont_Release(font); }
static void test_D3DXCreateRenderToSurface(IDirect3DDevice9 *device)
Signed-off-by: Sven Baars sbaars@codeweavers.com --- v2: - Use wide-char string literals. - Removed todo_wine that are only needed later. - Use text indices. - Add a more correct test for the blackbox.
dlls/d3dx9_36/tests/core.c | 151 +++++++++++++++++++++++++++---------- 1 file changed, 113 insertions(+), 38 deletions(-)
diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index ed4e0cbba8..a818504bae 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -305,7 +305,10 @@ static void test_ID3DXSprite(IDirect3DDevice9 *device)
static void test_ID3DXFont(IDirect3DDevice9 *device) { - static const WCHAR testW[] = {'t','e','s','t',0}; + static const WCHAR testW[] = L"test"; + static const char longText[] = "Example text to test clipping and other related things"; + static const WCHAR longTextW[] = L"Example text to test clipping and other related things"; + static const struct { int font_height; @@ -314,11 +317,14 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) } tests[] = { - { 6, 128, 4 }, - { 8, 128, 4 }, - { 10, 256, 5 }, - { 12, 256, 5 }, - { 72, 256, 8 }, + { 2, 32, 2 }, + { 6, 128, 4 }, + { 10, 256, 5 }, + { 12, 256, 5 }, + { 72, 256, 8 }, + { 250, 256, 9 }, + { 258, 512, 10 }, + { 512, 512, 10 }, }; const unsigned int size = ARRAY_SIZE(testW); IDirect3DTexture9 *texture; @@ -331,6 +337,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) HRESULT hr; POINT cellinc; RECT rect, blackbox; + WORD glyph; BOOL ret; HDC hdc; char c; @@ -478,6 +485,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); hr = ID3DXFont_PreloadTextA(font, "test", -1); ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadTextA(font, "", 0); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadTextA(font, "", -1); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextA returned %#x, expected %#x\n", hr, D3D_OK);
hr = ID3DXFont_PreloadTextW(font, NULL, -1); ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); @@ -487,6 +498,10 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(hr == D3DERR_INVALIDCALL, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3DERR_INVALIDCALL); hr = ID3DXFont_PreloadTextW(font, testW, -1); ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadTextW(font, L"", 0); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK); + hr = ID3DXFont_PreloadTextW(font, L"", -1); + ok(hr == D3D_OK, "ID3DXFont_PreloadTextW returned %#x, expected %#x\n", hr, D3D_OK); }
check_release((IUnknown*)font, 0); @@ -518,7 +533,6 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK);
for(c = 'b'; c <= 'z'; c++) { - WORD glyph; DWORD ret;
ret = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); @@ -528,17 +542,34 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); if(SUCCEEDED(hr)) { DWORD levels; + TEXTMETRICW tm; D3DSURFACE_DESC desc; + GLYPHMETRICS metrics; + MAT2 mat = { {0,1}, {0,0}, {0,0}, {0,1} };
levels = IDirect3DTexture9_GetLevelCount(texture); - ok(levels == 5, "Got levels %u, expected %u\n", levels, 5); + ok(levels == 5, "Character %c, got levels %u, expected %u\n", c, levels, 5); + hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc); ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n"); - ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8); - ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0); - ok(desc.Width == 256, "Got width %u, expected %u\n", desc.Width, 256); - ok(desc.Height == 256, "Got height %u, expected %u\n", desc.Height, 256); - ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED); + ok(desc.Format == D3DFMT_A8R8G8B8, "Character %c, got format %#x, expected %#x\n", c, desc.Format, D3DFMT_A8R8G8B8); + ok(desc.Usage == 0, "Character %c, got usage %#x, expected %#x\n", c, desc.Usage, 0); + ok(desc.Width == 256, "Character %c, got width %u, expected %u\n", c, desc.Width, 256); + ok(desc.Height == 256, "Character %c, got height %u, expected %u\n", c, desc.Height, 256); + ok(desc.Pool == D3DPOOL_MANAGED, "Character %c, got pool %u, expected %u\n", c, desc.Pool, D3DPOOL_MANAGED); + + ret = GetGlyphOutlineW(hdc, glyph, GGO_GLYPH_INDEX | GGO_METRICS, &metrics, 0, NULL, &mat); + ok(ret != GDI_ERROR, "GetGlyphOutlineW failed\n"); + + ID3DXFont_GetTextMetricsW(font, &tm); + ok(blackbox.right - blackbox.left == metrics.gmBlackBoxX + 2, "Character %c, got %d, expected %d\n", + c, blackbox.right - blackbox.left, metrics.gmBlackBoxX + 2); + ok(blackbox.bottom - blackbox.top == metrics.gmBlackBoxY + 2, "Character %c, got %d, expected %d\n", + c, blackbox.bottom - blackbox.top, metrics.gmBlackBoxY + 2); + ok(cellinc.x == metrics.gmptGlyphOrigin.x - 1, "Character %c, got %d, expected %d\n", + c, cellinc.x, metrics.gmptGlyphOrigin.x - 1); + ok(cellinc.y == tm.tmAscent - metrics.gmptGlyphOrigin.y - 1, "Character %c, got %d, expected %d\n", + c, cellinc.y, tm.tmAscent - metrics.gmptGlyphOrigin.y - 1);
check_release((IUnknown*)texture, 1); } @@ -547,41 +578,55 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) hr = ID3DXFont_PreloadCharacters(font, 'a', 'z'); ok(hr == D3D_OK, "ID3DXFont_PreloadCharacters returned %#x, expected %#x\n", hr, D3D_OK);
+ /* Test multiple textures */ + hr = ID3DXFont_PreloadGlyphs(font, 0, 1000); + todo_wine ok(hr == D3D_OK, "ID3DXFont_PreloadGlyphs returned %#x, expected %#x\n", hr, D3D_OK); + + /* Test glyphs that are not rendered */ + for (glyph = 1; glyph < 4; glyph++) + { + texture = (IDirect3DTexture9*)0xdeadbeef; + hr = ID3DXFont_GetGlyphData(font, glyph, &texture, &blackbox, &cellinc); + todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + todo_wine ok(!texture, "Got unexpected texture\n"); + } + check_release((IUnknown*)font, 0);
for (i = 0; i < ARRAY_SIZE(tests); ++i) { DWORD ret; - WORD glyph; char c = 'a';
hr = D3DXCreateFontA(device, tests[i].font_height, 0, FW_DONTCARE, 0, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, "Tahoma", &font); - ok(hr == D3D_OK, "D3DXCreateFont returned %#x, expected %#x\n", hr, D3D_OK); + ok(hr == D3D_OK, "Test %d, D3DXCreateFont returned %#x, expected %#x\n", i, hr, D3D_OK);
hdc = ID3DXFont_GetDC(font);
ret = GetGlyphIndicesA(hdc, &c, 1, &glyph, 0); - ok(ret != GDI_ERROR, "GetGlyphIndicesA failed\n"); + ok(ret != GDI_ERROR, "Test %d, GetGlyphIndicesA failed\n", i);
hr = ID3DXFont_GetGlyphData(font, glyph, &texture, NULL, NULL); - todo_wine ok(hr == D3D_OK, "ID3DXFont_GetGlyphData returned %#x, expected %#x\n", hr, D3D_OK); + todo_wine ok(hr == D3D_OK, "Test %d, ID3DXFont_GetGlyphData returned %#x, expected %#x\n", i, hr, D3D_OK); if(SUCCEEDED(hr)) { DWORD levels; D3DSURFACE_DESC desc;
levels = IDirect3DTexture9_GetLevelCount(texture); - ok(levels == tests[i].expected_levels, "Got levels %u, expected %u\n", - levels, tests[i].expected_levels); + ok(levels == tests[i].expected_levels, "Test %d, got levels %u, expected %u\n", + i, levels, tests[i].expected_levels); hr = IDirect3DTexture9_GetLevelDesc(texture, 0, &desc); - ok(hr == D3D_OK, "IDirect3DTexture9_GetLevelDesc failed\n"); - ok(desc.Format == D3DFMT_A8R8G8B8, "Got format %#x, expected %#x\n", desc.Format, D3DFMT_A8R8G8B8); - ok(desc.Usage == 0, "Got usage %#x, expected %#x\n", desc.Usage, 0); - ok(desc.Width == tests[i].expected_size, "Got width %u, expected %u\n", - desc.Width, tests[i].expected_size); - ok(desc.Height == tests[i].expected_size, "Got height %u, expected %u\n", - desc.Height, tests[i].expected_size); - ok(desc.Pool == D3DPOOL_MANAGED, "Got pool %u, expected %u\n", desc.Pool, D3DPOOL_MANAGED); + ok(hr == D3D_OK, "Test %d, IDirect3DTexture9_GetLevelDesc failed\n", i); + ok(desc.Format == D3DFMT_A8R8G8B8, "Test %d, got format %#x, expected %#x\n", + i, desc.Format, D3DFMT_A8R8G8B8); + ok(desc.Usage == 0, "Test %d, got usage %#x, expected %#x\n", i, desc.Usage, 0); + ok(desc.Width == tests[i].expected_size, "Test %d, got width %u, expected %u\n", + i, desc.Width, tests[i].expected_size); + ok(desc.Height == tests[i].expected_size, "Test %d, got height %u, expected %u\n", + i, desc.Height, tests[i].expected_size); + ok(desc.Pool == D3DPOOL_MANAGED, "Test %d, got pool %u, expected %u\n", + i, desc.Pool, D3DPOOL_MANAGED);
IDirect3DTexture9_Release(texture); } @@ -594,31 +639,31 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
IDirect3DDevice9_BeginScene(device); hr = ID3DXSprite_Begin(sprite, D3DXSPRITE_ALPHABLEND); - ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok (hr == D3D_OK, "Test %d, got unexpected hr %#x.\n", i, hr);
todo_wine { height = ID3DXFont_DrawTextW(font, sprite, testW, -1, &rect, DT_TOP, 0xffffffff); - ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); + ok(height == tests[i].font_height, "Test %d, got unexpected height %u.\n", i, height); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_TOP, 0xffffffff); - ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); + ok(height == tests[i].font_height, "Test %d, got unexpected height %u.\n", i, height); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_RIGHT, 0xffffffff); - ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); + ok(height == tests[i].font_height, "Test %d, got unexpected height %u.\n", i, height); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_NOCLIP, 0xffffffff); - ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); + ok(height == tests[i].font_height, "Test %d, got unexpected height %u.\n", i, height); }
SetRectEmpty(&rect); height = ID3DXFont_DrawTextW(font, sprite, testW, size, &rect, DT_LEFT | DT_CALCRECT, 0xffffffff); - todo_wine ok(height == tests[i].font_height, "Got unexpected height %u.\n", height); - ok(!rect.left, "Got unexpected rect left %d.\n", rect.left); - ok(!rect.top, "Got unexpected rect top %d.\n", rect.top); - todo_wine ok(rect.right, "Got unexpected rect right %d.\n", rect.right); - todo_wine ok(rect.bottom == tests[i].font_height, "Got unexpected rect bottom %d.\n", rect.bottom); + todo_wine ok(height == tests[i].font_height, "Test %d, got unexpected height %u.\n", i, height); + ok(!rect.left, "Test %d, got unexpected rect left %d.\n", i, rect.left); + ok(!rect.top, "Test %d, got unexpected rect top %d.\n", i, rect.top); + todo_wine ok(rect.right, "Test %d, got unexpected rect right %d.\n", i, rect.right); + todo_wine ok(rect.bottom == tests[i].font_height, "Test %d, got unexpected rect bottom %d.\n", i, rect.bottom);
hr = ID3DXSprite_End(sprite); - ok (hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + ok (hr == D3D_OK, "Test %d, got unexpected hr %#x.\n", i, hr); IDirect3DDevice9_EndScene(device); ID3DXSprite_Release(sprite);
@@ -648,6 +693,12 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) height = ID3DXFont_DrawTextA(font, NULL, "test", 2, &rect, 0, 0xFF00FF); ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
+ height = ID3DXFont_DrawTextA(font, NULL, "", 0, &rect, 0, 0xFF00FF); + ok(height == 0, "DrawTextA returned %d, expected 0.\n", height); + + height = ID3DXFont_DrawTextA(font, NULL, "", -1, &rect, 0, 0xFF00FF); + ok(height == 0, "DrawTextA returned %d, expected 0.\n", height); + height = ID3DXFont_DrawTextA(font, NULL, "test", -1, NULL, 0, 0xFF00FF); ok(height == 12, "DrawTextA returned %d, expected 12.\n", height);
@@ -657,6 +708,16 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) height = ID3DXFont_DrawTextA(font, NULL, NULL, -1, NULL, 0, 0xFF00FF); ok(height == 0, "DrawTextA returned %d, expected 0.\n", height);
+ SetRect(&rect, 10, 10, 50, 50); + + height = ID3DXFont_DrawTextA(font, NULL, longText, -1, &rect, DT_WORDBREAK, 0xFF00FF); + ok(height == 60, "DrawTextA returned %d, expected 60.\n", height); + + height = ID3DXFont_DrawTextA(font, NULL, longText, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xFF00FF); + ok(height == 96, "DrawTextA returned %d, expected 96.\n", height); + + SetRect(&rect, 10, 10, 200, 200); + height = ID3DXFont_DrawTextW(font, NULL, testW, -1, &rect, 0, 0xFF00FF); ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
@@ -669,6 +730,12 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) height = ID3DXFont_DrawTextW(font, NULL, testW, 2, &rect, 0, 0xFF00FF); ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
+ height = ID3DXFont_DrawTextW(font, NULL, L"", 0, &rect, 0, 0xFF00FF); + ok(height == 0, "DrawTextW returned %d, expected 0.\n", height); + + height = ID3DXFont_DrawTextW(font, NULL, L"", -1, &rect, 0, 0xFF00FF); + ok(height == 0, "DrawTextW returned %d, expected 0.\n", height); + height = ID3DXFont_DrawTextW(font, NULL, testW, -1, NULL, 0, 0xFF00FF); ok(height == 12, "DrawTextW returned %d, expected 12.\n", height);
@@ -677,6 +744,14 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
height = ID3DXFont_DrawTextW(font, NULL, NULL, -1, NULL, 0, 0xFF00FF); ok(height == 0, "DrawTextW returned %d, expected 0.\n", height); + + SetRect(&rect, 10, 10, 50, 50); + + height = ID3DXFont_DrawTextW(font, NULL, longTextW, -1, &rect, DT_WORDBREAK, 0xFF00FF); + ok(height == 60, "DrawTextW returned %d, expected 60.\n", height); + + height = ID3DXFont_DrawTextW(font, NULL, longTextW, -1, &rect, DT_WORDBREAK | DT_NOCLIP, 0xFF00FF); + ok(height == 96, "DrawTextW returned %d, expected 96.\n", height); }
ID3DXFont_Release(font);
Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index cb09af22f5..fe4fd27d5d 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -59,85 +59,85 @@ static HRESULT WINAPI ID3DXFontImpl_QueryInterface(ID3DXFont *iface, REFIID riid
static ULONG WINAPI ID3DXFontImpl_AddRef(ID3DXFont *iface) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref=InterlockedIncrement(&This->ref); + struct d3dx_font *font = impl_from_ID3DXFont(iface); + ULONG ref = InterlockedIncrement(&font->ref); TRACE("%p increasing refcount to %u\n", iface, ref); return ref; }
static ULONG WINAPI ID3DXFontImpl_Release(ID3DXFont *iface) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); - ULONG ref=InterlockedDecrement(&This->ref); + struct d3dx_font *font = impl_from_ID3DXFont(iface); + ULONG ref = InterlockedDecrement(&font->ref);
TRACE("%p decreasing refcount to %u\n", iface, ref);
if(ref==0) { - DeleteObject(This->hfont); - DeleteDC(This->hdc); - IDirect3DDevice9_Release(This->device); - HeapFree(GetProcessHeap(), 0, This); + DeleteObject(font->hfont); + DeleteDC(font->hdc); + IDirect3DDevice9_Release(font->device); + HeapFree(GetProcessHeap(), 0, font); } return ref; }
static HRESULT WINAPI ID3DXFontImpl_GetDevice(ID3DXFont *iface, IDirect3DDevice9 **device) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface);
TRACE("iface %p, device %p\n", iface, device);
if( !device ) return D3DERR_INVALIDCALL; - *device = This->device; - IDirect3DDevice9_AddRef(This->device); + *device = font->device; + IDirect3DDevice9_AddRef(font->device);
return D3D_OK; }
static HRESULT WINAPI ID3DXFontImpl_GetDescA(ID3DXFont *iface, D3DXFONT_DESCA *desc) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface);
TRACE("iface %p, desc %p\n", iface, desc);
if( !desc ) return D3DERR_INVALIDCALL; - memcpy(desc, &This->desc, FIELD_OFFSET(D3DXFONT_DESCA, FaceName)); - WideCharToMultiByte(CP_ACP, 0, This->desc.FaceName, -1, desc->FaceName, ARRAY_SIZE(desc->FaceName), NULL, NULL); + memcpy(desc, &font->desc, FIELD_OFFSET(D3DXFONT_DESCA, FaceName)); + WideCharToMultiByte(CP_ACP, 0, font->desc.FaceName, -1, desc->FaceName, ARRAY_SIZE(desc->FaceName), NULL, NULL);
return D3D_OK; }
static HRESULT WINAPI ID3DXFontImpl_GetDescW(ID3DXFont *iface, D3DXFONT_DESCW *desc) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface);
TRACE("iface %p, desc %p\n", iface, desc);
if( !desc ) return D3DERR_INVALIDCALL; - *desc = This->desc; + *desc = font->desc;
return D3D_OK; }
static BOOL WINAPI ID3DXFontImpl_GetTextMetricsA(ID3DXFont *iface, TEXTMETRICA *metrics) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface); TRACE("iface %p, metrics %p\n", iface, metrics); - return GetTextMetricsA(This->hdc, metrics); + return GetTextMetricsA(font->hdc, metrics); }
static BOOL WINAPI ID3DXFontImpl_GetTextMetricsW(ID3DXFont *iface, TEXTMETRICW *metrics) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface); TRACE("iface %p, metrics %p\n", iface, metrics); - return GetTextMetricsW(This->hdc, metrics); + return GetTextMetricsW(font->hdc, metrics); }
static HDC WINAPI ID3DXFontImpl_GetDC(ID3DXFont *iface) { - struct d3dx_font *This = impl_from_ID3DXFont(iface); + struct d3dx_font *font = impl_from_ID3DXFont(iface); TRACE("iface %p\n", iface); - return This->hdc; + return font->hdc; }
static HRESULT WINAPI ID3DXFontImpl_GetGlyphData(ID3DXFont *iface, UINT glyph,
I'd prefer making these changes along the way while touching the various functions vs all together in a separate patch.