Convert EOT | .NET
It is known that Embedded Open Type
(EOT
) is supported mainly by the Internet Explorer browser. Because of that, to render correctly you will need to build in your software converter to EOT
from other font formats and vice versa. In this article, it is described how to use the Aspose.Font for .NET to convert EOT
to TTF
, EOT
to WOFF
, and EOT
to WOFF2
.
For all the conversions you will need these namespaces:
using Aspose.Font.Sources;
using System;
using System.IO;
The information about the font conversion fundamentals is notified in How to convert the font into the desired format? chapter.
Convert EOT to TTF
To transform Embedded Open Type
to True Type Format
you will need:
- Open
EOT
font. - Notify the output settings for
TTF
font. - Run the font conversion.
// Open eot font, passing TTF as value for FontType, TtfFont will be returned as result of call Font.Open()
string fontPath = Path.Combine(DataDir, "LoraRegular.eot");
FontDefinition fontDefinition = new FontDefinition(FontType.TTF, new FontFileDefinition(new FileSystemStreamSource(fontPath)));
Font font = Font.Open(fontDefinition);
// Ttf output settings
string outPath = Path.Combine(OutputDir, "EotToTtf_out1.ttf");
// Save opened font to TrueType format
font.Save(outPath);
Convert EOT to WOFF
To get Web Open Font Format
from Embedded Open Type
the next actions have to be done:
- Open
EOT
font. - Notify the output settings for the
WOFF
font. - Fulfill the font conversion.
// Open eot font
string fontPath = Path.Combine(DataDir, "LoraRegular.eot");
FontDefinition fontDefinition = new FontDefinition(FontType.TTF, new FontFileDefinition(new FileSystemStreamSource(fontPath)));
Font font = Font.Open(fontDefinition);
// Woff output settings
string outPath = Path.Combine(OutputDir, "EotToWoff_out3.woff");
using (FileStream outStream = File.Create(outPath))
{
// Convert eot to woff
font.SaveToFormat(outStream, FontSavingFormats.WOFF);
}
Convert EOT to WOFF2
If you need to get the second version of the Web Open Font Format
from Embedded Open type
the taken steps are the same:
- Open
EOT
Font. - Add the output settings for the
WOFF2
font. - Convert
EOT
toWOFF2
and save the result.
// Open eot font
string fontPath = Path.Combine(DataDir, "LoraRegular.eot");
FontDefinition fontDefinition = new FontDefinition(FontType.TTF, new FontFileDefinition(new FileSystemStreamSource(fontPath)));
Font font = Font.Open(fontDefinition);
// Woff2 output settings
string outPath = Path.Combine(OutputDir, "EotToWoff2_out4.woff2");
using (FileStream outStream = File.Create(outPath))
{
// Convert eot to woff2
font.SaveToFormat(outStream, FontSavingFormats.WOFF2);
}
Our folder Aspose.Font.Examples.sln solution, in the net-examples of the Aspose.Font Documentation has these and many more examples on how to use the Aspose solution.
Similar functionality is also given by the free online Font Conversion application. Learn what opportunities it gives to you.