示例#1
0
文件: Program.cs 项目: ywscr/Fonts
        public static void RenderText(RendererOptions font, string text)
        {
            GlyphBuilder builder  = new GlyphBuilder();
            TextRenderer renderer = new TextRenderer(builder);

            Primitives.SizeF size = TextMeasurer.Measure(text, font);
            renderer.RenderText(text, font);

            builder.Paths
            .SaveImage((int)size.Width + 20, (int)size.Height + 20, font.Font.Name, text + ".png");
        }
示例#2
0
        public void ThrowsMeasureingWhitespace()
        {
            // wendy one returns wrong points for 'o'
            Font font = new FontCollection().Install(TestFonts.WendyOneFile).CreateFont(12);

            var r = new GlyphRenderer();

            Primitives.SizeF size = TextMeasurer.MeasureBounds("          ", new RendererOptions(new Font(font, 30), 72)).Size;

            Assert.Equal(60, size.Width, 1);
            Assert.Equal(31.6, size.Height, 1);
        }