Index: core/fxge/ge/cfx_fontmapper.cpp |
diff --git a/core/fxge/ge/cfx_fontmapper.cpp b/core/fxge/ge/cfx_fontmapper.cpp |
index 86dc2389d607a8ee77e96cd91478c94c70545c6c..a624c0e760b9f0f336cfbf5502b1116b4651ae4b 100644 |
--- a/core/fxge/ge/cfx_fontmapper.cpp |
+++ b/core/fxge/ge/cfx_fontmapper.cpp |
@@ -348,12 +348,11 @@ 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); |
+ m_InstalledTTFonts[TT_NormalizeName(new_name.c_str())] = name; |
dsinclair
2016/10/05 21:12:07
Should this name be new_name?
npm
2016/10/05 21:21:47
No. See comment below
|
} |
m_pFontInfo->DeleteFont(hFont); |
} |
- m_InstalledTTFonts.push_back(name); |
+ m_InstalledTTFonts[TT_NormalizeName(name.c_str())] = name; |
m_LastFamily = name; |
} |
@@ -368,18 +367,10 @@ void CFX_FontMapper::LoadInstalledFonts() { |
CFX_ByteString CFX_FontMapper::MatchInstalledFonts( |
const CFX_ByteString& norm_name) { |
LoadInstalledFonts(); |
- int i; |
- for (i = pdfium::CollectionSize<int>(m_InstalledTTFonts) - 1; i >= 0; i--) { |
Tom Sepez
2016/10/05 21:17:34
I worry about the order being significant as we mo
npm
2016/10/05 21:21:47
The order here is relevant in the sense that we ma
|
- CFX_ByteString norm1 = TT_NormalizeName(m_InstalledTTFonts[i].c_str()); |
dsinclair
2016/10/05 21:12:07
Previously if TT_NormalizeName(new_name) matched n
npm
2016/10/05 21:21:47
On previous line 381, the index is increased by 1.
|
- if (norm1 == norm_name) |
- break; |
- } |
- if (i < 0) |
+ auto it = m_InstalledTTFonts.find(norm_name); |
+ if (it == m_InstalledTTFonts.end()) |
return CFX_ByteString(); |
- CFX_ByteString match = m_InstalledTTFonts[i]; |
- if (match[0] == ' ') |
- match = m_InstalledTTFonts[i + 1]; |
- return match; |
+ return it->second; |
} |
FXFT_Face CFX_FontMapper::UseInternalSubst(CFX_SubstFont* pSubstFont, |