Ojas Maheshwari's Blog Site

Week 4 + Week 5 GSoC update | Almost had a heart attack

07 July, 2026

Ok, the title is slightly click-baity but hear me out.

So nearly 2 weeks ago, after writing a lot of code for making the font subsetting work for annotations, I found a flaw in my approach.

I was never deleting the old original font after embedding it's subset version.

So what happened is that:

This is actually slightly worse than when we had no subsetting at all.

So the solution should just be to delete the original font right? Nope

If we simply delete the original font, it would create the following problem:

When I realized this, I thought I would need to completely change how I do subsetting, and almost all the code I had written will go to waste.

My new idea was to never let the full version of a font to exist inside the PDF. What I mean is subsetting immediately when the font is loaded from the disk and is about to be embedded as a Font object.

But I had a meeting with my mentor Albert Astals Cid yesterday, and we decided to settle on a simpler approach. We can simply detect if the font we want to delete is:- a font we added ourselves or a pre-existing font inside the PDF.

If we added it ourselves, we can safely remove it. Otherwise, let it stay there as it might be in use by other annotations.

I implemented it today, and we have working font subsetting for freetext annotations right now (not merged).
https://gitlab.freedesktop.org/poppler/poppler/-/merge_requests/2220

A simple size experiment

Here's a simple experiment which demonstrates the impact of font subsetting on PDF file size:

Original file size: 105820 bytes = 105.82 KB

After adding an annotation with content "hello world":

Poppler without font subsetting: 504699 bytes = 504.699 KB

Poppler with font subsetting: 145806 bytes = 145.806 KB

That's like a 500% improvement...

What's next

Thank You

Good Night!