Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active April 8, 2022 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/e0ec151a44de63a9448a6f030a39ca3a to your computer and use it in GitHub Desktop.
Save aspose-com-gists/e0ec151a44de63a9448a6f030a39ca3a to your computer and use it in GitHub Desktop.
Convert WOFF to TTF using C#

Learn how to convert WOFF to TTF using C#.

The following topics are covered in this article:

  1. C# API to Convert WOFF to TTF
  2. Convert WOFF to TTF using C#
  3. Convert WOFF2 to TTF in C#
// 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment