我需要枚举所有已安装字体的postript名称.
例如:
foreach (FontFamily item in FontFamily.Families)
{
listBox1.Items.Add(item.Name);
}
Run Code Online (Sandbox Code Playgroud)
这将只给出实际的字体名称.但我需要找到附言名称.
例如:对于字体"Arial Black" - 1.实际字体名称为"Arial Black"2.PostScript名称为"Arial-Black"
詹姆斯,先谢谢你
编辑:
因此,理想的方法应该是从已安装的字体中读取postscript名称
您可以直接在 PostScript 中执行此操作。执行这个:
%!PS
/FS { findfont exch scalefont setfont } bind def
% gets page boundaries
clippath pathbbox newpath
/var_TopOfPage exch def
/var_RightOfPage exch def
/var_BottomOfPage exch def
/var_LeftOfPage exch def
% helvetica is almost always there
12 /Helvetica FS
0 setgray
% set start position
var_LeftOfPage var_TopOfPage 30 sub moveto
/pos var_TopOfPage 20 sub def
GlobalFontDirectory {
var_LeftOfPage pos moveto
/FontName get 70 string cvs show
/pos pos 20 sub def
pos 0 le {
showpage
/pos var_TopOfPage 20 sub def
} if
} forall
showpage
%%EOF
Run Code Online (Sandbox Code Playgroud)
我已经能够使用此代码找出打印机的可用字体。
我希望我帮助了你。
我也做过类似的事情。您应该知道 FontFamily.Families 可能不是整个可用字体集。
为什么不直接用“-”代替“”呢?
就我而言,我需要转到 PDF 字体名称,对于粗体样式的 Times New Roman 来说,该字体名称必须是“TimesNewRoman,Bold”。
private static string ToPdfFontName(Font f)
{
StringBuilder sb = new StringBuilder();
StripSpaces(sb, f.Name);
if ((f.Style & FontStyle.Bold)!= 0 && (f.Style & FontStyle.Italic)!= 0)
{
sb.Append(",BoldItalic");
}
else if ((f.Style & FontStyle.Bold)!= 0)
{
sb.Append(",Bold");
}
else if ((f.Style & FontStyle.Italic)!= 0)
{
sb.Append(",Italic");
}
return sb.ToString();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2745 次 |
| 最近记录: |