summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn2
-rw-r--r--core/fxge/android/cfpf_skiafont.cpp25
-rw-r--r--core/fxge/android/cfpf_skiafont.h14
-rw-r--r--core/fxge/android/cfpf_skiafontdescriptor.cpp32
-rw-r--r--core/fxge/android/cfpf_skiafontdescriptor.h30
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.cpp68
-rw-r--r--core/fxge/android/cfpf_skiafontmgr.h6
-rw-r--r--core/fxge/android/cfpf_skiapathfont.cpp15
-rw-r--r--core/fxge/android/cfpf_skiapathfont.h20
9 files changed, 68 insertions, 144 deletions
diff --git a/BUILD.gn b/BUILD.gn
index ca240d229a..73b4382a58 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1004,8 +1004,6 @@ jumbo_static_library("fxge") {
"core/fxge/android/cfpf_skiadevicemodule.h",
"core/fxge/android/cfpf_skiafont.cpp",
"core/fxge/android/cfpf_skiafont.h",
- "core/fxge/android/cfpf_skiafontdescriptor.cpp",
- "core/fxge/android/cfpf_skiafontdescriptor.h",
"core/fxge/android/cfpf_skiafontmgr.cpp",
"core/fxge/android/cfpf_skiafontmgr.h",
"core/fxge/android/cfpf_skiapathfont.cpp",
diff --git a/core/fxge/android/cfpf_skiafont.cpp b/core/fxge/android/cfpf_skiafont.cpp
index 6431f14c57..24984e8d9f 100644
--- a/core/fxge/android/cfpf_skiafont.cpp
+++ b/core/fxge/android/cfpf_skiafont.cpp
@@ -9,20 +9,13 @@
#include <algorithm>
#include "core/fxcrt/fx_system.h"
-#include "core/fxge/android/cfpf_skiafontdescriptor.h"
#include "core/fxge/android/cfpf_skiafontmgr.h"
#include "core/fxge/android/cfpf_skiapathfont.h"
#include "core/fxge/fx_freetype.h"
#define FPF_EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em)
-CFPF_SkiaFont::CFPF_SkiaFont()
- : m_pFontMgr(nullptr),
- m_pFontDes(nullptr),
- m_Face(nullptr),
- m_dwStyle(0),
- m_uCharset(0),
- m_dwRefCount(0) {}
+CFPF_SkiaFont::CFPF_SkiaFont() = default;
CFPF_SkiaFont::~CFPF_SkiaFont() {
if (m_Face)
@@ -178,29 +171,21 @@ uint32_t CFPF_SkiaFont::GetFontData(uint32_t dwTable,
}
bool CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr,
- CFPF_SkiaFontDescriptor* pFontDes,
+ CFPF_SkiaPathFont* pFont,
const ByteStringView& bsFamily,
uint32_t dwStyle,
uint8_t uCharset) {
- if (!pFontMgr || !pFontDes)
+ if (!pFontMgr || !pFont)
return false;
- switch (pFontDes->GetType()) {
- case FPF_SKIAFONTTYPE_Path: {
- CFPF_SkiaPathFont* pFont = (CFPF_SkiaPathFont*)pFontDes;
- m_Face = pFontMgr->GetFontFace(pFont->m_pPath, pFont->m_iFaceIndex);
- break;
- }
- default:
- return false;
- }
+ m_Face = pFontMgr->GetFontFace(pFont->m_pPath, pFont->m_iFaceIndex);
if (!m_Face)
return false;
m_dwStyle = dwStyle;
m_uCharset = uCharset;
m_pFontMgr = pFontMgr;
- m_pFontDes = pFontDes;
+ 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 1b2f605838..260e4222a5 100644
--- a/core/fxge/android/cfpf_skiafont.h
+++ b/core/fxge/android/cfpf_skiafont.h
@@ -11,8 +11,8 @@
#include "core/fxcrt/unowned_ptr.h"
#include "core/fxge/fx_font.h"
-class CFPF_SkiaFontDescriptor;
class CFPF_SkiaFontMgr;
+class CFPF_SkiaPathFont;
class CFPF_SkiaFont {
public:
@@ -37,18 +37,18 @@ class CFPF_SkiaFont {
uint32_t GetFontData(uint32_t dwTable, uint8_t* pBuffer, uint32_t dwSize);
bool InitFont(CFPF_SkiaFontMgr* pFontMgr,
- CFPF_SkiaFontDescriptor* pFontDes,
+ CFPF_SkiaPathFont* pFont,
const ByteStringView& bsFamily,
uint32_t dwStyle,
uint8_t uCharset);
private:
UnownedPtr<CFPF_SkiaFontMgr> m_pFontMgr;
- UnownedPtr<CFPF_SkiaFontDescriptor> m_pFontDes;
- FXFT_Face m_Face;
- uint32_t m_dwStyle;
- uint8_t m_uCharset;
- uint32_t m_dwRefCount;
+ UnownedPtr<CFPF_SkiaPathFont> m_pFont;
+ FXFT_Face m_Face = nullptr;
+ uint32_t m_dwStyle = 0;
+ uint8_t m_uCharset = 0;
+ uint32_t m_dwRefCount = 0;
};
#endif // CORE_FXGE_ANDROID_CFPF_SKIAFONT_H_
diff --git a/core/fxge/android/cfpf_skiafontdescriptor.cpp b/core/fxge/android/cfpf_skiafontdescriptor.cpp
deleted file mode 100644
index 8dd4481a7d..0000000000
--- a/core/fxge/android/cfpf_skiafontdescriptor.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2017 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "core/fxge/android/cfpf_skiafontdescriptor.h"
-
-#include "core/fxcrt/fx_memory.h"
-
-CFPF_SkiaFontDescriptor::CFPF_SkiaFontDescriptor()
- : m_pFamily(nullptr),
- m_dwStyle(0),
- m_iFaceIndex(0),
- m_dwCharsets(0),
- m_iGlyphNum(0) {}
-
-CFPF_SkiaFontDescriptor::~CFPF_SkiaFontDescriptor() {
- FX_Free(m_pFamily);
-}
-
-int32_t CFPF_SkiaFontDescriptor::GetType() const {
- return FPF_SKIAFONTTYPE_Unknown;
-}
-
-void CFPF_SkiaFontDescriptor::SetFamily(const char* pFamily) {
- FX_Free(m_pFamily);
- int32_t iSize = strlen(pFamily);
- m_pFamily = FX_Alloc(char, iSize + 1);
- memcpy(m_pFamily, pFamily, iSize * sizeof(char));
- m_pFamily[iSize] = 0;
-}
diff --git a/core/fxge/android/cfpf_skiafontdescriptor.h b/core/fxge/android/cfpf_skiafontdescriptor.h
deleted file mode 100644
index 00a19ecc54..0000000000
--- a/core/fxge/android/cfpf_skiafontdescriptor.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef CORE_FXGE_ANDROID_CFPF_SKIAFONTDESCRIPTOR_H_
-#define CORE_FXGE_ANDROID_CFPF_SKIAFONTDESCRIPTOR_H_
-
-#include "core/fxcrt/fx_system.h"
-
-#define FPF_SKIAFONTTYPE_Unknown 0
-
-class CFPF_SkiaFontDescriptor {
- public:
- CFPF_SkiaFontDescriptor();
- virtual ~CFPF_SkiaFontDescriptor();
-
- virtual int32_t GetType() const;
-
- void SetFamily(const char* pFamily);
-
- char* m_pFamily;
- uint32_t m_dwStyle;
- int32_t m_iFaceIndex;
- uint32_t m_dwCharsets;
- int32_t m_iGlyphNum;
-};
-
-#endif // CORE_FXGE_ANDROID_CFPF_SKIAFONTDESCRIPTOR_H_
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index 32fe498882..b091ae9fd7 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -19,7 +19,6 @@
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxge/android/cfpf_skiafont.h"
-#include "core/fxge/android/cfpf_skiafontdescriptor.h"
#include "core/fxge/android/cfpf_skiapathfont.h"
#include "core/fxge/fx_freetype.h"
@@ -277,29 +276,29 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
}
int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 +
FPF_SKIAMATCHWEIGHT_2 * 2;
- CFPF_SkiaFontDescriptor* pBestFontDes = nullptr;
+ CFPF_SkiaPathFont* pBestFont = nullptr;
int32_t nMax = -1;
int32_t nGlyphNum = 0;
for (auto it = m_FontFaces.rbegin(); it != m_FontFaces.rend(); ++it) {
- CFPF_SkiaPathFont* pFontDes = static_cast<CFPF_SkiaPathFont*>(*it);
- if (!(pFontDes->m_dwCharsets & FPF_SkiaGetCharset(uCharset)))
+ CFPF_SkiaPathFont* pFont = *it;
+ if (!(pFont->m_dwCharsets & FPF_SkiaGetCharset(uCharset)))
continue;
int32_t nFind = 0;
- uint32_t dwSysFontName = FPF_SKIANormalizeFontName(pFontDes->m_pFamily);
+ uint32_t dwSysFontName = FPF_SKIANormalizeFontName(pFont->m_pFamily);
if (dwFaceName == dwSysFontName)
nFind += FPF_SKIAMATCHWEIGHT_NAME1;
bool bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1);
- if (FontStyleIsBold(dwStyle) == FontStyleIsBold(pFontDes->m_dwStyle))
+ if (FontStyleIsBold(dwStyle) == FontStyleIsBold(pFont->m_dwStyle))
nFind += FPF_SKIAMATCHWEIGHT_1;
- if (FontStyleIsItalic(dwStyle) == FontStyleIsItalic(pFontDes->m_dwStyle))
+ if (FontStyleIsItalic(dwStyle) == FontStyleIsItalic(pFont->m_dwStyle))
nFind += FPF_SKIAMATCHWEIGHT_1;
if (FontStyleIsFixedPitch(dwStyle) ==
- FontStyleIsFixedPitch(pFontDes->m_dwStyle)) {
+ FontStyleIsFixedPitch(pFont->m_dwStyle)) {
nFind += FPF_SKIAMATCHWEIGHT_2;
}
- if (FontStyleIsSerif(dwStyle) == FontStyleIsSerif(pFontDes->m_dwStyle))
+ if (FontStyleIsSerif(dwStyle) == FontStyleIsSerif(pFont->m_dwStyle))
nFind += FPF_SKIAMATCHWEIGHT_1;
- if (FontStyleIsScript(dwStyle) == FontStyleIsScript(pFontDes->m_dwStyle))
+ if (FontStyleIsScript(dwStyle) == FontStyleIsScript(pFont->m_dwStyle))
nFind += FPF_SKIAMATCHWEIGHT_2;
if (dwSubst == dwSysFontName || dwSubstSans == dwSysFontName) {
nFind += FPF_SKIAMATCHWEIGHT_NAME2;
@@ -308,25 +307,25 @@ CFPF_SkiaFont* CFPF_SkiaFontMgr::CreateFont(const ByteStringView& bsFamilyname,
if (uCharset == FX_CHARSET_Default || bMaybeSymbol) {
if (nFind > nMax && bMatchedName) {
nMax = nFind;
- pBestFontDes = *it;
+ pBestFont = *it;
}
} else if (FPF_SkiaIsCJK(uCharset)) {
- if (bMatchedName || pFontDes->m_iGlyphNum > nGlyphNum) {
- pBestFontDes = *it;
- nGlyphNum = pFontDes->m_iGlyphNum;
+ if (bMatchedName || pFont->m_iGlyphNum > nGlyphNum) {
+ pBestFont = *it;
+ nGlyphNum = pFont->m_iGlyphNum;
}
} else if (nFind > nMax) {
nMax = nFind;
- pBestFontDes = *it;
+ pBestFont = *it;
}
if (nExpectVal <= nFind) {
- pBestFontDes = *it;
+ pBestFont = *it;
break;
}
}
- if (pBestFontDes) {
+ if (pBestFont) {
CFPF_SkiaFont* pFont = new CFPF_SkiaFont;
- if (pFont->InitFont(this, pBestFontDes, bsFamilyname, dwStyle, uCharset)) {
+ if (pFont->InitFont(this, pBestFont, bsFamilyname, dwStyle, uCharset)) {
m_FamilyFonts[dwHash] = pFont;
return pFont->Retain();
}
@@ -382,37 +381,36 @@ void CFPF_SkiaFontMgr::ScanFile(const ByteString& file) {
FXFT_Face face = GetFontFace(file.AsStringView(), 0);
if (!face)
return;
- CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont;
- pFontDesc->SetPath(file.c_str());
- ReportFace(face, pFontDesc);
- m_FontFaces.push_back(pFontDesc);
+ CFPF_SkiaPathFont* pFont = new CFPF_SkiaPathFont;
+ pFont->SetPath(file.c_str());
+ ReportFace(face, pFont);
+ m_FontFaces.push_back(pFont);
FXFT_Done_Face(face);
}
-void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face,
- CFPF_SkiaFontDescriptor* pFontDesc) {
- if (!face || !pFontDesc)
+void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face, CFPF_SkiaPathFont* pFont) {
+ if (!face || !pFont)
return;
- pFontDesc->SetFamily(FXFT_Get_Face_Family_Name(face));
+ pFont->SetFamily(FXFT_Get_Face_Family_Name(face));
if (FXFT_Is_Face_Bold(face))
- pFontDesc->m_dwStyle |= FXFONT_BOLD;
+ pFont->m_dwStyle |= FXFONT_BOLD;
if (FXFT_Is_Face_Italic(face))
- pFontDesc->m_dwStyle |= FXFONT_ITALIC;
+ pFont->m_dwStyle |= FXFONT_ITALIC;
if (FT_IS_FIXED_WIDTH(face))
- pFontDesc->m_dwStyle |= FXFONT_FIXED_PITCH;
+ pFont->m_dwStyle |= FXFONT_FIXED_PITCH;
TT_OS2* pOS2 = static_cast<TT_OS2*>(FT_Get_Sfnt_Table(face, ft_sfnt_os2));
if (pOS2) {
if (pOS2->ulCodePageRange1 & (1 << 31))
- pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC;
+ pFont->m_dwStyle |= FXFONT_SYMBOLIC;
if (pOS2->panose[0] == 2) {
uint8_t uSerif = pOS2->panose[1];
if ((uSerif > 1 && uSerif < 10) || uSerif > 13)
- pFontDesc->m_dwStyle |= FXFONT_SERIF;
+ pFont->m_dwStyle |= FXFONT_SERIF;
}
}
if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31)))
- pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC;
- pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2);
- pFontDesc->m_iFaceIndex = face->face_index;
- pFontDesc->m_iGlyphNum = face->num_glyphs;
+ pFont->m_dwStyle |= FXFONT_SYMBOLIC;
+ pFont->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2);
+ pFont->m_iFaceIndex = face->face_index;
+ pFont->m_iGlyphNum = face->num_glyphs;
}
diff --git a/core/fxge/android/cfpf_skiafontmgr.h b/core/fxge/android/cfpf_skiafontmgr.h
index 3152a3592e..af2d3acfc8 100644
--- a/core/fxge/android/cfpf_skiafontmgr.h
+++ b/core/fxge/android/cfpf_skiafontmgr.h
@@ -16,7 +16,7 @@
#define FPF_MATCHFONT_REPLACEANSI 1
class CFPF_SkiaFont;
-class CFPF_SkiaFontDescriptor;
+class CFPF_SkiaPathFont;
class CFPF_SkiaFontMgr {
public:
@@ -35,11 +35,11 @@ class CFPF_SkiaFontMgr {
private:
void ScanPath(const ByteString& path);
void ScanFile(const ByteString& file);
- void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor* pFontDesc);
+ void ReportFace(FXFT_Face face, CFPF_SkiaPathFont* pFont);
bool m_bLoaded = false;
FXFT_Library m_FTLibrary = nullptr;
- std::vector<CFPF_SkiaFontDescriptor*> m_FontFaces;
+ std::vector<CFPF_SkiaPathFont*> m_FontFaces;
std::map<uint32_t, CFPF_SkiaFont*> m_FamilyFonts;
};
diff --git a/core/fxge/android/cfpf_skiapathfont.cpp b/core/fxge/android/cfpf_skiapathfont.cpp
index 27f4fde988..063729f7e5 100644
--- a/core/fxge/android/cfpf_skiapathfont.cpp
+++ b/core/fxge/android/cfpf_skiapathfont.cpp
@@ -8,16 +8,13 @@
#include "core/fxcrt/fx_memory.h"
-CFPF_SkiaPathFont::CFPF_SkiaPathFont() : m_pPath(nullptr) {}
+CFPF_SkiaPathFont::CFPF_SkiaPathFont() {}
CFPF_SkiaPathFont::~CFPF_SkiaPathFont() {
+ FX_Free(m_pFamily);
FX_Free(m_pPath);
}
-int32_t CFPF_SkiaPathFont::GetType() const {
- return FPF_SKIAFONTTYPE_Path;
-}
-
void CFPF_SkiaPathFont::SetPath(const char* pPath) {
FX_Free(m_pPath);
int32_t iSize = strlen(pPath);
@@ -25,3 +22,11 @@ void CFPF_SkiaPathFont::SetPath(const char* pPath) {
memcpy(m_pPath, pPath, iSize * sizeof(char));
m_pPath[iSize] = 0;
}
+
+void CFPF_SkiaPathFont::SetFamily(const char* pFamily) {
+ FX_Free(m_pFamily);
+ int32_t iSize = strlen(pFamily);
+ m_pFamily = FX_Alloc(char, iSize + 1);
+ memcpy(m_pFamily, pFamily, iSize * sizeof(char));
+ m_pFamily[iSize] = 0;
+}
diff --git a/core/fxge/android/cfpf_skiapathfont.h b/core/fxge/android/cfpf_skiapathfont.h
index 6cba42acff..e1d8994768 100644
--- a/core/fxge/android/cfpf_skiapathfont.h
+++ b/core/fxge/android/cfpf_skiapathfont.h
@@ -8,21 +8,21 @@
#define CORE_FXGE_ANDROID_CFPF_SKIAPATHFONT_H_
#include "core/fxcrt/fx_system.h"
-#include "core/fxge/android/cfpf_skiafontdescriptor.h"
-#define FPF_SKIAFONTTYPE_Path 1
-
-class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor {
+class CFPF_SkiaPathFont {
public:
CFPF_SkiaPathFont();
- ~CFPF_SkiaPathFont() override;
-
- // CFPF_SkiaFontDescriptor
- int32_t GetType() const override;
+ ~CFPF_SkiaPathFont();
void SetPath(const char* pPath);
-
- char* m_pPath;
+ void SetFamily(const char* pFamily);
+
+ char* m_pPath = nullptr;
+ char* m_pFamily = nullptr;
+ uint32_t m_dwStyle = 0;
+ int32_t m_iFaceIndex = 0;
+ uint32_t m_dwCharsets = 0;
+ int32_t m_iGlyphNum = 0;
};
#endif // CORE_FXGE_ANDROID_CFPF_SKIAPATHFONT_H_