Fonts are an integral part of digital documents and web pages that are used to define the appearance of the text. The font files are used to store information about the fonts such as styles, weight, size and etc. There could be the case when you would need to manipulate fonts in order to extract their information. For such scenarios, in this article, you will learn how to load and read information from TrueType, CFF, and Type1 fonts using C++.
- C++ Font Manipulation API
- Load CFF, TrueType, and Type1 Fonts using C++
- Extract Font Metrics from TrueType or Type1 Fonts using C++
C++ Font Manipulation Library
Aspose.Font for C++ is a powerful font manipulation API that allows you to work with TrueType, CFF, OpenType, and Type1, EOT, and many other fonts from within your C++ applications. You can load, save, and extract encoding information from the fonts as well as work with glyphs. The API can be downloaded from the downloads section or installed via NuGet.
Load CFF, TrueType, and Type1 Fonts using C++
Aspose.Font for C++ lets you load the CFF, TrueType, and Type1 fonts from the files located on your storage media. The following are the steps to load a font.
- Create an object of FontDefinition class to load the font by specifying its type i.e. TrueType, Type1, etc.
- Use CffFont, TtfFont, or Type1Font class to open CFF, TrueType, and Type1 fonts respectively from FontDefinition object.
Load CFF Fonts using C++
The following code sample shows how to load CFF fonts using C++.
Load TrueType Fonts using C++
The following code sample shows how to load TrueType fonts using C++.
Load Type1 Fonts using C++
The following code sample shows how to load Type1 fonts using C++.
Extract Font Metrics from TrueType or Type1 using C++
Aspose.Font for C++ also allows you to extract the font metrics which contain information such as Ascender, Descender, TypoAscender, TypoDescender, and UnitsPerEm. The following are the steps to retrieve font metrics from a TrueType or Type1 font.
- Create an object of FontDefinition class to load TrueType or Type1 font.
- Open font using TtfFont or Type1Font class according to the font’s type.
- Extract the font’s metrics information.
Get Font Metrics from TrueType Font using C++
Extract Font Metrics from Type1 Font using C++
In this article, you have learned how to load CFF, TrueType, and Type1 fonts and extract their information using C++. You can explore more about the C++ Font Manipulation API using the documentation.