如何在Inventor Design Automation中使用自定义字体



我正在尝试在生成pdf时使用具有设计自动化功能的自定义字体。根据这个Stackoverflow问题的答案Stackoverflow问题,我将字体文件放在捆绑包的Contents文件夹中,并更改PackageContents.xml以引用Support路径,但我仍然收到来自forge的警告Inventor inner xml: <Warning Message="Cannot create font Helvetica 35 Thin" />

我是不是错过了什么?

我刚刚写了一篇关于这方面的博客文章:https://forge.autodesk.com/blog/use-custom-fonts-design-automation

最重要的是,您可以使用System.Drawing.Text.PrivateFontCollection在打开绘图之前加载自定义字体,这样应该可以正常工作:

public void RunWithArguments(Document doc, NameValueMap map)
{
LogTrace("RunWithArguments called with v7");
string bundlePath = map.Item["_1"] as string;
string contents = System.IO.Path.Combine(bundlePath, @"DaSamplePlugin.bundleContents");
string dwgPath = IO.Path.Combine(contents, "AssetLibraryTest", "CustomFontTest.dwg");
string fontPath = IO.Path.Combine(contents, "AssetLibraryTest", "DancingScript-Regular.ttf");
PrivateFontCollection pfc = new PrivateFontCollection();
pfc.AddFontFile(fontPath);
doc = inventorApplication.Documents.Open(dwgPath, false);
doc.SaveAs("result.pdf", true);
}

最新更新