从资源加载basefont

我正在尝试使用ITextSharp并加载插入项目中的字体文件作为资源。

我尝试了不同的解决方案,但它们似乎都不起作用,这里是我所做的一个示例:

这个无法加载资源

private static BaseFont _bfArial; public static BaseFont BfArial { get { if (_bfArial == null) _bfArial = BaseFont.CreateFont(@"Resources\Images\arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED); return _bfArial; } } 

这个给了我一个错误:“’Identity-H’不是受支持的编码名称。”

  private static BaseFont _bfCourier; public static BaseFont BfCourier { get { if (_bfCourier == null) _bfCourier = BaseFont.CreateFont("Courier", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, true, FontsResources.cour, null); return _bfCourier; } } 

这是我在解决方案中添加文件的方式

在此处输入图像描述

你能帮我解决这个问题吗? 谢谢

安德里亚

尝试使用:

 Byte[] fb = Properties.Resources.arialuni; _bfArial = BaseFont.CreateFont("arialuni.ttf", BaseFont.CP1252, BaseFont.EMBEDDED, BaseFont.CACHED, fb, null); 

“属性”出现在解决方案资源管理器中的“GIGPrinting”下,“Properties.Resources”是对resources文件夹的引用。