Convert WOFF to WOFF2 | .NET
Contents
[
Hide
]
If you need to transform Web OpenFont Format
to its version 2.0, this article provides you with the necessary information.
Fill the head of the file with the following namespaces:
using Aspose.Font.Sources;
using Aspose.Font.Ttf;
using System;
using System.IO;
If you want to learn the Aspose conversion fundamentals go to How to convert the font into the desired format? chapter to find them out.
Taking the next three steps you will convert WOFF
to WOFF2
:
-
Open
Woff
font file.// Open woff font string fontPath = Path.Combine(DataDir, "Montserrat-Regular.woff"); FontDefinition fontDefinition = new FontDefinition(FontType.TTF, new FontFileDefinition("woff", new FileSystemStreamSource(fontPath))); Font font = Font.Open(fontDefinition);
-
Notify the output setting.
// Woff2 output settings string outPath = Path.Combine(OutputDir, "WoffToWoff2_out1.woff2"); FileStream outStream = File.Create(outPath);
-
Transform the font into
WOFF2
format and save the result.// Convert woff to woff2 font.SaveToFormat(outStream, FontSavingFormats.WOFF2);
More examples of the solution are placed in Aspose.Font.Examples.sln solution, in the net-examples of the Aspose.Font Documentation Github repository.
Check the Font Conversion application from Aspose and see the solutions it offers.