Nikolay Sivov : dwrite/tests: Some tests for bounds returned by GetAlphaTextureBounds().
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Jul 20 14:20:50 CDT 2015
Module: wine
Branch: master
Commit: a718a9a5ca3ff014db5c685d3747e9c442bfbe09
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a718a9a5ca3ff014db5c685d3747e9c442bfbe09
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon Jul 20 15:14:32 2015 +0300
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);
}
More information about the wine-cvs
mailing list