Bug 484601 - Okular should not (by default) embed the ENTIRE font file into the saved PDF document when Typewriter annotations are added.
Summary: Okular should not (by default) embed the ENTIRE font file into the saved PDF ...
Status: REPORTED
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: 24.02.1
Platform: Flatpak Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-27 13:58 UTC by 林博仁(Buo-ren, Lin)
Modified: 2024-03-28 05:16 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Size differences between the original document and the one with the typewriter annotations (29.25 KB, image/png)
2024-03-27 13:58 UTC, 林博仁(Buo-ren, Lin)
Details
The screenshot of the Fonts tab of the PDF properties dialog (84.20 KB, image/png)
2024-03-27 13:59 UTC, 林博仁(Buo-ren, Lin)
Details
The source HTML document used to produce the POC.orig.pdf (the file is generated using the output as PDF function of the print dialog of the web browser) (258 bytes, text/html)
2024-03-27 14:45 UTC, 林博仁(Buo-ren, Lin)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description 林博仁(Buo-ren, Lin) 2024-03-27 13:58:34 UTC
Created attachment 167846 [details]
Size differences between the original document and the one with the typewriter annotations

SUMMARY

I was going to sign a PDF document using Okular but found that after signing it using the Typewriter annotations feature the resulting PDF document's file size becomes >15MiB.  It turns out that Okular embeds the ENTIRE font file of the Chinese font I'm using but not a subset of it required by the annotation text itself, making the resulting file size 260x than the original.

This is a serious problem as:

* The resulting file will likely no longer be attachable to an e-mail due to the oversized file.
* The resulting file may no longer be legally distributed as it may violate the license of the embedded font(only subset distribution of the glyphs is allowed).

STEPS TO REPRODUCE
1. Open a PDF document, and note the original file size of the file.
2. Add a Typewriter annotation that consists of characters that can only be rendered by a big-scaled font (e.g. Chinese by "Noto Sans CJK").
3. Save the PDF document.

OBSERVED RESULT

The entire Chinese font(instead of its subset) is embedded in the document(as per the attached screenshot).

EXPECTED RESULT

Okular should embed the subset of the font required to render the Typewriter annotations by default, or at least provide an option to opt-off the current behavior.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Okular 24.02.1 Flatpak @ Ubuntu 23.10 Desktop
(available in About System)
KDE Plasma Version: 5.27.8
KDE Frameworks Version: Flatpak: 6.0.0 @ Host: 5.110.0
Qt Version: Flatpak: 6.6.2 @ Host: 5.15.10

ADDITIONAL INFORMATION

Use [the Static Super-OTC variant of the Noto Sans CJK font](https://github.com/notofonts/noto-cjk/releases/download/Sans2.004/00_NotoSansCJK.ttc.zip) creates a PDF document that is 1233x of the original file's size.
Comment 1 林博仁(Buo-ren, Lin) 2024-03-27 13:59:06 UTC
Created attachment 167847 [details]
The screenshot of the Fonts tab of the PDF properties dialog
Comment 2 林博仁(Buo-ren, Lin) 2024-03-27 14:45:44 UTC
Created attachment 167851 [details]
The source HTML document used to produce the POC.orig.pdf (the file is generated using the output as PDF function of the print dialog of the web browser)
Comment 3 林博仁(Buo-ren, Lin) 2024-03-28 05:16:34 UTC
(In reply to 林博仁(Buo-ren, Lin) from comment #0)
> Use [the Static Super-OTC variant of the Noto Sans CJK
> font](https://github.com/notofonts/noto-cjk/releases/download/Sans2.004/
> 00_NotoSansCJK.ttc.zip) creates a PDF document that is 1233x of the original
> file's size.

Which is ~91.1MiB to be specific, which is NOT a reasonable file size for a single-page PDF document that contains only 2 glyphs of the Chinese characters.