Why does PDFium bundle Freetype instead of using the system library?

253 views
Skip to first unread message

John Abd-El-Malek

unread,
Dec 12, 2014, 6:04:47 PM12/12/14
to pdf...@googlegroups.com
I'm looking into merging pdfium into the chromium binary (to save shipping multiple copies of V8). I'm getting multiple definitions of all the freetype functions. It also seems wasteful binary-size wise to ship it instead of using the system one. Are there modifications to it that are done?
Thanks

bo_xu

unread,
Dec 12, 2014, 6:26:12 PM12/12/14
to pdf...@googlegroups.com
There is an issue regarding freetype: https://code.google.com/p/chromium/issues/detail?id=407341

John Abd-El-Malek

unread,
Dec 12, 2014, 7:21:16 PM12/12/14
to bo_xu, pdf...@googlegroups.com
I think you mean https://code.google.com/p/chromium/issues/detail?id=375598? (didn't know about it, just found it by searching).

However, the bug doesn't answer my question. Can someone from Foxit enlighten me?

I'm also confused why there are two foxitnames.h files.

--
You received this message because you are subscribed to the Google Groups "pdfium" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pdfium+un...@googlegroups.com.
To post to this group, send email to pdf...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pdfium/80762297-1674-452e-9d88-ee11ff0df116%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Abd-El-Malek

unread,
Jan 12, 2015, 6:11:01 PM1/12/15
to bo_xu, pdf...@googlegroups.com
ping :)

I now see that 407341 led to updating the version of FreeType. I'm wondering why we don't just use the system one?

Bo Xu

unread,
Jan 12, 2015, 6:37:44 PM1/12/15
to John Abd-El-Malek, pdf...@googlegroups.com

From https://code.google.com/p/chromium/issues/detail?id=407341#c18 and https://code.google.com/p/chromium/issues/detail?id=407341#c20

 

It looks like the copy in chromium is also old and not maintained?

 

Bo

John Abd-El-Malek

unread,
Jan 13, 2015, 12:23:17 PM1/13/15
to Bo Xu, pdf...@googlegroups.com
I'm not talking about using the one in chromium (that is only for testing purposes, so that when running Blink pixel tests the results look the same on any version of Linux even though they may have different versions of FreeType and thus produce slightly different rendering). Chrome itself uses the system FreeType.

I'm wondering why PDFium bundles a version of FreeType instead of using the system one.

John Abd-El-Malek

unread,
Jan 13, 2015, 12:23:40 PM1/13/15
to Bo Xu, pdf...@googlegroups.com
On Tue, Jan 13, 2015 at 9:23 AM, John Abd-El-Malek <j...@chromium.org> wrote:
I'm not talking about using the one in chromium (that is only for testing purposes, so that when running Blink pixel tests the results look the same on any version of Linux even though they may have different versions of FreeType and thus produce slightly different rendering). Chrome itself uses the system FreeType.

I'm wondering why PDFium bundles a version of FreeType (independent of whether it's located in chromium or pdfium repo) instead of using the system one.

John Abd-El-Malek

unread,
Jan 13, 2015, 2:10:30 PM1/13/15
to Bo Xu, pdf...@googlegroups.com
Here's a quick cl to demonstrate: https://codereview.chromium.org/826613004 (to make the changes easy to see, I didn't change GN or delete the freetype files). It saves about 400KB in the size of the (release) binary. More importantly, it avoids having to maintain a copy of FreeType in PDFium, and having to keep aware of security fixes so we can update it.

The one question I have is wrt to the FXFT_Get_Face_Internal_Flag/FXFT_Set_Face_Internal_Flag methods. They modify  the internal transform_flags value which is a cache about the transformation. Why was that done? From my reading of the code, it seems like it's erroneous?

bo_xu

unread,
Jan 13, 2015, 2:16:39 PM1/13/15
to pdf...@googlegroups.com, bo...@foxitsoftware.com
I see. I will ask our developers for more details.

It existed before because we have some bug fixes in it. With the update, I don't think that's an issue  though. So hopefully it could be get rid of.

To post to this group, send email to pd...@googlegroups.com.

kai_jing

