summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font/cpdf_font.cpp
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-04-12 15:05:15 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-12 19:52:00 +0000
commit27a0f350ff26ba752eb17a593bbaad17fbbe71d2 (patch)
tree48996b61ff35c5621b7658e8e73a655f6dc8c010 /core/fpdfapi/font/cpdf_font.cpp
parent94c34c9934bf93fc68d0ab0bb0c6696ce71b6441 (diff)
downloadpdfium-27a0f350ff26ba752eb17a593bbaad17fbbe71d2.tar.xz
Some fixes to the fallback font code.
This CL applies several fixes to the fallback font code. - PDFium uses -1 to indicate that no glyph index was found, but freetype uses 0. In CPDF_TrueTypeFont, an index of 0 indicates a freetype failure, which means we should try to find the glyph from a fallback font. - Improve the fallback glyph calculation by going from original font charcode to unicode to fallback font charcode. - Consider the m_ExtGID on Mac when deciding the fallback. Bug: chromium:665467 Change-Id: I2be34983e0d768d9a598043f84edd2d70f033c86 Reviewed-on: https://pdfium-review.googlesource.com/4055 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/font/cpdf_font.cpp')
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/fpdfapi/font/cpdf_font.cpp b/core/fpdfapi/font/cpdf_font.cpp
index a6a661b328..b9be3aa868 100644
--- a/core/fpdfapi/font/cpdf_font.cpp
+++ b/core/fpdfapi/font/cpdf_font.cpp
@@ -457,9 +457,12 @@ int CPDF_Font::FallbackGlyphFromCharcode(int fallbackFont, uint32_t charcode) {
if (!pdfium::IndexInBounds(m_FontFallbacks, fallbackFont))
return -1;
+ CFX_WideString str = UnicodeFromCharCode(charcode);
+ uint32_t unicode = !str.IsEmpty() ? str.GetAt(0) : charcode;
int glyph =
- FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), charcode);
- if (glyph == 0 || glyph == 0xffff)
+ FXFT_Get_Char_Index(m_FontFallbacks[fallbackFont]->GetFace(), unicode);
+ if (glyph == 0)
return -1;
+
return glyph;
}