Open tambet opened 10 years ago
Need a provision in pdfkit to set a substitution font like (arial unicode) so that glyphs get substituted when it is not present in primary font .This is an important requirement to avoid text disappearing in final pdf for lack of glyph.
+1
I'm working on it. The new font system that I'm developing will use my new font-manager module to get font fallback information from the OS automatically.
how about fallback support in browser ? seems font-manager will just works on Node, am I right ?
Yes, font-manager is for Node. For the browser, we'll have to include a set of fallback font data. The problem is that the data will make PDFKit HUGE. Not sure what the best thing to do is.
Can we have a mechanism that, user can customize pdfkit to use fallback fonts (and user can select font files), but by default, don't use it ?
+1
Some notes.
Hey, is there any update on this feature? I need it.
Doesn't PDF allow to have text without any embedded fonts and then it's up to the rendering program or OS to select a default font?
It would be great if that was an option. Then instead of saying document.font('Helvetica')
you could leave the default and for Chinese, Korean, Japanese, Greek, Russian, etc. you'd still get readable PDFs.
Has anyone managed to figure out a good strategy to allow fallback fonts?
Been having some trouble rendering such sentences which consists of a combination of various languages (Vietnamese, and Chinese):
doc
.fontSize(12)
.font('Semibold')
.text('Hanoi Hotel, Trần Huy Liệu, Giang Vo,巴亭郡河内越南', 166, 468, {
width: 370,
})
If not, how exactly can we make this work with the font-manager
package?
Ok, just an update, I decide to use [arial unicode] for the pdf generation instead of the project's main font (which uses PingFang SC). It wasn't ideal, but arial unicode was a good compromise as it supports a variety of languages which is perfect for internationalisation. (https://catalog.monotype.com/family/monotype/arial-unicode)
I found a workaround!
Follow these instructions (You might have to use the 10 day trial | or use opensource FontForge but that did not work that good)
With these steps you can merge multiple fonts so there is no need for a fallback font. Works pretty good! :)
This has been an issue for the past 9 years, and it makes developing language-inclusive software with PDFKit really difficult. For a lot of situations, the solutions and workarounds in this thread really don't help, they only help if you know exactly what fonts your users will need/want and what text they're going to be writing.
I'm going to be too busy over the next few months to look into it, but could someone more familiar with pdfkit suggest what a a correct way of doing this would be? Just so we have an idea of how complex it would be, and so that potential contributors know where to start looking.
A basic implementation could even ignore system font fallback, and only look for fallback glyphs amongst user-supplied and specified fonts.
When a glyph does not exist in the primary font, it should look in a list of other candidate fonts to find it (like in prawn, see https://github.com/prawnpdf/prawn/issues/103)