In the previous post, you have seen how to load and work with CFF, TrueType, OpenType, and Type1 fonts from within your C++ applications. This article takes you one step further by demonstrating how to detect the Latin symbols in a font programmatically using C++. After detection, you can decide whether a font supports the Latin symbols or not.

C++ API to Detect Latin Symbols in Fonts

Aspose.Font for C++ is a font manipulation and management API that lets you detect the support of Latin symbols in the fonts quite easily. You can either download the API or install it via NuGet.

PM> Install-Package Aspose.Font.Cpp

Detect Latin Symbols in TrueType Fonts in C++

Detecting the support of Latin symbols using Aspose.Font for C++ is as simple as a pie. The following are the steps to check if a particular TrueType font supports Latin symbols or not.

  • Create an object of FontDefinition class to load the font by specifying its type as TrueType.
  • Create an object of TtfFont class to access the font’s information.
  • Loop through the possible codes and decode them into glyph IDs.
  • Match the glyph IDs to check if Latin symbols are supported in the source TrueType font or not.

The following code sample shows how to detect Latin symbols in TrueType fonts using C++.

Detect Latin Symbols in Type1 Fonts in C++

The process of detecting Latin symbols in Type1 fonts is as same as you have done for TrueType fonts. The only difference is the use of the Type1Font class. The following steps demonstrate the complete process of Latin symbol detection in Type1 fonts.

  • Use the FontDefinition class to load the font by specifying its type as Type1.
  • Use Type1Font class to access the information of the font.
  • Loop through the possible codes and decode them into glyph IDs.
  • Match the glyph IDs to check the support of Latin symbols in the provided Type1 font.

The following code sample shows how to detect Latin symbols in Type1 font using C++.

Conclusion

In this article, you have learned how to detect Latin symbols in TrueType and Type1 fonts using C++. The code samples in this article let you determine if the Latin symbols are supported by a particular font or not. You can learn more about the C++ font manipulation API using documentation.

See Also