From 27a0f350ff26ba752eb17a593bbaad17fbbe71d2 Mon Sep 17 00:00:00 2001 From: Nicolas Pena Date: Wed, 12 Apr 2017 15:05:15 -0400 Subject: Some fixes to the fallback font code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: dsinclair Reviewed-by: Tom Sepez --- core/fpdfapi/font/cpdf_truetypefont.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'core/fpdfapi/font/cpdf_truetypefont.cpp') diff --git a/core/fpdfapi/font/cpdf_truetypefont.cpp b/core/fpdfapi/font/cpdf_truetypefont.cpp index 54e565bfd1..d78a5e0eb2 100644 --- a/core/fpdfapi/font/cpdf_truetypefont.cpp +++ b/core/fpdfapi/font/cpdf_truetypefont.cpp @@ -73,13 +73,11 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { return; int charcode = 0; - for (; charcode < nStartChar; charcode++) { + for (; charcode < nStartChar; charcode++) m_GlyphIndex[charcode] = 0; - } uint16_t nGlyph = charcode - nStartChar + 3; - for (; charcode < 256; charcode++, nGlyph++) { + for (; charcode < 256; charcode++, nGlyph++) m_GlyphIndex[charcode] = nGlyph; - } return; } bool bMSUnicode = FT_UseTTCharmap(m_Font.GetFace(), 3, 1); @@ -108,9 +106,8 @@ void CPDF_TrueTypeFont::LoadGlyphMap() { uint16_t unicode = kPrefix[j] * 256 + charcode; m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), unicode); - if (m_GlyphIndex[charcode]) { + if (m_GlyphIndex[charcode]) break; - } } } else if (m_Encoding.m_Unicodes[charcode]) { if (bMSUnicode) { -- cgit v1.2.3