Commit 8201fa14 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

dwrite: Fix alignment shifts in RTL case.

parent 6d52bc59
......@@ -1137,6 +1137,7 @@ static FLOAT layout_get_line_width(struct dwrite_textlayout *layout,
static void layout_apply_leading_alignment(struct dwrite_textlayout *layout)
{
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
struct layout_effective_inline *inrun;
struct layout_effective_run *erun;
......@@ -1153,11 +1154,12 @@ static void layout_apply_leading_alignment(struct dwrite_textlayout *layout)
inrun = layout_get_next_inline_run(layout, inrun);
}
layout->metrics.left = 0;
layout->metrics.left = is_rtl ? layout->metrics.layoutWidth - layout->metrics.width : 0.0;
}
static void layout_apply_trailing_alignment(struct dwrite_textlayout *layout)
{
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
struct layout_effective_inline *inrun;
struct layout_effective_run *erun;
UINT32 line;
......@@ -1169,6 +1171,9 @@ static void layout_apply_trailing_alignment(struct dwrite_textlayout *layout)
FLOAT width = layout_get_line_width(layout, erun, inrun, line);
FLOAT shift = layout->metrics.layoutWidth - width;
if (is_rtl)
shift *= -1.0;
while (erun && erun->line == line) {
erun->align_dx = shift;
erun = layout_get_next_erun(layout, erun);
......@@ -1180,11 +1185,12 @@ static void layout_apply_trailing_alignment(struct dwrite_textlayout *layout)
}
}
layout->metrics.left = layout->metrics.layoutWidth - layout->metrics.width;
layout->metrics.left = is_rtl ? 0.0 : layout->metrics.layoutWidth - layout->metrics.width;
}
static void layout_apply_centered_alignment(struct dwrite_textlayout *layout)
{
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
struct layout_effective_inline *inrun;
struct layout_effective_run *erun;
UINT32 line;
......@@ -1196,6 +1202,9 @@ static void layout_apply_centered_alignment(struct dwrite_textlayout *layout)
FLOAT width = layout_get_line_width(layout, erun, inrun, line);
FLOAT shift = (layout->metrics.layoutWidth - width) / 2.0;
if (is_rtl)
shift *= -1.0;
while (erun && erun->line == line) {
erun->align_dx = shift;
erun = layout_get_next_erun(layout, erun);
......@@ -1277,6 +1286,7 @@ static void layout_apply_par_alignment(struct dwrite_textlayout *layout)
static HRESULT layout_compute_effective_runs(struct dwrite_textlayout *layout)
{
BOOL is_rtl = layout->format.readingdir == DWRITE_READING_DIRECTION_RIGHT_TO_LEFT;
struct layout_effective_inline *inrun;
struct layout_effective_run *erun;
const struct layout_run *run;
......@@ -1411,7 +1421,8 @@ static HRESULT layout_compute_effective_runs(struct dwrite_textlayout *layout)
textpos += layout->clustermetrics[i].length;
}
layout->metrics.left = layout->metrics.top = 0.0;
layout->metrics.left = is_rtl ? layout->metrics.layoutWidth - layout->metrics.width : 0;
layout->metrics.top = 0.0;
layout->metrics.maxBidiReorderingDepth = 1; /* FIXME */
layout->metrics.height = 0.0;
......
......@@ -3168,7 +3168,6 @@ static void test_SetReadingDirection(void)
hr = IDWriteTextLayout_GetMetrics(layout, &metrics);
ok(hr == S_OK, "got 0x%08x\n", hr);
todo_wine
ok(metrics.left == metrics.layoutWidth - clusters[0].width, "got %.2f\n", metrics.left);
ok(metrics.top == 0.0, "got %.2f\n", metrics.top);
ok(metrics.width == clusters[0].width, "got %.2f\n", metrics.width);
......@@ -3184,7 +3183,6 @@ todo_wine
hr = IDWriteTextLayout_GetMetrics(layout, &metrics);
ok(hr == S_OK, "got 0x%08x\n", hr);
todo_wine
ok(metrics.left == 0.0, "got %.2f\n", metrics.left);
ok(metrics.top == 0.0, "got %.2f\n", metrics.top);
ok(metrics.width == clusters[0].width, "got %.2f\n", metrics.width);
......
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