Font Settings So, The problem is i am working on a dektop application, which will be used globally, but for German or European region countries th Arial Bold converted to their Local language, which makes the application unable to find the Arial Bold font. Please see the below attached image.
You can see in the above image that for German region , the font typeface changed to German Language , the Bold is converted to Fett. Is there a workaroud to stop this or to fetch these names as it is from their regional systems, so that i can convert Arial Bold to Aria Fett for system to recognise. I tried different methods but nothing worked.
enter image description here Tried this but it didn't help much.
namespace WPF_MapsStudio_UIs.Views {
/// <summary>
/// Interaction logic for CheckSystemFonts.xaml
/// </summary>
public partial class CheckSystemFonts : Window {
ObservableCollection<string> _strings = new ObservableCollection<string>();
Dictionary<string, List<string>> _fonts = new Dictionary<string, List<string>>();
const string _arialFont = "Arial";
public CheckSystemFonts() {
InitializeComponent();
//GetFont(fontNameToFind);
//NewCode();
Init();
SystemInfo();
GetTypeFaces();
GlyphTypeface glyphTypeface = new GlyphTypeface(new Uri(@"C:\Windows\Fonts\Arial.ttf", UriKind.Absolute));
var name = glyphTypeface.FamilyNames.Values.First();
var version = glyphTypeface.VersionStrings.Values.First();
var familyName = glyphTypeface.FamilyNames[CultureInfo.GetCultureInfo("en-US")];
}
private void Init() {
var arialfont = Fonts.SystemFontFamilies.Where(f => f.Source.Equals(_arialFont)).FirstOrDefault();
var arialTypeFaces = arialfont.FamilyTypefaces;
foreach(var ft in arialTypeFaces) {
if(!_fonts.ContainsKey(_arialFont)) {
_fonts.Add(_arialFont, new List<string>() { ft.AdjustedFaceNames.FirstOrDefault().Value });
}
else {
_fonts[_arialFont].Add(ft.AdjustedFaceNames.FirstOrDefault().Value);
}
}
Font_Cmbx.ItemsSource = _fonts.Values.FirstOrDefault();
}
private void Font_Cmbx_SelectionChanged(object sender, SelectionChangedEventArgs e) {
var selectedfont = Font_Cmbx.SelectedItem as string;
string str = selectedfont;
switch(str) {
case "Fett":
MessageBox.Show("Fett");
break;
case "Tornillo":
MessageBox.Show("Tornillo");
break;
case "Audacieux":
MessageBox.Show("Audacieux");
break;
default:
MessageBox.Show("Bold");
break;
}
}
private void SystemInfo() {
CultureInfo ci = CultureInfo.InstalledUICulture;
Debug.Print("Default Language Info:");
Debug.Print("* Name: {0}", ci.Name);
Debug.Print("* Display Name: {0}", ci.DisplayName);
Debug.Print("* English Name: {0}", ci.EnglishName);
Debug.Print("* 2-letter ISO Name: {0}", ci.TwoLetterISOLanguageName);
Debug.Print("* 3-letter ISO Name: {0}", ci.ThreeLetterISOLanguageName);
Debug.Print("* 3-letter Win32 API Name: {0}", ci.ThreeLetterWindowsLanguageName);
}
private void GetTypeFaces() {
// Return the typeface collection for the fonts in the selected URI location.
System.Collections.Generic.ICollection<Typeface> typefaces = Fonts.GetTypefaces(@"C:\Windows\Fonts\Arial.ttf");
// Enumerate the typefaces in the collection.
foreach(Typeface face in typefaces) {
// Separate the URI directory source info from the font family name.
string[] familyName = face.FontFamily.Source.Split('#');
// Add the font family name, weight, and style values to the typeface combo box.
Font_Cmbx1.Items.Add(familyName[familyName.Length - 1] + " " + face.Weight);
}
Font_Cmbx1.SelectedIndex = 0;
}
}
}
I tried above code but showin only the english names not system specific names. enter image description here