Font converter | Aspose.Font for .NET
Overview
How much simpler creating interfaces would be if there were only one font format existing. But as we have a lot of different types of gadgets, environments, a few operational systems, and many other areas where we use fonts, we have a bunch of font formats to serve different purposes. Some are better for web pages and applications, some for publishing. There are pros and cons to any font format. If you want the text to render well everywhere, sometimes you will have to transform one font into another.
For some tasks, a web application will be just enough. For example, if you only need to convert one text document into a document with a different font type. And Aspose does have such an application in its ecosystem. Try Font Conversion application to see whether it fits your purposes.
In case your issues are not covered with the web application, and you need a more solid solution, here is the tool aimed to simplify the conversion process for you. The Aspose.Font for .NET library is a solution that allows you to convert fonts between popular formats:
It is a flexible and easy-to-use library designed to work with different font files like TrueType CFF, OpenType, and Type1. Apart from converting fonts, it offers some more manipulations with fonts like reading font information, reading glyphs and metrics information, detecting latin symbols in fonts, etc.
Supported font formats
The next formats are supported by the font converter from Aspose:
| Format | Description |
|---|---|
TrueType (
TTF) | It is one of the most popular formats between Mac Os and Microsoft Windows operating systems. True type fonts have .ttf extension. Fonts of the TrueType family are easy to scale any size on computers and other devices like printers, smartphones, etc. The most famous representatives of TTF fonts are Times Roman, Helvetica, and Courier families. |
Web Open Font Format (
WOFF) | This font format is developed for web pages. Basically, it is TrueType or OpenType font altered by adding HTML metadata and by applied compression. The format is supported by all major browsers. |
Web Open Font Format version 2.0 (
WOFF2) | The next generation of WOFF. It gives you a 30% average compression gain in comparison to WOFF. It is not that widespread though yet. |
Embedded OpenType format (
EOT) | These are made by Microsoft and supported by Internet explorer fonts used on the web. Because of compression, the font files are smaller. EOT also provides some copyright protection because of subsetting. |
Type 1 format | (also known as PostScript, PS1, T1, Adobe Type 1, Multiple Master, or MM). This format is developed by Adobe Systems for professional digital typesetting. This system uses the PostScript file format to encode font information. As this font type is outdated and is not supported in many modern environments like mobile devices and web browsers, it will not have been supported anymore by Adobe by 2023. The company recommends using the Open type instead. |
Compact Font Format (
CFF) | It is also known as Type 2 font format, or CFF/Type 2 font format. With this format, you can store different fonts together in one unit called Fontset. As it allows sharing data between fonts, and defaulting frequently occurring data it provides you with notable space saving. |
Scalable Vector Graphics (
SVG) | SVG is a file format used to display vector-based graphics and images on the web. SVG fonts, also known as SVG-in-OpenType or SVGOT fonts, are a specific type of font format within SVG. Each character in an SVG font is defined as a separate SVG path or shape so SVG fonts can be scaled without losing quality. |
All of the formats are supported for reading, and a few of them for writing.
Formats supported for reading and/or writing
| Format | Read | Write |
|---|---|---|
TTF | ||
CFF | ||
WOFF | ||
WOFF2 | ||
Type 1 | ||
EOT | ||
SVG |
Available font conversions
Any font format from those supported for reading can be converted and saved into one of the formats supported for writing.
Here you can learn the pairs of fonts which are currently provided for conversion by the Aspose solution. Following the links, you will find more information and examples of using the library illustrated with the code snippets.
TTF to WOFF -
TrueType FonttoWeb Open Font FormatconversionTTF to WOFF2 -
TrueType FonttoWeb Open Font Format version 2.0conversionTTF to SVG -
TrueType FonttoScalable Vector GraphicsconversionWOFF to TTF -
Web Open Font FormattoTrueType FontconversionWOFF to WOFF2 -
Web Open Font FormattoWeb Open Font Format version 2.0conversionWOFF to SVG -
Web Open Font FormattoScalable Vector GraphicsconversionWOFF2 to TTF -
Web Open Font Format version 2.0toTrueType FontconversionWOFF2 to WOFF -
Web Open Font Format version 2.0toWeb Open Font FormatconversionWOFF2 to SVG -
Web Open Font Format version 2.0toScalable Vector GraphicsconversionEOT to TTF -
Embedded OpenType FonttoTrueType FontconversionEOT to WOFF -
Embedded OpenType FonttoWeb Open Font FormatconversionEOT to WOFF2 -
Embedded OpenType FonttoWeb Open Font Format version 2.0conversionEOT to SVG -
Embedded OpenType FonttoScalable Vector GraphicsconversionType 1 to TTF -
Type 1Font toTrueType FontconversionType 1 to WOFF -
Type 1Font toWeb Open Font FormatconversionType 1 to WOFF2 -
Type 1Font toWeb Open Font Format version 2.0conversionType 1 to SVG -
Type 1Font toScalable Vector GraphicsconversionCFF to TTF -
Compact Font FormattoTrueType FontconversionCFF to WOFF -
Compact Font FormattoWeb Open Font FormatconversionCFF to WOFF2 -
Compact Font FormattoWeb Open Font Format version 2.0conversionCFF to SVG -
Compact Font Formatto toScalable Vector GraphicsconversionCFF to OTF -
Compact Font FormattoOpenType Fontconversion
- new
How to convert the font into the desired format?
- Load font from any of the supported formats and get reference on base Aspose.Font.Font object which represents this font.
- Save just loaded font into another format with the help of SaveToFormat() method of the base abstract Font class instance. SaveToFormat() method takes two arguments: output stream and FontSavingFormats enumeration for choosing the output font format. Method SaveToFormat() allows you to save fonts into any of the output formats supported.
You need to use the following namespaces:
1
2 using Aspose.Font.Sources;
3 using Aspose.Font.Ttf;
4 using System;
5 using System.IO;Below is the sample which converts font from TTF to WOFF format.
Take the next steps:
- Open
TTFfont. - Add the output settings.
- Fulfil the conversion
TTFtoWOFFand save the resultant.
1 // Open ttf font
2 string fontPath = Path.Combine(DataDir, "Montserrat-Regular.ttf");
3 FontDefinition fontDefinition = new FontDefinition(FontType.TTF, new FontFileDefinition(new FileSystemStreamSource(fontPath)));
4 Font font = Font.Open(fontDefinition);
5
6 // Woff output settings
7 string outPath = Path.Combine(OutputDir, "TtfToWoff_out1.woff");
8 FileStream outStream = File.Create(outPath);
9
10 // Convert ttf to woff
11 font.SaveToFormat(outStream, FontSavingFormats.WOFF);Conversions into other formats, like woff to ttf, ttf to woff2, woff2 to ttf, and others can be accomplished in a similar way.
How to get the solution?
If you are interested in getting the library, go to Aspose.Font for .NET product page. There you will find more opportunities that the solution gives to you. You can download a free trial from or buy the product there.
If you have any troubles or questions left, feel free to post them at the Aspose.Font.Product Family section of the Free Support Forum and within a few hours our support team will clear everything up for you.