[poppler] [PATCH]

Stefan Thomas thomas at txtbear.com
Fri Apr 30 05:51:37 PDT 2010


Hey folks,

Got a quick patch. The GfxFont parses the FontWeight as per the PDF 
Specification, allowing only certain discrete values and raising an 
error otherwise. We've encountered PDFs in the wild that don't adhere to 
the standard. Acroread seems to handle the case gracefully, falling back 
to the nearest valid font weight. Poppler raises an error and ignores 
the FontWeight property altogether.

This patch adds the same graceful handling to Poppler. I don't see a 
reason not to allow non-standard font weights. Poppler is a renderer, 
not a validator. If we can handle this case gracefully and transparently 
to the user, we should.

However, one could make an argument for adding a basic bounds check for 
values outside of 50-950 or so. Personally I'm from the school of trying 
to handle problems as locally as possible, but if a PDF has a font 
weight with nonsensical values, perhaps that would be better handled 
with an error. We opted to go without the bounds check for simplicity, 
but it would be easy enough to add:

if (obj2.getNum() < 50 || obj2.getNum() > 950) error(-1, "Invalid Font 
Weight");
else if (obj2.getNum() <= 150) weight = W100;
[..etc..]

Cheers,

Stefan Thomas
CTO

TxtBear AG Switzerland | www.txtbear.com | thomas at txtbear.com
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Changed-GfxFont-to-accept-non-standard-font-sizes.patch
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20100430/2920527d/attachment.txt>


More information about the poppler mailing list