summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/font')
-rw-r--r--core/fpdfapi/font/cpdf_font.cpp7
-rw-r--r--core/fpdfapi/font/cpdf_simplefont.cpp7
-rw-r--r--core/fpdfapi/font/cpdf_truetypefont.cpp9
3 files changed, 13 insertions, 10 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;
}
diff --git a/core/fpdfapi/font/cpdf_simplefont.cpp b/core/fpdfapi/font/cpdf_simplefont.cpp
index a3597824bd..cb8f00a98a 100644
--- a/core/fpdfapi/font/cpdf_simplefont.cpp
+++ b/core/fpdfapi/font/cpdf_simplefont.cpp
@@ -29,8 +29,11 @@ int CPDF_SimpleFont::GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) {
if (charcode > 0xff)
return -1;
- int index = m_GlyphIndex[(uint8_t)charcode];
- return index != 0xffff ? index : -1;
+ int index = m_GlyphIndex[charcode];
+ if (index == 0xffff || (index == 0 && IsTrueTypeFont()))
+ return -1;
+
+ return index;
}
void CPDF_SimpleFont::LoadCharMetrics(int charcode) {
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) {