问题
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