unread,
Jan 13, 2015, 2:20:15 PM1/13/15
to John Abd-El-Malek, Bo Xu, pdf...@googlegroups.com
Hi John,

Eventually we will use system FreeType. Right now, Foxit uses subset of FreeType, and every time we need to change two files in order to make it work with Foxit current code. As long as we will figure out how to get ride of that two changes, we will move to your direction to use system FreeType. We will keep your posted.

Regards,
Kai

John Abd-El-Malek

unread,
Jan 13, 2015, 2:28:03 PM1/13/15
to kai_jing, Bo Xu, pdf...@googlegroups.com
Hi Kai, thanks for the info.

On Tue, Jan 13, 2015 at 11:18 AM, kai_jing <kai_...@foxitsoftware.com> wrote:
Hi John,

Eventually we will use system FreeType. Right now, Foxit uses subset of FreeType, and every time we need to change two files in order to make it work with Foxit current code.

Can you expand on this some more? Which two files are you referring to, and what are the changes?

I can understand that on some platforms, especially embedded ones, Foxit can't make the assumption that FreeType is installed. But for Chromium's use case, we know that FreeType is always there (or else Chrome itself wouldn't work).

I guess we also have to check with Android team who also consumes FreeType. If FreeType isn't installed on Android, then we can have a mode that either uses system or bundled FreeType (similar to what Skia does).

kai_jing

unread,
Jan 13, 2015, 4:24:22 PM1/13/15
to John Abd-El-Malek, Bo Xu, pdf...@googlegroups.com
Hi John,

The two files needs to be changed:

third_party/freetype/include/config/ftmodule.h

third_party/freetype/include/config/ftoption.h


Here is the last update diff:


Regards,
Kai
From: John Abd-El-Malek <j...@chromium.org>
Date: Tuesday, January 13, 2015 at 11:28 AM
To: kai jing <kai_...@foxitsoftware.com>
Cc: Bo Xu <bo...@foxitsoftware.com>, "pdf...@googlegroups.com" <pdf...@googlegroups.com>

John Abd-El-Malek

unread,
Jan 13, 2015, 11:54:46 PM1/13/15
to kai_jing, Bo Xu, pdf...@googlegroups.com
On Tue, Jan 13, 2015 at 1:22 PM, kai_jing <kai_...@foxitsoftware.com> wrote:
Hi John,

The two files needs to be changed:

third_party/freetype/include/config/ftmodule.h


The changes here appear to remove some modules of FreeType that aren't used, presumably as a size optimization. However this only makes sense when building FreeType to bundle with a project.

third_party/freetype/include/config/ftoption.h


This enables subpixel rendering. On Ubuntu, which I just checked, this is also enabled.

Then there are a few ifdefs to disable some features, presumably for size reasons because they're not used. These are enabled in Ubuntu. I didn't check other distributions, but I would presume they would keep them enabled, which is harmless. Even if they don't, it would match the version bundled with PDFium now so it's irrelevant.

Lastly, there's T_CONFIG_OPTION_BDF. Why did Foxit increase that from the default of 256 to 512?

kai_jing

unread,
Jan 14, 2015, 6:09:52 PM1/14/15
to John Abd-El-Malek, Bo Xu, pdf...@googlegroups.com
Hi John,

T1_MAX_CHARSTRINGS_OPERANDS” define the charstring stack’s capacity. Usually 256 will be fine. But some font in PDF, for instance, Goundy Font need more.
So we need to use 512.

Regards,
Kai

John Abd-El-Malek

unread,
Jan 15, 2015, 12:31:22 PM1/15/15
to kai_jing, Bo Xu, pdf...@googlegroups.com
On Wed, Jan 14, 2015 at 3:09 PM, kai_jing <kai_...@foxitsoftware.com> wrote:
Hi John,

T1_MAX_CHARSTRINGS_OPERANDS” define the charstring stack’s capacity. Usually 256 will be fine. But some font in PDF, for instance, Goundy Font need more.
So we need to use 512.

Do you have any example PDFs that 256 breaks? I'm curious what it looks like.

Also, presumably any application that uses FreeType on Linux will hit these same limits.
Reply all
Reply to author
Forward
0 new messages