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

Embed only used characters? #22

Open
phmarek opened this issue Feb 14, 2021 · 5 comments
Open

Embed only used characters? #22

phmarek opened this issue Feb 14, 2021 · 5 comments

Comments

@phmarek
Copy link
Contributor

phmarek commented Feb 14, 2021

Hi,

is there a way to embed only these parts of fonts that are really used?
I need two Truetype fonts, but the current behaviour adds about 210kB of unneeded glyphs to the PDF - making generating it slower as well.

@erikronstrom
Copy link

There is currently no support for font subsetting, unfortunately. I've just recently been thinking about how this could be achieved but PDF is a hairy business and I'm just a beginner in that field. (And I'm not involved in cl-pdf)

I would be willing to put some time on this but it would perhaps need to be some kind of collaborative effort because I have too little experience of PDF internals.

@erikronstrom
Copy link

Two more things:

  1. It seems that adding TrueType fonts to cl-pdf always makes it write a CID font which takes a lot of space. This could be optimized away in many cases I believe.

  2. On Windows I would love to be able to embed fonts using the Windows Font Embedding API! That way you could embed (almost) any font available in the system without having to know where its font file resides (which is not generally possible). In LispWorks I have managed to call TTEmbedFont using FLI and thereby retrieving the glyph data for fonts, but I haven't figured out how to insert that into the PDF stream. As I wrote above, I would be willing to implement this if I could just get some general guidance on how to proceed (from someone with better insights in the inner workings of the PDF format)!

@erikronstrom
Copy link

BTW, if you just need a quick solution for a specific case, you can make subsetted versions of the fonts and load those into cl-pdf. Have a look at pyftsubset for instance: https://fonttools.readthedocs.io/en/latest/subset/index.html

@phmarek
Copy link
Contributor Author

phmarek commented Apr 12, 2021

On Windows I would love to be able to embed fonts using the Windows Font Embedding API!

Well, that wouldn't help me here ;)

BTW, if you just need a quick solution for a specific case, you can make subsetted versions of the fonts and load those into cl-pdf.
Yeah, I used fontforge for that.

@erikronstrom
Copy link

One way to go could be to extend zpb-ttf so that it can perform subsetting of entire fonts. I looked into it yesterday and I think it would be doable albeit non-trivial and probably requiring quite some effort.

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

No branches or pull requests

2 participants