Convert Type1 | API Solution for .NET

In this article, you will see how to convert Type 1 format. Aspose.Font for .NET offers you solutions for conversion Type 1 to TTF, Type 1 to WOFF, and Type 1 to WOFF2.


For all three conversions you need to put the next namespaces at the top of the head of the title:

1 
2using Aspose.Font.Sources;
3using System;
4using System.IO;

Reach How to convert the font into the desired format? chapter to see about the Aspose conversion fundamentals.

Convert Type1 to TTF

Fulfill the actions written below to tranform Type one to True Type Font:

  1. Open Type1 font.
  2. Apply the output settings for the Type1 font.
  3. Fulfill the conversion.
 1 
 2    // Open Type1 font
 3    string fontPath = Path.Combine(DataDir, "Courier.pfb");
 4    FontDefinition fontDefinition = new FontDefinition(FontType.Type1, new FontFileDefinition("pfb", new FileSystemStreamSource(fontPath)));
 5    Font font = Font.Open(fontDefinition);
 6
 7    // Type1 output settings
 8    string outPath = Path.Combine(OutputDir, "Type1ToTtf_out1.ttf");
 9    FileStream outStream = File.Create(outPath);
10
11    // Convert type1 to ttf
12    font.SaveToFormat(outStream, FontSavingFormats.TTF);

Convert font formats from Type 1 to Woff

For this you will need to take the next steps:

  1. Open Type1 font.
  2. Add the output settings.
  3. Fulfill the conversion.
 1 
 2    // Open Type1 font
 3    byte[] fontMemoryData = File.ReadAllBytes(Path.Combine(DataDir, "Courier.pfb"));
 4    FontDefinition fontDefinition = new FontDefinition(FontType.Type1, new FontFileDefinition("pfb", new ByteContentStreamSource(fontMemoryData)));
 5    Font font = Font.Open(fontDefinition);
 6
 7    // Woff output settings
 8    string outPath = Path.Combine(OutputDir, "Type1ToWoff_out3.ttf");
 9    FileStream outStream = File.Create(outPath);
10
11    // Convert type1 to woff
12    font.SaveToFormat(outStream, FontSavingFormats.WOFF);

Convert Type 1 to WOFF2

Follow the written below algorithm to convert the fonts:

  1. Open Type1 font.
  2. Notify the next output settings.
  3. Fulfill the conversion.
 1 
 2    // Open Type1 font
 3    byte[] fontMemoryData = File.ReadAllBytes(Path.Combine(DataDir, "Courier.pfb"));
 4    FontDefinition fontDefinition = new FontDefinition(FontType.Type1, new FontFileDefinition("pfb", new ByteContentStreamSource(fontMemoryData)));
 5    Font font = Font.Open(fontDefinition);
 6
 7    // Woff2 output settings
 8    string outPath = Path.Combine(OutputDir, "Type1ToWoff2_out4.ttf");
 9    FileStream outStream = File.Create(outPath);
10
11    // Convert type1 to woff2
12    font.SaveToFormat(outStream, FontSavingFormats.WOFF2);
                
            

For getting more examples of using the solution go to the Aspose.Font.Examples.sln solution, in the net-examples of the Aspose.Font Documentation Github repository.

Aspose also offers you a free online Font Conversion application where you can try the existing functionality.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.