我写了一些代码来从ttf文件中获取字体名称。但是,当它在英语-Windows操作系统上运行时,所有日语字体都会以英语返回其名称。 例如:代替<リュウミン>。 当我在英文Windows操作系统上运行程序时,我想获得日语的字体名称。 如果您可以提供一些建议,我将不胜感激!
我搜索了System.Globalization命名空间,但是却无处可寻。
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 "";
}