Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback font support #201

Open
tambet opened this issue Feb 21, 2014 · 13 comments
Open

Fallback font support #201

tambet opened this issue Feb 21, 2014 · 13 comments

Comments

@tambet
Copy link

tambet commented Feb 21, 2014

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 prawnpdf/prawn#103)

@shyamramesh
Copy link

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.

@ramachandranmarimuthu
Copy link

+1

@devongovett
Copy link
Member

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.

@pluswave
Copy link

how about fallback support in browser ? seems font-manager will just works on Node, am I right ?

@devongovett
Copy link
Member

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.

@pluswave
Copy link

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 ?

@vsemozhetbyt
Copy link

+1

Some notes.

  1. Sometimes characters not found in the default or embedded font make all the text scrambled, even simple ASCII chains.
  2. Someteimes if I embed big font (arialuni.ttf) I get completely blank document.

@Blewin
Copy link

Blewin commented Feb 28, 2017

Hey, is there any update on this feature? I need it.

@gubikmic
Copy link

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.

@wentjun
Copy link

wentjun commented May 12, 2020

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?

@wentjun
Copy link

wentjun commented May 13, 2020

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)

@Fliens
Copy link

Fliens commented Nov 14, 2022

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! :)

@piersdeseilligny
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests