[poppler] [PATCH]

Albert Astals Cid aacid at kde.org
Sat May 29 06:05:14 PDT 2010


A Divendres, 30 d'abril de 2010, Albert Astals Cid va escriure:
> A Divendres, 30 d'abril de 2010, Stefan Thomas va escriure:
> > 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..]
> 
> Is there any chance we can get such a PDF?

I've been playing with Acrobat and could not find a way that confirms what 
happens if i use a FontWeight of 1000, does it use 900 that is the closes 
valid value or does it use a default one?

Whithout any real reason (e.g. Acrobat does it) i see no reason to change our 
implementation.

Albert

> 
> Albert
> 
> > Cheers,
> > 
> > Stefan Thomas
> > CTO
> > 
> > TxtBear AG Switzerland | www.txtbear.com | thomas at txtbear.com
> 
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/poppler


More information about the poppler mailing list