summaryrefslogtreecommitdiff
path: root/core/fxge/android
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge/android')
-rw-r--r--core/fxge/android/cfpf_skiafont.cpp30
-rw-r--r--core/fxge/android/cfpf_skiafont.h26
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.cpp17
3 files changed, 31 insertions, 42 deletions
diff --git a/core/fxge/android/cfpf_skiafont.cpp b/core/fxge/android/cfpf_skiafont.cpp
index 242ddfd3bb..2d9f274219 100644
--- a/core/fxge/android/cfpf_skiafont.cpp
+++ b/core/fxge/android/cfpf_skiafont.cpp
@@ -15,7 +15,15 @@
#define FPF_EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em)
-CFPF_SkiaFont::CFPF_SkiaFont() = default;
+CFPF_SkiaFont::CFPF_SkiaFont(CFPF_SkiaFontMgr* pFontMgr,
+ const CFPF_SkiaPathFont* pFont,
+ uint32_t dwStyle,
+ uint8_t uCharset)
+ : m_pFontMgr(pFontMgr),
+ m_pFont(pFont),
+ m_Face(m_pFontMgr->GetFontFace(m_pFont->path(), m_pFont->face_index())),
+ m_dwStyle(dwStyle),
+ m_uCharset(uCharset) {}
CFPF_SkiaFont::~CFPF_SkiaFont() {
if (m_Face)
@@ -167,23 +175,3 @@ uint32_t CFPF_SkiaFont::GetFontData(uint32_t dwTable,
return 0;
return pdfium::base::checked_cast<uint32_t>(ulSize);
}
-
-bool CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr,
- const CFPF_SkiaPathFont* pFont,
- const ByteStringView& bsFamily,
- uint32_t dwStyle,
- uint8_t uCharset) {
- if (!pFontMgr || !pFont)
- return false;
-
- m_Face = pFontMgr->GetFontFace(pFont->path(), pFont->face_index());
- if (!m_Face)
- return false;
-
- m_dwStyle = dwStyle;
- m_uCharset = uCharset;
- m_pFontMgr = pFontMgr;
- m_pFont = pFont;
- m_dwRefCount = 1;
- return true;
-}
diff --git a/core/fxge/android/cfpf_skiafont.h b/core/fxge/android/cfpf_skiafont.h
index d80378ec75..4e3b02d892 100644
--- a/core/fxge/android/cfpf_skiafont.h
+++ b/core/fxge/android/cfpf_skiafont.h
@@ -16,12 +16,16 @@ class CFPF_SkiaPathFont;
class CFPF_SkiaFont {
public:
- CFPF_SkiaFont();
- ~CFPF_SkiaFont();
+ CFPF_SkiaFont(CFPF_SkiaFontMgr* pFontMgr,
+ const CFPF_SkiaPathFont* pFont,
+ uint32_t dwStyle,
+ uint8_t uCharset);
void Release();
CFPF_SkiaFont* Retain();
+ bool IsValid() const { return !!m_Face; }
+
ByteString GetFamilyName();
ByteString GetPsName();
uint32_t GetFontStyle() const { return m_dwStyle; }
@@ -36,18 +40,14 @@ class CFPF_SkiaFont {
int32_t GetItalicAngle() const;
uint32_t GetFontData(uint32_t dwTable, uint8_t* pBuffer, uint32_t dwSize);
- bool InitFont(CFPF_SkiaFontMgr* pFontMgr,
- const CFPF_SkiaPathFont* pFont,
- const ByteStringView& bsFamily,
- uint32_t dwStyle,
- uint8_t uCharset);
-
private:
- UnownedPtr<CFPF_SkiaFontMgr> m_pFontMgr;
- UnownedPtr<const CFPF_SkiaPathFont> m_pFont;
- FXFT_Face m_Face = nullptr;
- uint32_t m_dwStyle = 0;
- uint8_t m_uCharset = 0;
+ ~CFPF_SkiaFont();
+
+ UnownedPtr<CFPF_SkiaFontMgr> const m_pFontMgr;
+ UnownedPtr<const CFPF_SkiaPathFont> const m_pFont;
+ const FXFT_Face m_Face;
+ const uint32_t m_dwStyle;
+ const uint8_t m_uCharset;
uint32_t m_dwRefCount = 0;
};
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();
}