[InlineData("a\tb", 1, 10, 10, 13, 11)] // this will break once tab support is added. public void RenderText(string text, int fontsize, int startX, int startY, int lastX, int lastY) { var rasterizer = new FakeGlyphRasterizer(); // the default test factory will end up faking out spacing for a monospaced font. // the font will draw a line from top left to bottom right for each character var renderer = TestFactory.CreateRenderer(text, rasterizer); var options = new TextOptions() { FontSize = fontsize, LineHeight = 1 }; renderer.Render(startX, startY, text, options); var start = rasterizer.Points.First(); var end = rasterizer.Points.Last(); Assert.Equal(startX, start.X); Assert.Equal(startY, start.Y); Assert.Equal(lastX, end.X); Assert.Equal(lastY, end.Y); }
[InlineData("World", 10, 50, 10)] //pixel size == font size in these tests public void MesureText(string text, int fontSize, int expectedWidth, int expectedHeight) { // the default test factory will end up faking out spacing for a monospaced font. var renderer = TestFactory.CreateRenderer(text); var options = new TextOptions() { FontSize = fontSize }; var size = renderer.Measure(text, options); Assert.Equal(expectedWidth, size.Width); Assert.Equal(expectedHeight, size.Height); }