コード例 #1
0
        private static Font CreateFont(string fontName, int size)
        {
            var    fontCollection = new FontCollection();
            string fontPath       = TestFontUtilities.GetPath(fontName);

            return(fontCollection.Add(fontPath).CreateFont(size));
        }
コード例 #2
0
        public void CanRenderCustomFont()
        {
            Font font = CreateFont(TestFonts.IcoMoonEvents, 175);

            TextOptions options = new(font)
            {
                VerticalAlignment = VerticalAlignment.Center
            };

            const int imageSize = 300;

            using var image = new Image <Rgba32>(imageSize, imageSize);

            string iconText = char.ConvertFromUtf32(int.Parse("e926", NumberStyles.HexNumber));

            FontRectangle rect = TextMeasurer.Measure(iconText, options);

            float textX = ((imageSize - rect.Width) * 0.5F) + rect.Left;
            float textY = ((imageSize - rect.Height) * 0.5F) + (rect.Top * 0.25F);

            image.Mutate(x => x.DrawText(iconText, font, Color.Black, new PointF(textX, textY)));
            image.Save(TestFontUtilities.GetPath("e96.png"));
        }
コード例 #3
0
ファイル: DrawText.Path.cs プロジェクト: woutware/ImageSharp
 public DrawText_Path()
 {
     this.FontCollection = new FontCollection();
     this.Font           = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")).CreateFont(12);
 }
コード例 #4
0
ファイル: DrawText.Path.cs プロジェクト: Toxantron/ImageSharp
 public DrawText_Path()
 {
     this.FontCollection = new FontCollection();
     this.Font           = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff"));
     this.img            = new ProcessorWatchingImage(10, 10);
 }
コード例 #5
0
 public OutputText()
 {
     this.FontCollection = new FontCollection();
     this.Font           = FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff"));
 }