How can I add to the list of font substitutions in pdfbox 2.0.7?

谁都会走 提交于 2020-06-16 17:36:13

问题


I'm using FontMapper.getTrueTypeFont() to find available fonts by name in pdfbox 2.0.7. This has a feature to map fonts (by name) so that if I ask for Symbol and my system only has SymbolMT it will return that as a substitute.

But the default implementation doesn't map the other way. My system has Symbol installed, but if I try to get SymbolMT it returns Helvetica as the best match (which doesn't work very well).

The underlying FontMapperImpl class has an addSubstitute() method that lets you add mappings, but the class is private to the package so I can't call that (even though the method is marked public). The FontMapper interface that FontMapperImpl implements does not include the addSubstitute() method.

In the Cookbook for pdfbox 1.8 there is a reference to using Resources/PDFBox_External_Fonts.properties to add mappings, but this does not seem to be present in pdfbox 2.0.7.

Is there a way to add additional font mappings (by name) in pdfbox 2.0.7, or do I need to build my own mapping layer outside of it? Thanks!

来源:https://stackoverflow.com/questions/47320624/how-can-i-add-to-the-list-of-font-substitutions-in-pdfbox-2-0-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!