Aspose.Font for .NET is an on premise library of classes that deal in font loading and drawing. Plugging this into your .NET applications make them able to support TTF (TrueType Font), TTC (TrueType collections), CFF, OpenType, and Type1 font formats without installing any 3rd party software. It allows you to load the EOT, FNTDATA, WOFF, WOFF2 as TTF font, and then this TTF font can be saved into TTF or WOFF format. Using Aspose.Font for .NET, you can fetch information related to fonts, Glyphs, and Metrics. Detect latin symbols within fonts as well as render text using font glyphs. Special glyphs can also be rendered by implementing interface using simple graphics functionality (move point, draw line, curve). You can also extract encoding and licensing information from font files. Aspose.Font for .NET can be used to develop applications in any IDE that targets the .NET platform and supports Microsoft Windows Desktop, Microsoft Windows Server, and Windows Azure. It also complies with .NET Standard 2.1 (.NET Core 3.0/3.1) and supports the .NET5.0 (support for Linux / macOS).
$ dotnet add package Aspose.Font
Product Page | Docs | API Reference | Examples | Blog | Search | Free Support | Temporary License
Aspose.Font for .NET is a library that enables your .NET applications to load, edit, convert, and save font data. Aspose.Font for .NET also enables your .NET applications to draw text with the specified font.
TTF, WOFF/WOFF2, SVG
TTC, OpenType, CFF, Type1, EOT
Aspose.Font for .NET can be integrated with any kind of ASP.NET Web Application or a Windows Application.
Are you ready to give Aspose.Font for .NET a try? Simply execute Install-Package Aspose.Font from Package Manager Console in Visual Studio to fetch the NuGet package. If you already have Aspose.Font for .NET and want to upgrade the version, please execute Update-Package Aspose.Font to get the latest version.
using Aspose.Font;
using Aspose.Font.Sources;
// Font file name with the full path
string fontPath = Path.Combine(DataDir, "Montserrat-Regular.ttf");
// Initialize FontFileDefinition based on FileSystemStreamSource object, set fileExtension to "ttf"
FontFileDefinition fileDef = new FontFileDefinition("ttf", new FileSystemStreamSource(fontPath));
// Initialize FontDefinition using just created FontFileDefinition object, passing TTF as the FontType value
FontDefinition fontDef = new FontDefinition(FontType.TTF, fileDef);
// Load the font
Font font = Font.Open(fontDef);using Aspose.Font;
//Reference to font object loaded from some source
Font font;
string fontName = font.FontName;
string fontFamily = font.FontFamily;using Aspose.Font.Sources;
using System.IO;
// Open TTF font
string fontPath = Path.Combine(DataDir, "Montserrat-Regular.ttf");
FontDefinition fontDefinition = new FontDefinition(FontType.TTF, new FontFileDefinition(new FileSystemStreamSource(fontPath)));
Font font = Font.Open(fontDefinition);
// Write the output settings for the WOFF2 format
string outPath = Path.Combine(OutputDir, "out.woff2");
FileStream outStream = File.Create(outPath);
// Make conversion from TTF to WOFF2 and save the result using SaveToFormat() method of the base abstract Font class instance
font.SaveToFormat(outStream, FontSavingFormats.WOFF2);using System.IO;
using Aspose.Font;
using Aspose.Font.Renderers;
//Reference to font object loaded from some source
Font font;
//Text to render using the specified font
string text = "Hello world";
//Set font size to 12
using (Stream st = RenderingUtils.DrawText(font, text, 12))
{
//Save rendered text to the file
byte[] buff = new byte[st.Length];
st.Read(buff);
File.WriteAllBytes("Text.png", buff);
}
using Aspose.Font.Ttf;
using Aspose.Font.TtfHelpers;
// Original font to take glyphs from
TtfFont srcFont;
//To create a font we can use functionality of the IFontCharactersMerger interface.
//The IFontCharactersMerger.MergeFonts() method is designed to create a font as a result of merging two fonts.
//It takes two arrays of glyphs or character codes and puts into resultant font only glyphs from these arrays.
//But we can use a trick by passing two references on same font and provide only single array of character codes.
IFontCharactersMerger merger = HelpersFactory.GetFontCharactersMerger(srcFont, srcFont);
TtfFont destFont = merger.MergeFonts(new uint[] { 'a', 'c', 'e' }, new uint[0], "TestFont");
//Save resultant font
destFont.Save("TestFont.ttf");
Product Page | Docs | API Reference | Examples | Blog | Search | Free Support | Temporary License