-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
Support font subsetting to reduce size of pdf #103
Comments
In order to reduce the size of the pdf, This is when a pdf contains a special "made up" font that contains only those characters that are actually used in the document. So for instance, if you created a pdf containing only the text "Hello World" you would find a font inside the pdf that only contains the characters H, e, l, o, W, r and d. Font subsetting is currently not supported in Kind regards, |
Thanks for your reply! Font subsetting is such an important feature for languages with large character sets. Hope that |
@jorisschellekens As you use fonttools, subsetting TrueType fonts by using fonttools is simple, just see this example. https://github.com/orklann/caprice/blob/main/caprice/font/truetype/font.py#L89 For none Latin TrueType fonts, subsetting is a important feature, since fonts in this category are always large in size. |
I think I may have found a way to do this. Both of these files were created with |
✔️ According to the PDF validator I use (vera pdf), my output is a valid PDF. Next I want to try it with your particular font and code, and see whether the results still hold. Kind regards, |
Turns out I already had a test using
I'm also going to attach the subset version of that PDF to this ticket, so you can verify for yourself. That means this feature will be included in the next release 📣 Kind regards, |
These two PDFs looks different using Preview (the default PDF viewer) on macOS 12.4. output_without_subsetting.pdf output_with_subsetting.pdf It might not be the expected behaviour. |
The attached PDF is blank opening by Preview (the default PDF viewer) on macOS 12.4. However, you said that you added "你好世界" in this PDF. It might not be the expected behavior. |
That is definitely not the expected behaviour. It's using a substitute font (so it's claiming that it can't find the font file inside the PDF) Can you open it in Adobe? |
It seems that certain standards of PDF are not satisfied. |
After having discussed this issue with another PDF expert, it seems like the actual subsetting of the font (rather than the dictionaries in the PDF) is going awry. Sadly, that makes this problem a bit trickier. Currently I use |
Describe the bug
I want to add Chinese and Japanese in PDF. I did present Chinese and Japanese characters (は哈) successfully, but the size of
output.pdf
is too large (14MB).I read the example doc and found the chapter 8.6.2 Composite fonts. I just want to render each character seperately, namely extract the font of a single character and then package these characters in PDF file. How to achieve this using borb? I wonder if there is an exact configuration in borb?
To Reproduce
Steps to reproduce the behaviour:
Download Microsoft Yahei.ttf at https://github.com/dolbydu/font/blob/master/unicode/Microsoft%20Yahei.ttf
Expected behaviour
The size of PDF file should be less than 1MB.
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: