Convert WOFF2 to TTF | .NET
Contents
[
Hide
]
This page is aimed to show how to convert fonts from Web Open Font Format 2
to True Type
font using the Aspose.Font for .NET.
Set the following namespaces at the head of the file:
using Aspose.Font.Sources;
using Aspose.Font.Ttf;
using System;
using System.IO;
How to convert the font into the desired format? chapter will let you know about the Aspose conversion fundamentals.
To convert WOFF2
to TTF
make the next actions:
-
Open
Woff2
font.// Open woff2 font string fontPath = Path.Combine(DataDir, "Montserrat-Regular.woff2"); FontDefinition fontDefinition = new FontDefinition(FontType.TTF, new FontFileDefinition("woff2", new FileSystemStreamSource(fontPath))); Font font = Font.Open(fontDefinition);
-
Add the output setting.
// Ttf output settings string outPath = Path.Combine(OutputDir, "Woff2ToTtf_out1.ttf"); FileStream outStream = File.Create(outPath);
-
Convert font and save the result.
// Convert woff2 to ttf font.SaveToFormat(outStream, FontSavingFormats.TTF);
Go to Aspose.Font.Examples.sln solution, in the net-examples folder of the Aspose.Font Documentation Github repository for getting more examples.
Aspose also offers a free web Font Conversion application application where you can try the functionality online.