Exemple #1
0
        public void AntialiasingIsAntialiased <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            Font font36  = TestFontUtilities.GetFont(TestFonts.OpenSans, 20);
            var  textOpt = new TextOptions(font36)
            {
                Dpi    = 96,
                Origin = new PointF(0, 0)
            };

            var comparer = ImageComparer.TolerantPercentage(0.001f);

            provider.RunValidatingProcessorTest(
                x => x
                .SetGraphicsOptions(o => o.Antialias = false)
                .DrawText(textOpt, "Hello, World!", Color.Black),
                comparer: comparer);
        }
Exemple #2
0
        public void TextBuilder_Bounds_AreCorrect()
        {
            Vector2 position = new(5, 5);
            var     options  = new TextOptions(TestFontUtilities.GetFont(TestFonts.OpenSans, 16))
            {
                Origin = position
            };

            string text = "Hello World";

            IPathCollection glyphs = TextBuilder.GenerateGlyphs(text, options);

            RectangleF    builderBounds  = glyphs.Bounds;
            FontRectangle measuredBounds = TextMeasurer.MeasureBounds(text, options);

            Assert.Equal(measuredBounds.X, builderBounds.X);
            Assert.Equal(measuredBounds.Y, builderBounds.Y);
            Assert.Equal(measuredBounds.Width, builderBounds.Width);
            Assert.Equal(measuredBounds.Height, builderBounds.Height);
        }