Detect Latin Symbols in Fonts
.NET API Solution to find out if the font supports Latin symbols.
Aspose.Font API Solution has a rich functionality to work with fonts. Conversion, glyph manipulations, loading and saving fonts, and many more. Some of the features are linked to manipulations with glyphs.
A glyph is an individually designed character of a typeface or a graphical representation of a symbol/character. To learn more about this font unit, read the Introduction to Glyph article.
We all know for sure that such fonts like Arial, Times New Roman, and Helvetica includes Latin symbols. But what about the rest of fonts? This page describes the option on how to find glyphs of the Latin symbols in the font, but the whole functionality is carefully described in the Using Glyph objects article. There you will find much more C# code examples, and learn the functionality of Aspose.Font for working with glyphs and the Aspose.Font.Glyphs namespace in particular.
To check fonts for Latin symbols we 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 detect whether the font supports Latin symbols using C#:
- Specify the font that needs to be checked.
- Detect the Latin symbols using the functionality of the GlyphId Class.
C# Code for detecting Latin symbols in fonts
using Aspose.Font;
using Aspose.Font.Glyphs;
bool latinText = true;
//Font to check
Font font;
for (uint code = 65; code < 123; code++)
{
GlyphId gid = font.Encoding.DecodeToGid(code);
if (gid == null || gid == GlyphUInt32Id.NotDefId)
{
latinText = false;
}
}
if (latinText)
{
Console.WriteLine(string.Format("Font {0} supports latin symbols.", font.FontName));
}
else
{
Console.WriteLine(string.Format("Latin symbols are not supported by font {0}.", font.FontName));
}
FAQ
1. What is a Latin symbol?
A Latin or Roman symbol is any symbol of the Latin alphabet. Most modern languages use the Latin alphabet English, for example.
2. What are Non-Latin symbols?
Here are a few examples of non-Latin languages: Asian, Arabic, Cyrillic, Hebrew. Symbols of these languages are non-Latin.
3. Is Latin a Unicode?
From the official site of Unicode we can learn that the Unicode Standard actually started out with the Basic Latin. So yes, they are mostly Unicode. To check if any symbol is Unicode, just learn Unicode Code Charts .
4. How to detect Latin symbols in font?
Specify the font you want to work with. Using the entities of the GlyphId Class check if the font includes Latin symbols.