I have wrote some code to get the Font name out of ttf file. But when it run on English-windows OS, all the Japanese font return its name in English Ex: instead of <リュウミン>. I would like to get the the font name in Japanese when i run the program on my English-windows OS. If you can give some advice, i will be appreciated!
I searched for System.Globalization namespace but it gets me no-where.
private void getFile_Click(object sender, EventArgs e)
{
fontFilePath.Text = openFolder();
}
private void print_Click(object sender, EventArgs e)
{
StringBuilder strb = new StringBuilder();
DirectoryInfo d = new DirectoryInfo(fontFilePath.Text);
//convert to jp
//System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("ja-JP", true);
//culture. = new System.Globalization.JapaneseCalendar();
FileInfo[] fil = d.GetFiles();
foreach (FileInfo _fil in fil)
{
PrivateFontCollection fonts = new PrivateFontCollection();
fonts.AddFontFile(_fil.FullName);
try { strb.Append(fonts.Families[0].Name).AppendLine(); }
catch (Exception ex) { }
}
FileStream fs = new FileStream(System.IO.Directory.GetCurrentDirectory() + "/path.txt" , FileMode.Create, FileAccess.ReadWrite);
StreamWriter strw = new StreamWriter(fs);
strw.Write(strb);
strw.Close();
strb.Clear();
}
private string openFolder()
{
FolderBrowserDialog fol = new FolderBrowserDialog();
if (fol.ShowDialog() == DialogResult.OK)
{
string folName = fol.SelectedPath;
return folName;
}
else
return "";
}