Commit 333687f5 authored by Sven Baars's avatar Sven Baars Committed by Alexandre Julliard

d3dx9: Handle DT_SINGLELINE in ID3DXFont_DrawText.

parent 756ed811
...@@ -512,7 +512,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite, ...@@ -512,7 +512,7 @@ static INT WINAPI ID3DXFontImpl_DrawTextA(ID3DXFont *iface, ID3DXSprite *sprite,
} }
static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len, static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len,
unsigned int chars_fit, unsigned int *chars_used, SIZE *size) unsigned int chars_fit, unsigned int *chars_used, DWORD format, SIZE *size)
{ {
SCRIPT_LOGATTR *sla; SCRIPT_LOGATTR *sla;
SCRIPT_ANALYSIS sa; SCRIPT_ANALYSIS sa;
...@@ -535,7 +535,7 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len, ...@@ -535,7 +535,7 @@ static void word_break(HDC hdc, const WCHAR *str, unsigned int *str_len,
--i; --i;
/* If the there is no word that fits put in all characters that do fit */ /* If the there is no word that fits put in all characters that do fit */
if (!sla[i].fSoftBreak) if (!sla[i].fSoftBreak || (format & DT_SINGLELINE))
i = chars_fit; i = chars_fit;
*chars_used = i; *chars_used = i;
...@@ -561,10 +561,10 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, ...@@ -561,10 +561,10 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count,
SIZE size; SIZE size;
*dest_len = 0; *dest_len = 0;
while (*count && str[i] != '\n') while (*count && (str[i] != '\n' || (format & DT_SINGLELINE)))
{ {
--(*count); --(*count);
if (str[i] != '\r') if (str[i] != '\r' && str[i] != '\n')
dest[(*dest_len)++] = str[i]; dest[(*dest_len)++] = str[i];
++i; ++i;
} }
...@@ -572,13 +572,21 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count, ...@@ -572,13 +572,21 @@ static const WCHAR *read_line(HDC hdc, const WCHAR *str, int *count,
num_fit = 0; num_fit = 0;
GetTextExtentExPointW(hdc, dest, *dest_len, width, &num_fit, NULL, &size); GetTextExtentExPointW(hdc, dest, *dest_len, width, &num_fit, NULL, &size);
if (num_fit < *dest_len && (format & DT_WORDBREAK)) if (num_fit < *dest_len)
{ {
unsigned int chars_used; if (format & DT_WORDBREAK)
{
unsigned int chars_used;
word_break(hdc, dest, dest_len, num_fit, &chars_used, &size); word_break(hdc, dest, dest_len, num_fit, &chars_used, format, &size);
*count = orig_count - chars_used; *count = orig_count - chars_used;
i = chars_used; i = chars_used;
}
else if (format & DT_SINGLELINE)
{
*dest_len = num_fit;
*count = 0;
}
} }
if (*count && str[i] == '\n') if (*count && str[i] == '\n')
...@@ -617,6 +625,9 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite, ...@@ -617,6 +625,9 @@ static INT WINAPI ID3DXFontImpl_DrawTextW(ID3DXFont *iface, ID3DXSprite *sprite,
if (format & DT_CALCRECT) if (format & DT_CALCRECT)
format |= DT_NOCLIP; format |= DT_NOCLIP;
if (format & DT_SINGLELINE)
format &= ~DT_WORDBREAK;
if (!rect) if (!rect)
{ {
y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format | DT_CALCRECT, 0); y = ID3DXFont_DrawTextW(iface, NULL, string, count, &textrect, format | DT_CALCRECT, 0);
......
...@@ -771,7 +771,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device) ...@@ -771,7 +771,7 @@ static void test_ID3DXFont(IDirect3DDevice9 *device)
ok(height == 12, "Got unexpected height %d.\n", height); ok(height == 12, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, DT_SINGLELINE, 0xff00ff); height = ID3DXFont_DrawTextW(font, NULL, L"a\na", -1, &rect, DT_SINGLELINE, 0xff00ff);
todo_wine ok(height == 12, "Got unexpected height %d.\n", height); ok(height == 12, "Got unexpected height %d.\n", height);
height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, 0xff00ff); height = ID3DXFont_DrawTextW(font, NULL, L"a\naaaaa aaaa", -1, &rect, 0, 0xff00ff);
ok(height == 24, "Got unexpected height %d.\n", height); ok(height == 24, "Got unexpected height %d.\n", height);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment