Esempio n. 1
0
        [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);
        }
Esempio n. 2
0
        public void CharacterToGlyphIndex_FakeFactorMap()
        {
            var chars = new char[]
            {
                'a',
                'b',
                'c',
                'd',
                '9',
                '@'
            };

            var map = TestFactory.CreateCharacterMap(chars);

            for (var i = 0; i < chars.Length; i++)
            {
                var idx = map.CharacterToGlyphIndex(chars[i]);
                Assert.Equal(i, idx);
            }
        }
Esempio n. 3
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
            };

            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);
        }