openhtmltopdf
openhtmltopdf copied to clipboard
SVGs do not use custom fonts included with `useFont(FSSupplier<InputStream> supplier, ...)`
The issue seems to be the font.fontFile != null
check at in PdfRendererBuilder:
if (state._svgImpl != null &&
font.fontFile != null &&
font.usedFor.contains(FSFontUseCase.SVG)) {
try {
state._svgImpl.addFontFile(font.fontFile, font.family, font.weight, font.style);
} catch (IOException | FontFormatException e) {
XRLog.log(Level.WARNING, LogMessageId.LogMessageId1Param.INIT_FONT_COULD_NOT_BE_LOADED, font.fontFile.getPath(), e);
}
}
I'd like for fonts to be usable in SVGs even if they are supplied via input stream (rather than by file).
I think this post might be related to what you're trying to do? (as a workaround) https://stackoverflow.com/questions/11851821/how-i-use-a-custom-font-with-the-batik-svg-library
Could you reopen the issue at https://github.com/openhtmltopdf/openhtmltopdf ?
Thanks for the tip. I'll see how much simpler it is than the hacky workaround that I came up with. And yeah, I'll port this issue over to that repo as well. Nice to see some folks willing and able to maintain this project.