openhtmltopdf icon indicating copy to clipboard operation
openhtmltopdf copied to clipboard

SVGs do not use custom fonts included with `useFont(FSSupplier<InputStream> supplier, ...)`

Open zford-reitz opened this issue 1 year ago • 2 comments

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).

zford-reitz avatar Jul 21 '23 14:07 zford-reitz

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 ?

siegelzc avatar Mar 10 '24 16:03 siegelzc

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.

zford-reitz avatar Apr 12 '24 15:04 zford-reitz