diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/font/cpdf_type1font.cpp | 88 | ||||
-rw-r--r-- | core/fxge/cfx_fontmapper.cpp | 25 |
2 files changed, 56 insertions, 57 deletions
diff --git a/core/fpdfapi/font/cpdf_type1font.cpp b/core/fpdfapi/font/cpdf_type1font.cpp index 21d9da42c8..77987bb5dc 100644 --- a/core/fpdfapi/font/cpdf_type1font.cpp +++ b/core/fpdfapi/font/cpdf_type1font.cpp @@ -154,9 +154,9 @@ void CPDF_Type1Font::LoadGlyphMap() { } } FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE); - if (m_BaseEncoding == 0) { + if (m_BaseEncoding == 0) m_BaseEncoding = PDFFONT_ENCODING_STANDARD; - } + for (int charcode = 0; charcode < 256; charcode++) { const char* name = GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode); @@ -193,7 +193,7 @@ void CPDF_Type1Font::LoadGlyphMap() { if (name) { m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); m_GlyphIndex[charcode] = - FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); + FXFT_Get_Name_Index(m_Font.GetFace(), const_cast<char*>(name)); SetExtGID(name, charcode); } else { m_GlyphIndex[charcode] = @@ -208,46 +208,46 @@ void CPDF_Type1Font::LoadGlyphMap() { FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], name_glyph, 256); name_glyph[255] = 0; - if (unicode == 0 && name_glyph[0] != 0) { + if (unicode == 0 && name_glyph[0] != 0) unicode = PDF_UnicodeFromAdobeName(name_glyph); - } + m_Encoding.m_Unicodes[charcode] = unicode; SetExtGID(name_glyph, charcode); } } return; } - bool bUnicode = false; - if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) { - bUnicode = true; - } + + bool bUnicode = + FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE) == 0; for (int charcode = 0; charcode < 256; charcode++) { const char* name = GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode); - if (!name) { + if (!name) continue; - } + m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); const char* pStrUnicode = GlyphNameRemap(name); if (pStrUnicode && - 0 == FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name)) { + FXFT_Get_Name_Index(m_Font.GetFace(), const_cast<char*>(name)) == 0) { name = pStrUnicode; } m_GlyphIndex[charcode] = - FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); + FXFT_Get_Name_Index(m_Font.GetFace(), const_cast<char*>(name)); SetExtGID(name, charcode); - if (m_GlyphIndex[charcode] == 0) { - if (strcmp(name, ".notdef") != 0 && strcmp(name, "space") != 0) { - m_GlyphIndex[charcode] = FXFT_Get_Char_Index( - m_Font.GetFace(), - bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); - CalcExtGID(charcode); - } else { - m_Encoding.m_Unicodes[charcode] = 0x20; - m_GlyphIndex[charcode] = - bUnicode ? FXFT_Get_Char_Index(m_Font.GetFace(), 0x20) : 0xffff; - CalcExtGID(charcode); - } + if (m_GlyphIndex[charcode] != 0) + continue; + + if (strcmp(name, ".notdef") != 0 && strcmp(name, "space") != 0) { + m_GlyphIndex[charcode] = FXFT_Get_Char_Index( + m_Font.GetFace(), + bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); + CalcExtGID(charcode); + } else { + m_Encoding.m_Unicodes[charcode] = 0x20; + m_GlyphIndex[charcode] = + bUnicode ? FXFT_Get_Char_Index(m_Font.GetFace(), 0x20) : 0xffff; + CalcExtGID(charcode); } } return; @@ -260,7 +260,7 @@ void CPDF_Type1Font::LoadGlyphMap() { if (name) { m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); m_GlyphIndex[charcode] = - FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); + FXFT_Get_Name_Index(m_Font.GetFace(), const_cast<char*>(name)); } else { m_GlyphIndex[charcode] = FXFT_Get_Char_Index(m_Font.GetFace(), charcode); @@ -273,9 +273,8 @@ void CPDF_Type1Font::LoadGlyphMap() { FXFT_Get_Glyph_Name(m_Font.GetFace(), m_GlyphIndex[charcode], name_glyph, 256); name_glyph[255] = 0; - if (name_glyph[0] != 0) { + if (name_glyph[0] != 0) unicode = PDF_UnicodeFromAdobeName(name_glyph); - } } m_Encoding.m_Unicodes[charcode] = unicode; } @@ -288,26 +287,27 @@ void CPDF_Type1Font::LoadGlyphMap() { #endif return; } - bool bUnicode = false; - if (0 == FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE)) { - bUnicode = true; - } + + bool bUnicode = + FXFT_Select_Charmap(m_Font.GetFace(), FXFT_ENCODING_UNICODE) == 0; for (int charcode = 0; charcode < 256; charcode++) { const char* name = GetAdobeCharName(m_BaseEncoding, m_CharNames, charcode); - if (!name) { + if (!name) continue; - } + m_Encoding.m_Unicodes[charcode] = PDF_UnicodeFromAdobeName(name); - m_GlyphIndex[charcode] = FXFT_Get_Name_Index(m_Font.GetFace(), (char*)name); - if (m_GlyphIndex[charcode] == 0) { - if (strcmp(name, ".notdef") != 0 && strcmp(name, "space") != 0) { - m_GlyphIndex[charcode] = FXFT_Get_Char_Index( - m_Font.GetFace(), - bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); - } else { - m_Encoding.m_Unicodes[charcode] = 0x20; - m_GlyphIndex[charcode] = 0xffff; - } + m_GlyphIndex[charcode] = + FXFT_Get_Name_Index(m_Font.GetFace(), const_cast<char*>(name)); + if (m_GlyphIndex[charcode] != 0) + continue; + + if (strcmp(name, ".notdef") != 0 && strcmp(name, "space") != 0) { + m_GlyphIndex[charcode] = FXFT_Get_Char_Index( + m_Font.GetFace(), + bUnicode ? m_Encoding.m_Unicodes[charcode] : charcode); + } else { + m_Encoding.m_Unicodes[charcode] = 0x20; + m_GlyphIndex[charcode] = 0xffff; } } #if _FX_PLATFORM_ == _FX_PLATFORM_APPLE_ diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp index 406a8222db..0aa41239eb 100644 --- a/core/fxge/cfx_fontmapper.cpp +++ b/core/fxge/cfx_fontmapper.cpp @@ -250,21 +250,20 @@ std::tuple<bool, uint32_t, size_t> GetStyleType(const ByteString& bsStyle, return std::make_tuple(false, FXFONT_NORMAL, 0); } -bool CheckSupportThirdPartFont(ByteString name, int& PitchFamily) { - if (name == "MyriadPro") { - PitchFamily &= ~FXFONT_FF_ROMAN; - return true; - } - return false; +bool CheckSupportThirdPartFont(const ByteString& name, int* PitchFamily) { + if (name != "MyriadPro") + return false; + *PitchFamily &= ~FXFONT_FF_ROMAN; + return true; } -void UpdatePitchFamily(uint32_t flags, int& PitchFamily) { +void UpdatePitchFamily(uint32_t flags, int* PitchFamily) { if (FontStyleIsSerif(flags)) - PitchFamily |= FXFONT_FF_ROMAN; + *PitchFamily |= FXFONT_FF_ROMAN; if (FontStyleIsScript(flags)) - PitchFamily |= FXFONT_FF_SCRIPT; + *PitchFamily |= FXFONT_FF_SCRIPT; if (FontStyleIsFixedPitch(flags)) - PitchFamily |= FXFONT_FF_FIXEDPITCH; + *PitchFamily |= FXFONT_FF_FIXEDPITCH; } } // namespace @@ -485,7 +484,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name, nStyle |= styleType; } } - UpdatePitchFamily(flags, PitchFamily); + UpdatePitchFamily(flags, &PitchFamily); } int old_weight = weight; @@ -563,7 +562,7 @@ FXFT_Face CFX_FontMapper::FindSubstFont(const ByteString& name, } if (match.IsEmpty() && iBaseFont >= kNumStandardFonts) { if (!bCJK) { - if (!CheckSupportThirdPartFont(family, PitchFamily)) { + if (!CheckSupportThirdPartFont(family, &PitchFamily)) { bItalic = italic_angle != 0; weight = old_weight; } @@ -707,7 +706,7 @@ FXFT_Face CFX_FontMapper::FindSubstFontByUnicode(uint32_t dwUnicode, bool bItalic = (flags & FXFONT_ITALIC) != 0; int PitchFamily = 0; - UpdatePitchFamily(flags, PitchFamily); + UpdatePitchFamily(flags, &PitchFamily); void* hFont = m_pFontInfo->MapFontByUnicode(dwUnicode, weight, bItalic, PitchFamily); if (!hFont) |