[PATCH 2/4] dwrite/tests: Some tests for bounds returned by GetAlphaTextureBounds()
Nikolay Sivov
nsivov at codeweavers.com
Mon Jul 20 07:14:32 CDT 2015
---
-------------- next part --------------
>From 0a0fe973cf1d0c11aed7eb6321616aeeefaf3420 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun, 19 Jul 2015 02:29:01 +0300
Subject: [PATCH 2/5] dwrite/tests: Some tests for bounds returned by
GetAlphaTextureBounds()
---
dlls/dwrite/tests/font.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 94dccdd..c85193a 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -3403,6 +3403,7 @@ static void test_CreateGlyphRunAnalysis(void)
RECT rect;
DWRITE_GLYPH_OFFSET offset;
DWRITE_GLYPH_METRICS metrics;
+ DWRITE_FONT_METRICS fm;
int i;
factory = create_factory();
@@ -3492,6 +3493,41 @@ static void test_CreateGlyphRunAnalysis(void)
IDWriteGlyphRunAnalysis_Release(analysis);
}
+ IDWriteFontFace_GetMetrics(run.fontFace, &fm);
+
+ /* check bbox for a single glyph run */
+ for (run.fontEmSize = 1.0; run.fontEmSize <= 100.0; run.fontEmSize += 1.0) {
+ DWRITE_GLYPH_METRICS gm;
+ LONG bboxX, bboxY;
+
+ hr = IDWriteFactory_CreateGlyphRunAnalysis(factory, &run, 1.0, NULL,
+ DWRITE_RENDERING_MODE_ALIASED, DWRITE_MEASURING_MODE_GDI_CLASSIC,
+ 0.0, 0.0, &analysis);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ memset(&rect, 0, sizeof(rect));
+ hr = IDWriteGlyphRunAnalysis_GetAlphaTextureBounds(analysis, DWRITE_TEXTURE_ALIASED_1x1, &rect);
+ todo_wine
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ if (hr != S_OK)
+ break;
+
+ hr = IDWriteFontFace_GetGdiCompatibleGlyphMetrics(run.fontFace, run.fontEmSize, 1.0, NULL,
+ DWRITE_MEASURING_MODE_GDI_CLASSIC, run.glyphIndices, 1, &gm, run.isSideways);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ /* metrics are in design units */
+ bboxX = (int)floorf((gm.advanceWidth - gm.leftSideBearing - gm.rightSideBearing) * run.fontEmSize / fm.designUnitsPerEm + 0.5f);
+ bboxY = (int)floorf((gm.advanceHeight - gm.topSideBearing - gm.bottomSideBearing) * run.fontEmSize / fm.designUnitsPerEm + 0.5f);
+
+ rect.right -= rect.left;
+ rect.bottom -= rect.top;
+ ok(abs(bboxX - rect.right) <= 1, "%.0f: bbox width %d, from metrics %d\n", run.fontEmSize, rect.right, bboxX);
+ ok(abs(bboxY - rect.bottom) <= 1, "%.0f: bbox height %d, from metrics %d\n", run.fontEmSize, rect.bottom, bboxY);
+
+ IDWriteGlyphRunAnalysis_Release(analysis);
+ }
+
IDWriteFontFace_Release(face);
IDWriteFactory_Release(factory);
}
--
2.1.4
More information about the wine-patches
mailing list