예제 #1
0
        [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);
        }
예제 #2
0
        // to mean that lettersize becomes pixel size the resolution must be 72 if letterSize == EmSquare.Size
        public static Renderer CreateRenderer(string supportedCharacters, int lettersize = EmSquare.Size, int resolution = 72)
        {
            //lets fake out a typeface with all stnadrd cahractes
            var rasterizer = new FakeGlyphRasterizer()
            {
                Resolution = resolution
            };

            return(CreateRenderer(supportedCharacters, rasterizer, lettersize));
        }