Signed-off-by: Sven Baars sbaars@codeweavers.com --- dlls/d3dx9_36/font.c | 22 +++++++++++++++++++++- dlls/d3dx9_36/tests/core.c | 15 +++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/dlls/d3dx9_36/font.c b/dlls/d3dx9_36/font.c index bd81a7044b..550ff2c0fe 100644 --- a/dlls/d3dx9_36/font.c +++ b/dlls/d3dx9_36/font.c @@ -687,6 +687,13 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, D3DXVECTOR3 pos; unsigned int i;
+ if (format & DT_CENTER) + x = (calcrect.left + calcrect.right - size.cx) / 2; + else if (format & DT_RIGHT) + x = calcrect.right - size.cx; + else + x = calcrect.left; + memset(&results, 0, sizeof(results)); results.nGlyphs = line_len;
@@ -739,7 +746,20 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, *rect = calcrect;
rect->bottom = y; - rect->right = rect->left + max_width; + + if (format & DT_CENTER) + { + rect->left += (rect->right - rect->left - max_width) / 2; + rect->right = rect->left + max_width; + } + else if (format & DT_RIGHT) + { + rect->left = rect->right - max_width; + } + else + { + rect->right = rect->left + max_width; + } }
ret = y - textrect.top; diff --git a/dlls/d3dx9_36/tests/core.c b/dlls/d3dx9_36/tests/core.c index 7800e6036c..c2244b1a97 100644 --- a/dlls/d3dx9_36/tests/core.c +++ b/dlls/d3dx9_36/tests/core.c @@ -863,6 +863,21 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ok(height == 32, "Got unexpected height %d.\n", height); check_rect(&rect, 10, 18, 30, 42);
+ SetRect(&rect, 10, 10, 50, 50); + height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_RIGHT | DT_CALCRECT, 0xff00ff); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 30, 10, 50, 34); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_CALCRECT, 0xff00ff); + ok(height == 24, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 10, 40, 34); + + SetRect(&rect, 10, 10, 50, 50); + height = ID3DXFont_DrawTextW(font, NULL, L"aaaa\naaaa", -1, &rect, DT_CENTER | DT_VCENTER | DT_CALCRECT, 0xff00ff); + ok(height == 32, "Got unexpected height %d.\n", height); + check_rect(&rect, 20, 18, 40, 42); + ID3DXFont_Release(font); }