private static Font CreateFont(string fontName, int size) { var fontCollection = new FontCollection(); string fontPath = TestFontUtilities.GetPath(fontName); return(fontCollection.Add(fontPath).CreateFont(size)); }
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")); }
public DrawText_Path() { this.FontCollection = new FontCollection(); this.Font = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")).CreateFont(12); }
public DrawText_Path() { this.FontCollection = new FontCollection(); this.Font = this.FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")); this.img = new ProcessorWatchingImage(10, 10); }
public OutputText() { this.FontCollection = new FontCollection(); this.Font = FontCollection.Install(TestFontUtilities.GetPath("SixLaborsSampleAB.woff")); }