summaryrefslogtreecommitdiff
path: root/core/fxge/android/cfpf_skiafontmgr.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-08-17 23:51:08 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-17 23:51:08 +0000
commit2f113cac5ff28008c702898f41e691c8d233db5f (patch)
treeac5f32f69105a716e05efe8565f9dc1e24313868 /core/fxge/android/cfpf_skiafontmgr.cpp
parent3f9a65a6bc254008625d6641ff9c54a40a64fb70 (diff)
downloadpdfium-2f113cac5ff28008c702898f41e691c8d233db5f.tar.xz
Get rid of CFPF_SkiaFont::InitFont().
Initialize via the ctor instead. Also fix refcounting for the class, so the refcount does not go negative for invalid fonts. Change-Id: I5cf51ae9051f5fc5e0204193d18f8eb37b34c244 Reviewed-on: https://pdfium-review.googlesource.com/40590 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxge/android/cfpf_skiafontmgr.cpp')
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index 08b6fc5835..37cd4516b7 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -228,10 +228,9 @@ uint32_t FPF_SkiaGetFaceCharset(TT_OS2* pOS2) {
CFPF_SkiaFontMgr::CFPF_SkiaFontMgr() = default;
CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() {
- for (const auto& pair : m_FamilyFonts) {
- if (pair.second)
- pair.second->Release();
- }
+ for (const auto& pair : m_FamilyFonts)
+ pair.second->Release();
+
m_FamilyFonts.clear();
m_FontFaces.clear();
if (m_FTLibrary)
@@ -257,7 +256,7 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
uint32_t dwMatch) {
uint32_t dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
auto it = m_FamilyFonts.find(dwHash);
- if (it != m_FamilyFonts.end() && it->second)
+ if (it != m_FamilyFonts.end())
return it->second->Retain();
uint32_t dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname);
@@ -323,10 +322,12 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
}
}
if (pBestFont) {
- CFPF_SkiaFont* pFont = new CFPF_SkiaFont;
- if (pFont->InitFont(this, pBestFont, bsFamilyname, dwStyle, uCharset)) {
+ CFPF_SkiaFont* pFont =
+ new CFPF_SkiaFont(this, pBestFont, dwStyle, uCharset);
+ pFont->Retain();
+ if (pFont->IsValid()) {
m_FamilyFonts[dwHash] = pFont;
- return pFont->Retain();
+ return pFont;
}
pFont->Release();
}