Merge TTF fonts

.NET API Solution to merge TrueType fonts

 

Aspose.Font API Solution has a rich functionality to work with fonts. Conversion, manipulations with glyphs, detection of Latin symbols, and many more. Here we will explore font merging functionality.

Combining several font files into a single file, commonly known as font merging or font consolidation, gives you the next advantages:

  • Merged files are easier to distribute. Instead of managing and distributing multiple font files separately, you only need to download and install one file. This can be especially beneficial when sharing fonts with others or using them in applications or on websites.

  • Consolidating multiple fonts into a single file can help reduce the overall file size which may be crucial in web design or digital media, where optimizing file sizes influences loading.

  • Merging can enhance performance in certain contexts. This is especially relevant in situations where multiple fonts are used throughout a project or website, as loading a single merged font file can be faster than loading several separate font files.

  • Font merging can also be used to create font subsets . Font subsets include only the characters and glyphs necessary for a particular project or language, rather than the entire character set.

It’s important to note that font merging should be done carefully to ensure compatibility and maintain the intended design integrity. It’s recommended to follow font licensing agreements and consult the font designer or foundry to confirm if merging is allowed or if specific guidelines need to be followed. But anyway, if you need to merge fonts Aspose.Font offers you 2 ways to do this. You can either use cross-platform Font Merger or use API Solution to code. On this page, you will find an example of how to do this within C#.

To run the examples you need:

  • Aspose.Font for .NET API which is a feature-rich, powerful and easy-to-use document manipulation and conversion API for C# platform.

  • Open the NuGet package manager, and search for Aspose.Font and install. You may also use the following command from the Package Manager Console.

Package Manager Console Command


    PM> Install-Package Aspose.Font

Steps to combine two fonts into a single one C#:

  1. Specify the input font.
  2. Merge fonts using the IFontCharactersMerger.MergeFonts() Method.
  3. Save the resulting font using the Save() Method.

C# Code for merging fonts

    using Aspose.Font.Ttf;
    using Aspose.Font.TtfHelpers;
    // Fonts to take glyphs from
    TtfFont font1, font2;

    //Create merger
    IFontCharactersMerger merger = HelpersFactory.GetFontCharactersMerger(font1, font2);

    TtfFont destFont = merger.MergeFonts(new uint[] { 'a', 'b', 'c' }, new uint[] { 'd', 'e', 'f' }, "TestFont");

    //Save resultant font
    destFont.Save("TestFont.ttf");



FAQ

1. Fonts of which formats can be merged with Aspose.Font for .NET?

Using this API Solution you can combine TTF, WOFF, WOFF2, EOT, Type1, and CFF fonts and save the result as TTF, WOFF, WOFF2, or SVG.

2. Can I merge fonts online?

Yes, there is a cross-platform Aspose Font Merger developed specifically for such a task.

3. Can I merge fonts of different formats?

No, but you can convert one of the fonts to make the formats the same and then merge the files.