Reputation: 131
I am binding a combo box with all the characters from ttf file. Combo box displays empty space for some of the characters like \n \r \t \a etc. I am not able to find the reason why it does so.
Here is my code to populate all symbols
var families = Fonts.GetFontFamilies(new Uri(fontFilePath));
foreach (FontFamily family in families)
{
var typefaces = family.GetTypefaces();
foreach (Typeface typeface in typefaces)
{
GlyphTypeface glyph;
typeface.TryGetGlyphTypeface(out glyph);
IDictionary<int, ushort> characterMap = glyph.CharacterToGlyphMap;
foreach (var item in characterMap.Values)
{
char temp = Convert.ToChar(item);
string str = string.Format("{0}", temp);
if (!listOfString.Contains(str))
{
listOfString.Add(str);
}
}
}
}
listOfString.Sort();
ddlSymbols.ItemsSource = listOfString;
Any help would be highly appreciated. Thanks in advance.
Upvotes: 0
Views: 933
Reputation: 14619
In C#, some of the characters are called "Escape sequences" and are special characters.
'
in a character literal, e.g. '\''"
in a string literal, e.g. "this is the
double quote (\") character"\
character in a character or string literal, e.g. '\' or "this is the backslash
(\) character" So when you map your characters, their special behaviour is used.
Upvotes: 1