Reputation: 1022
I'm trying to replicate (not an exact replica) the CharMap program from windows in my program for inserting and adding symbols. Problem is that the symbols would work on a machine with Windows 7, 8 10 but some symbols wouldn't show on Windows XP.
Windows XP
Windows 7, 8, 10
I'm currently using the below to generate my symbols:
public static string CharToHex(char c)
{
return ((ushort)c).ToString("X4");
}
string x = CharToHex(Convert.ToChar(defaultSymbolsCollection[i]));
int value = int.Parse(x, System.Globalization.NumberStyles.HexNumber);
string symbol = char.ConvertFromUtf32(value).ToString();
AddSymbol(Convert.ToString((char)value);
Void AddSymbol(string _symbolText)
{
Button symbolButton = new Button()
{
Text = _symbolText,
Size = new Size(32, 32),
Font = new Font("Arial Unicode MS", 9),
Tag = _symbolText,
UseMnemonic = false,
};
symbolButton.Click += SymbolButton_Click;
pnl_SymbolHolder.Controls.Add(symbolButton);
}
This ends up working only on Windows 7, 8, 10 but not on Windows XP. some symbols don't show, instead is represented by a square and others do.
How do I go about solving this problem? my other alternative was to draw the symbols at the center of the button that way it's always there regardless because it was drawn but I would like to see other alternatives, perhaps a solution to this problem
Upvotes: 1
Views: 1371
Reputation: 21239
The font "Arial Unicode MS" is not included with Windows XP/7/8/10, but is included with some Microsoft Office products. Windows XP is likely using "Tahoma" instead (the default UI font), which does not include glyphs for those symbols (whereas "Segoe UI", the default UI font on Windows 7/8/10, does).
For the characters to appear correctly, you will need to find/install/use a font that has glyphs for those characters.
Upvotes: 2