summaryrefslogtreecommitdiff
path: root/core/fxge/ge
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-10-06 12:29:09 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-06 12:29:09 -0700
commit065c35006d96eaca324f49248d20d83709a25fbe (patch)
tree46d3d235bc8a8192748fa64166cb3d86aa65a0d8 /core/fxge/ge
parentaa6e8b555e113a3f91a49258ed83810abf0d4929 (diff)
downloadpdfium-065c35006d96eaca324f49248d20d83709a25fbe.tar.xz
Split m_InstalledTTFonts into two vectors to avoid sketchy logic.
Instead of relying on ' ' to determine whether the CFX_Bytestring is added on one place or another, use another vector. When trying to match fonts from the fontmapper, compare with both vectors. BUG=pdfium:510 Review-Url: https://codereview.chromium.org/2395883002
Diffstat (limited to 'core/fxge/ge')
-rw-r--r--core/fxge/ge/cfx_fontmapper.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/core/fxge/ge/cfx_fontmapper.cpp b/core/fxge/ge/cfx_fontmapper.cpp
index 86dc2389d6..b388545751 100644
--- a/core/fxge/ge/cfx_fontmapper.cpp
+++ b/core/fxge/ge/cfx_fontmapper.cpp
@@ -347,10 +347,8 @@ void CFX_FontMapper::AddInstalledFont(const CFX_ByteString& name, int charset) {
}
CFX_ByteString new_name = GetPSNameFromTT(hFont);
- if (!new_name.IsEmpty()) {
- new_name.Insert(0, ' ');
- m_InstalledTTFonts.push_back(new_name);
- }
+ if (!new_name.IsEmpty())
+ m_LocalizedTTFonts.push_back(std::make_pair(new_name, name));
m_pFontInfo->DeleteFont(hFont);
}
m_InstalledTTFonts.push_back(name);
@@ -372,14 +370,15 @@ CFX_ByteString CFX_FontMapper::MatchInstalledFonts(
for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) {
CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str());
if (norm1 == norm_name)
- break;
+ return m_InstalledTTFonts[i];
}
- if (i < 0)
- return CFX_ByteString();
- CFX_ByteString match = m_InstalledTTFonts[i];
- if (match[0] == ' ')
- match = m_InstalledTTFonts[i + 1];
- return match;
+ for (i = pdfium::CollectionSize<int>(m_LocalizedTTFonts) - 1; i >= 0; i--) {
+ CFX_ByteString norm1 =
+ TT_NormalizeName(m_LocalizedTTFonts[i].first.c_str());
+ if (norm1 == norm_name)
+ return m_LocalizedTTFonts[i].second;
+ }
+ return CFX_ByteString();
}
FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont,