How can I identify the characters defined in the font?

I am making a simple help tool with css icon icons.

He currently takes a specific wing-style font and presents it as it appears for each Unicode number, side by side with a standard system font (for example, arial) as I go from Unicode number 33-255.

Since those familiar with fonts and character encodings have already guessed, many of these places will be empty. Here is an example: enter image description here

As you can see, the characters that are actually worth showing for this font are in the minority, and many characters in this unicode range are not even displayed by default for the default sans-serif font. This is not critical material, all suitable characters are shown in any case, but purely out of curiosity, I would like to know if there is a way to find out which characters are represented in the font. Does anyone know a solution?

Ideally, a server solution is preferred, any language you like. However, any solution would be valuable at all.

For the curious, my existing code runs on github: Looper Font

I hope that a presentation with a flat file will not offend anyone, I try to make it scanty and average.

+6
source share
1 answer

I believe that the information you are looking for is in the font CMAP table. I'm not an expert on fonts, but I understand that the CMAP table displays unicode, points to glyph indices. Therefore, if there is no glyph associated with a unicode point, we can assume that the font does not support this character.

Here is a sample C # code that I found using WPF libraries:

 var fontFamilies = System.Windows.Media.Fonts.GetFontFamilies(@"C:\Windows\Fonts\Arial.ttf"); foreach (var family in fontFamilies) { foreach (var typeface in family.GetTypefaces()) { var glyph = null as System.Windows.Media.GlyphTypeface; if (typeface.TryGetGlyphTypeface(out glyph)) { foreach (var kvp in glyph.CharacterToGlyphMap) { Console.WriteLine(kvp.Key.ToString() + " : " + kvp.Value.ToString()); } } } } 

I don’t know how much this will help you, but you said that any language / solution would be valuable.

All of these classes can be found in the System.Windows.Media namespace , which is part of the PresentationCore.dll strong> build.

+3
source

Source: https://habr.com/ru/post/921329/


All Articles