Skip to content

Page::insertFont() - possible to only insert font data for characters in use? #855

Answered by JorjMcKie
cuteufo asked this question in Q&A
Discussion options

You must be logged in to vote

An interesting question!
Your observation is correct: if inserting text the complete fontfile is included in the PDF, which can be big. The reason is that PyMuPDF does not know, which characters you intend to use.
There are ways to build font subsets, and there also are Python packages that let you do this.

If you use an office software like LibreOffice or Word, they do font subsetting internally, when you export a document to PDF. So the resulting file will be relatively small and depend on the total set of characters you ever used in the Word document.
And here comes the difference to using PyMuPDF: it does not and cannot know this!

I have been experimenting:

  • Before actually inserting …

Replies: 13 comments 15 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by cuteufo
Comment options

You must be logged in to vote
1 reply
@JorjMcKie
Comment options

Comment options

You must be logged in to vote
1 reply
@cuteufo
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@cuteufo
Comment options

Comment options

You must be logged in to vote
5 replies
@cuteufo
Comment options

@JorjMcKie
Comment options

@cuteufo
Comment options

@JorjMcKie
Comment options

@cuteufo
Comment options

Comment options

You must be logged in to vote
1 reply
@JorjMcKie
Comment options

Comment options

You must be logged in to vote
1 reply
@cuteufo
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@cuteufo
Comment options

@JorjMcKie
Comment options

@cuteufo
Comment options

@JorjMcKie
Comment options

@JorjMcKie
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #854 on January 22, 2021 08:07.