Learn how to convert WOFF to TTF using C#.
The following topics are covered in this article:
- C# API to Convert WOFF to TTF
- Convert WOFF to TTF using C#
- Convert WOFF2 to TTF in C#
Learn how to convert WOFF to TTF using C#.
The following topics are covered in this article:
// This code example demonstrates how to convert WOFF2 to TTF. | |
// Font file path | |
string fontPath = @"D:\Files\font\Montserrat-Regular.woff2"; | |
// Load the Font file | |
FileSystemStreamSource source = new FileSystemStreamSource(fontPath); | |
// Create font file definition | |
FontFileDefinition fileDefinition = new FontFileDefinition("woff2", source); | |
// Create font definition | |
FontDefinition fontDefinition = new FontDefinition(FontType.TTF, fileDefinition); | |
// Open font | |
Font font = Font.Open(fontDefinition); | |
// TTF output path | |
string outPath = @"D:\Files\font\Woff2ToTtf_out.ttf"; | |
FileStream outStream = File.Create(outPath); | |
// Convert WOFF2 to TTF | |
font.SaveToFormat(outStream, FontSavingFormats.TTF); |
// This code example demonstrates how to convert WOFF to TTF. | |
// Font file path | |
string fontPath = @"D:\Files\font\Montserrat-Regular.woff"; | |
// Load the Font file | |
FileSystemStreamSource source = new FileSystemStreamSource(fontPath); | |
// Create font file definition | |
FontFileDefinition fileDefinition = new FontFileDefinition("woff", source); | |
// Create font definition | |
FontDefinition fontDefinition = new FontDefinition(FontType.TTF, fileDefinition); | |
// Open font | |
Font font = Font.Open(fontDefinition); | |
// TTF output path | |
string outPath = @"D:\Files\font\WoffToTtf_out.ttf"; | |
FileStream outStream = File.Create(outPath); | |
// Convert WOFF to TTF | |
font.SaveToFormat(outStream, FontSavingFormats.TTF); |