summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-06-27 18:22:06 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-27 18:22:06 -0700
commitb21c6d0083e18077aa09b8cb1e4bb867dab2949e (patch)
treeb639a87556dcb59c3a6c76a378fdb1916637d03f
parent8ea3f5176aab4d6688710d9937cf38a43c14d030 (diff)
downloadpdfium-b21c6d0083e18077aa09b8cb1e4bb867dab2949e.tar.xz
Fix a regression from commit f3e6851.
The index calculations are wrong for a reverse iterator. Review-Url: https://codereview.chromium.org/2101723002
-rw-r--r--core/fxge/android/fpf_skiafontmgr.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/core/fxge/android/fpf_skiafontmgr.cpp b/core/fxge/android/fpf_skiafontmgr.cpp
index fb5b686a87..4b2ad98ddd 100644
--- a/core/fxge/android/fpf_skiafontmgr.cpp
+++ b/core/fxge/android/fpf_skiafontmgr.cpp
@@ -248,6 +248,7 @@ void CFPF_SkiaFontMgr::LoadSystemFonts() {
void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) {}
void CFPF_SkiaFontMgr::LoadPrivateFont(const CFX_ByteStringC& bsFileName) {}
void CFPF_SkiaFontMgr::LoadPrivateFont(void* pBuffer, size_t szBuffer) {}
+
CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
uint8_t uCharset,
uint32_t dwStyle,
@@ -269,7 +270,7 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
}
int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 +
FPF_SKIAMATCHWEIGHT_2 * 2;
- int32_t nItem = -1;
+ CFPF_SkiaFontDescriptor* pBestFontDes = nullptr;
int32_t nMax = -1;
int32_t nGlyphNum = 0;
for (auto it = m_FontFaces.rbegin(); it != m_FontFaces.rend(); ++it) {
@@ -306,26 +307,25 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
if (uCharset == FXFONT_DEFAULT_CHARSET || bMaybeSymbol) {
if (nFind > nMax && bMatchedName) {
nMax = nFind;
- nItem = it - m_FontFaces.rbegin();
+ pBestFontDes = *it;
}
} else if (FPF_SkiaIsCJK(uCharset)) {
if (bMatchedName || pFontDes->m_iGlyphNum > nGlyphNum) {
- nItem = it - m_FontFaces.rbegin();
+ pBestFontDes = *it;
nGlyphNum = pFontDes->m_iGlyphNum;
}
} else if (nFind > nMax) {
nMax = nFind;
- nItem = it - m_FontFaces.rbegin();
+ pBestFontDes = *it;
}
if (nExpectVal <= nFind) {
- nItem = it - m_FontFaces.rbegin();
+ pBestFontDes = *it;
break;
}
}
- if (nItem > -1) {
- CFPF_SkiaFontDescriptor* pFontDes = m_FontFaces[nItem];
+ if (pBestFontDes) {
CFPF_SkiaFont* pFont = new CFPF_SkiaFont;
- if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) {
+ if (pFont->InitFont(this, pBestFontDes, bsFamilyname, dwStyle, uCharset)) {
m_FamilyFonts[dwHash] = pFont;
return pFont->Retain();
}
@@ -333,6 +333,7 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
}
return nullptr;
}
+
FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead,
int32_t iFaceIndex) {
if (!pFileRead) {