From 6a74dbe996326d042da8979847a8a5357aca0978 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 31 Aug 2009 20:41:57 -0400 Subject: [PATCH] Maintain Type0 fonts when using embedded font type When font types do not match the type of an embedded font, we use the type of the embedded font. However, we need to avoid switching from a CID type to a non-CID type. Otherwise, future processing will assuming the font has class Gfx8BitFont and crash. Fixes #17252. Signed-off-by: David Benjamin --- poppler/GfxFont.cc | 37 +++++++++++++++++++++++++++++++------ 1 files changed, 31 insertions(+), 6 deletions(-) diff --git a/poppler/GfxFont.cc b/poppler/GfxFont.cc index 02af312..dc0521c 100644 --- a/poppler/GfxFont.cc +++ b/poppler/GfxFont.cc @@ -272,7 +272,12 @@ void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { embFontID = obj2.getRef(); if (type != fontType1) { error(-1, "Mismatch between font type and embedded font file"); - type = fontType1; + if (isCIDFont()) { + error(-1, "CID font has FontFile attribute; assuming CIDType0"); + type = fontCIDType0; + } else { + type = fontType1; + } } } obj2.free(); @@ -281,7 +286,7 @@ void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { embFontID = obj2.getRef(); if (type != fontTrueType && type != fontCIDType2) { error(-1, "Mismatch between font type and embedded font file"); - type = type == fontCIDType0 ? fontCIDType2 : fontTrueType; + type = isCIDFont() ? fontCIDType2 : fontTrueType; } } obj2.free(); @@ -293,26 +298,46 @@ void GfxFont::readFontDescriptor(XRef *xref, Dict *fontDict) { embFontID = obj2.getRef(); if (type != fontType1) { error(-1, "Mismatch between font type and embedded font file"); - type = fontType1; + if (isCIDFont()) { + error(-1, "Embedded CID font has type Type1; assuming CIDType0"); + type = fontCIDType0; + } else { + type = fontType1; + } } } else if (obj4.isName("Type1C")) { embFontID = obj2.getRef(); if (type != fontType1 && type != fontType1C) { error(-1, "Mismatch between font type and embedded font file"); } - type = fontType1C; + if (isCIDFont()) { + error(-1, "Embedded CID font has type Type1C; assuming CIDType0C"); + type = fontCIDType0C; + } else { + type = fontType1C; + } } else if (obj4.isName("TrueType")) { embFontID = obj2.getRef(); if (type != fontTrueType) { error(-1, "Mismatch between font type and embedded font file"); - type = fontTrueType; + if (isCIDFont()) { + error(-1, "Embedded CID font has type TrueType; assuming CIDType2"); + type = fontCIDType2; + } else { + type = fontTrueType; + } } } else if (obj4.isName("CIDFontType0C")) { embFontID = obj2.getRef(); if (type != fontCIDType0) { error(-1, "Mismatch between font type and embedded font file"); } - type = fontCIDType0C; + if (isCIDFont()) { + type = fontCIDType0C; + } else { + error(-1, "Embedded non-CID font has type CIDFontType0c; assuming Type1C"); + type = fontType1C; + } } else if (obj4.isName("OpenType")) { embFontID = obj2.getRef(); if (type == fontTrueType) { -- 1.6.0.4