summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-05-17 14:48:29 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-05-17 19:08:33 +0000
commit17f4e0268b31f2f75a01567b83dbb763680344e1 (patch)
tree3d9a738f0063a68be17d5011949ab255861ff85b /core/fpdfapi/font
parentc559156da52805513e11b1b2a057001b6fa63f90 (diff)
downloadpdfium-17f4e0268b31f2f75a01567b83dbb763680344e1.tar.xz
Reland: 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. Previously, some bots failed with 'unable to open' the .png file. Bug: chromium:665467 Change-Id: I435a73647eadcc3ba37bb0120f3b5cee381ae7a3 Reviewed-on: https://pdfium-review.googlesource.com/5610 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi/font')
-rw-r--r--core/fpdfapi/font/cpdf_truetypefont.cpp40
1 files changed, 18 insertions, 22 deletions
diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp
index d78a5e0eb2..7f4512da05 100644
--- a/core/fpdfapi/font/cpdf_truetypefont.cpp
+++ b/core/fpdfapi/font/cpdf_truetypefont.cpp
@@ -125,28 +125,24 @@ void CPDF_TrueTypeFont::LoadGlyphMap() {
}
}
}
- 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);
- }
- }
- }
+ 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];
}
}
return;