From b332581e185760597e8f0160011b1e6094634ed8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Pe=C3=B1a?= Date: Wed, 17 May 2017 00:14:40 +0000 Subject: Revert "Small fix in CPDF_TrueTypeFont load" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit dde95d8be9bc2817e34429fc38ee6d89d6d5ab75. Reason for revert: the test added is flaky Original change's description: > Small fix in CPDF_TrueTypeFont load > > The ToUnicode map should not be ignored when it exists. Doing so can cause a > charcode to be assigned an incorrect glyph index, and will result in garbled > text. > > Bug: chromium:665467 > Change-Id: I21c1bf560a0731d974191d4189ea730ef9868334 > Reviewed-on: https://pdfium-review.googlesource.com/5512 > Reviewed-by: Lei Zhang > Commit-Queue: Nicolás Peña > TBR=thestig@chromium.org,tsepez@chromium.org,dsinclair@chromium.org,npm@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Bug: chromium:665467 Change-Id: I704a34f326d31018061bcfd857fb25f7e4ee4cc2 Reviewed-on: https://pdfium-review.googlesource.com/5493 Reviewed-by: Nicolás Peña Commit-Queue: Nicolás Peña --- core/fpdfapi/font/cpdf_truetypefont.cpp | 40 ++++---- testing/resources/pixel/bug_665467.in | 93 ------------------ testing/resources/pixel/bug_665467.pdf | 106 --------------------- .../resources/pixel/bug_665467_expected.pdf.0.png | Bin 467 -> 0 bytes .../pixel/bug_665467_expected_mac.pdf.0.png | Bin 509 -> 0 bytes 5 files changed, 22 insertions(+), 217 deletions(-) delete mode 100644 testing/resources/pixel/bug_665467.in delete mode 100644 testing/resources/pixel/bug_665467.pdf delete mode 100644 testing/resources/pixel/bug_665467_expected.pdf.0.png delete mode 100644 testing/resources/pixel/bug_665467_expected_mac.pdf.0.png diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp index 7f4512da05..d78a5e0eb2 100644 --- a/core/fpdfapi/font/cpdf_truetypefont.cpp +++ b/core/fpdfapi/font/cpdf_truetypefont.cpp @@ -125,24 +125,28 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { } } } - if ((m_GlyphIndex[charcode] != 0 && m_GlyphIndex[charcode] != 0xffff) || - !name) { - continue; - } - if (strcmp(name, ".notdef") == 0) { - m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), 32); - continue; - } - m_GlyphIndex[charcode] = - FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); - if (m_GlyphIndex[charcode] != 0 || !bToUnicode) - continue; - - CFX_WideString wsUnicode = UnicodeFromCharCode(charcode); - if (!wsUnicode.IsEmpty()) { - m_GlyphIndex[charcode] = - FXFT_Get_Char_Index(m_Font.GetFace(), wsUnicode[0]); - m_Encoding.m_Unicodes[charcode] = wsUnicode[0]; + if ((m_GlyphIndex[charcode] == 0 || m_GlyphIndex[charcode] == 0xffff) && + name) { + if (name[0] == '.' && strcmp(name, ".notdef") == 0) { + m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), 32); + } else { + m_GlyphIndex[charcode] = + FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); + if (m_GlyphIndex[charcode] == 0) { + if (bToUnicode) { + CFX_WideString wsUnicode = UnicodeFromCharCode(charcode); + if (!wsUnicode.IsEmpty()) { + m_GlyphIndex[charcode] = + FXFT_Get_Char_Index(m_Font.GetFace(), wsUnicode[0]); + m_Encoding.m_Unicodes[charcode] = wsUnicode[0]; + } + } + if (m_GlyphIndex[charcode] == 0) { + m_GlyphIndex[charcode] = + FXFT_Get_Char_Index(m_Font.GetFace(), charcode); + } + } + } } } return; diff --git a/testing/resources/pixel/bug_665467.in b/testing/resources/pixel/bug_665467.in deleted file mode 100644 index 0166ee4c67..0000000000 --- a/testing/resources/pixel/bug_665467.in +++ /dev/null @@ -1,93 +0,0 @@ -{{header}} -{{object 1 0}} -<< - /Type /Catalog - /Pages 2 0 R ->> -{{object 2 0}} -<< - /Type /Pages - /MediaBox [ 0 0 100 100 ] - /Count 1 - /Kids [ 3 0 R ] ->> -endobj -{{object 3 0}} -<< - /Type /Page - /Parent 2 0 R - /Resources - << - /Font << /F1 4 0 R >> - >> - /Contents 9 0 R ->> -endobj -{{object 4 0}} -<< - /Type /Font - /Subtype /TrueType - /BaseFont /ChromeSansMM - /Encoding 6 0 R - /FirstChar 32 - /LastChar 255 - /Name /F1 - /ToUnicode 7 0 R - /FontDescriptor 8 0 R ->> -endobj -{{object 6 0}} -<< - /Differences [ 161 /someunknownname ] - /Type /Encoding ->> -{{object 7 0}} << ->> -stream -/CIDInit /ProcSet findresource begin -12 dict begin -begincmap -/CIDSystemInfo -<> def -/CMapName /Adobe-Identity-H def -CMapType 2 def -1 begincodespacerange -<00> -endcodespacerange -1 beginbfchar - <043B> -endbfchar -endcmap -CMapName currentdict /CMap defineresource pop -end -end -endobj -{{object 8 0}} -<< - << /Ascent 1000 - /CapHeight 0 - /Descent -200 - /Flags 32 - /FontBBox [ -599 -207 1338 1034 ] - /FontName /ChromeSansMM - /ItalicAngle 0 - /StemV 0 - /Type /FontDescriptor ->> -{{object 9 0}} << ->> -stream -BT -50 50 Td /F1 15 Tf Tj -ET -endstream -endobj -{{xref}} -trailer << - /Root 1 0 R ->> -{{startxref}} -%%EOF diff --git a/testing/resources/pixel/bug_665467.pdf b/testing/resources/pixel/bug_665467.pdf deleted file mode 100644 index e0ec6ea28d..0000000000 --- a/testing/resources/pixel/bug_665467.pdf +++ /dev/null @@ -1,106 +0,0 @@ -%PDF-1.7 -% ò¤ô -1 0 obj -<< - /Type /Catalog - /Pages 2 0 R ->> -2 0 obj -<< - /Type /Pages - /MediaBox [ 0 0 100 100 ] - /Count 1 - /Kids [ 3 0 R ] ->> -endobj -3 0 obj -<< - /Type /Page - /Parent 2 0 R - /Resources - << - /Font << /F1 4 0 R >> - >> - /Contents 9 0 R ->> -endobj -4 0 obj -<< - /Type /Font - /Subtype /TrueType - /BaseFont /ChromeSansMM - /Encoding 6 0 R - /FirstChar 32 - /LastChar 255 - /Name /F1 - /ToUnicode 7 0 R - /FontDescriptor 8 0 R ->> -endobj -6 0 obj -<< - /Differences [ 161 /someunknownname ] - /Type /Encoding ->> -7 0 obj << ->> -stream -/CIDInit /ProcSet findresource begin -12 dict begin -begincmap -/CIDSystemInfo -<> def -/CMapName /Adobe-Identity-H def -CMapType 2 def -1 begincodespacerange -<00> -endcodespacerange -1 beginbfchar - <043B> -endbfchar -endcmap -CMapName currentdict /CMap defineresource pop -end -end -endobj -8 0 obj -<< - << /Ascent 1000 - /CapHeight 0 - /Descent -200 - /Flags 32 - /FontBBox [ -599 -207 1338 1034 ] - /FontName /ChromeSansMM - /ItalicAngle 0 - /StemV 0 - /Type /FontDescriptor ->> -9 0 obj << ->> -stream -BT -50 50 Td /F1 15 Tf Tj -ET -endstream -endobj -xref -0 10 -0000000000 65535 f -0000000015 00000 n -0000000061 00000 n -0000000154 00000 n -0000000272 00000 n -0000000000 65535 f -0000000459 00000 n -0000000531 00000 n -0000000892 00000 n -0000001081 00000 n -trailer << - /Root 1 0 R ->> -startxref -1152 -%%EOF diff --git a/testing/resources/pixel/bug_665467_expected.pdf.0.png b/testing/resources/pixel/bug_665467_expected.pdf.0.png deleted file mode 100644 index 617cb0a916..0000000000 Binary files a/testing/resources/pixel/bug_665467_expected.pdf.0.png and /dev/null differ diff --git a/testing/resources/pixel/bug_665467_expected_mac.pdf.0.png b/testing/resources/pixel/bug_665467_expected_mac.pdf.0.png deleted file mode 100644 index 9f51dcb855..0000000000 Binary files a/testing/resources/pixel/bug_665467_expected_mac.pdf.0.png and /dev/null differ -- cgit v1.2.3