From 849b5dd96d8efd0eb1520072bf32428fd8479a6e Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 23 Feb 2017 16:39:25 +0300 Subject: [PATCH] dwrite: Set runHeight attribute for underlines. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/dwrite/layout.c | 10 ++++++---- dlls/dwrite/tests/layout.c | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/dwrite/layout.c b/dlls/dwrite/layout.c index f850c95be85..a7fff463661 100644 --- a/dlls/dwrite/layout.c +++ b/dlls/dwrite/layout.c @@ -1,7 +1,7 @@ /* * Text format and layout * - * Copyright 2012, 2014-2016 Nikolay Sivov for CodeWeavers + * Copyright 2012, 2014-2017 Nikolay Sivov for CodeWeavers * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1662,27 +1662,29 @@ static BOOL is_same_u_splitting(struct layout_underline_splitting_params *left, static HRESULT layout_add_underline(struct dwrite_textlayout *layout, struct layout_effective_run *first, struct layout_effective_run *last) { + FLOAT thickness, offset, runheight; struct layout_effective_run *cur; DWRITE_FONT_METRICS metrics; - FLOAT thickness, offset; if (first == layout_get_prev_erun(layout, last)) { layout_get_erun_font_metrics(layout, first, &metrics); thickness = SCALE_FONT_METRIC(metrics.underlineThickness, first->run->u.regular.run.fontEmSize, &metrics); offset = SCALE_FONT_METRIC(metrics.underlinePosition, first->run->u.regular.run.fontEmSize, &metrics); + runheight = SCALE_FONT_METRIC(metrics.capHeight, first->run->u.regular.run.fontEmSize, &metrics); } else { FLOAT width = 0.0f; /* Single underline is added for consecutive underlined runs. In this case underline parameters are calculated as weighted average, where run width acts as a weight. */ - thickness = offset = 0.0f; + thickness = offset = runheight = 0.0f; cur = first; do { layout_get_erun_font_metrics(layout, cur, &metrics); thickness += SCALE_FONT_METRIC(metrics.underlineThickness, cur->run->u.regular.run.fontEmSize, &metrics) * cur->width; offset += SCALE_FONT_METRIC(metrics.underlinePosition, cur->run->u.regular.run.fontEmSize, &metrics) * cur->width; + runheight = max(SCALE_FONT_METRIC(metrics.capHeight, cur->run->u.regular.run.fontEmSize, &metrics), runheight); width += cur->width; cur = layout_get_next_erun(layout, cur); @@ -1721,7 +1723,7 @@ static HRESULT layout_add_underline(struct dwrite_textlayout *layout, struct lay /* Font metrics convention is to have it negative when below baseline, for rendering however Y grows from baseline down for horizontal baseline. */ u->u.offset = -offset; - u->u.runHeight = 0.0f; /* FIXME */ + u->u.runHeight = runheight; u->u.readingDirection = is_run_rtl(cur) ? DWRITE_READING_DIRECTION_RIGHT_TO_LEFT : DWRITE_READING_DIRECTION_LEFT_TO_RIGHT; u->u.flowDirection = layout->format.flow; diff --git a/dlls/dwrite/tests/layout.c b/dlls/dwrite/tests/layout.c index 868a465e9be..0d737169c3c 100644 --- a/dlls/dwrite/tests/layout.c +++ b/dlls/dwrite/tests/layout.c @@ -596,7 +596,6 @@ static HRESULT WINAPI testrenderer_DrawUnderline(IDWriteTextRenderer *iface, if (ctxt) TEST_MEASURING_MODE(ctxt, underline->measuringMode); -todo_wine ok(underline->runHeight > 0.0f, "Expected non-zero run height\n"); if (ctxt && ctxt->format) { DWRITE_FONT_METRICS metrics; @@ -609,7 +608,6 @@ todo_wine ok(emsize == metrics.designUnitsPerEm, "Unexpected font size %f\n", emsize); /* Expected height is in design units, allow some absolute difference from it. Seems to only happen on Vista */ - todo_wine ok(abs(metrics.capHeight - underline->runHeight) < 2.0f, "Expected runHeight %u, got %f\n", metrics.capHeight, underline->runHeight);