summaryrefslogtreecommitdiff
path: root/core/fxge/android/fpf_skiafont.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-04-13 10:52:11 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-13 10:52:12 -0700
commit6d8e981b51458f0381031fe240f5215db9906622 (patch)
treef36b121dd552a16ef5d8aeba7417fd8f8edfa611 /core/fxge/android/fpf_skiafont.cpp
parent65ffa4a4ee599194118a0ddf3c26fc3674120b4a (diff)
downloadpdfium-6d8e981b51458f0381031fe240f5215db9906622.tar.xz
Cleanup IFPF_* interfaces.
This CL removes the IFPF_DeviceModule, IFPF_FontMgr and IFPF_Font interfaces in favour of their concrete classes. BUG=pdfium:467 Review URL: https://codereview.chromium.org/1881043004
Diffstat (limited to 'core/fxge/android/fpf_skiafont.cpp')
-rw-r--r--core/fxge/android/fpf_skiafont.cpp98
1 files changed, 52 insertions, 46 deletions
diff --git a/core/fxge/android/fpf_skiafont.cpp b/core/fxge/android/fpf_skiafont.cpp
index 0d2069cd99..332bfd0ca2 100644
--- a/core/fxge/android/fpf_skiafont.cpp
+++ b/core/fxge/android/fpf_skiafont.cpp
@@ -17,54 +17,55 @@
#define FPF_EM_ADJUST(em, a) (em == 0 ? (a) : (a)*1000 / em)
CFPF_SkiaFont::CFPF_SkiaFont()
- : m_pFontMgr(NULL),
- m_pFontDes(NULL),
- m_Face(NULL),
+ : m_pFontMgr(nullptr),
+ m_pFontDes(nullptr),
+ m_Face(nullptr),
m_dwStyle(0),
m_uCharset(0),
m_dwRefCount(0) {}
+
CFPF_SkiaFont::~CFPF_SkiaFont() {
- if (m_Face) {
+ if (m_Face)
FXFT_Done_Face(m_Face);
- }
}
+
void CFPF_SkiaFont::Release() {
- if (--m_dwRefCount == 0) {
+ if (--m_dwRefCount == 0)
delete this;
- }
}
-IFPF_Font* CFPF_SkiaFont::Retain() {
+
+CFPF_SkiaFont* CFPF_SkiaFont::Retain() {
m_dwRefCount++;
- return (IFPF_Font*)this;
+ return this;
}
+
FPF_HFONT CFPF_SkiaFont::GetHandle() {
- return NULL;
+ return nullptr;
}
+
CFX_ByteString CFPF_SkiaFont::GetFamilyName() {
- if (!m_Face) {
+ if (!m_Face)
return CFX_ByteString();
- }
return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face));
}
+
CFX_WideString CFPF_SkiaFont::GetPsName() {
- if (!m_Face) {
+ if (!m_Face)
return CFX_WideString();
- }
return CFX_WideString::FromLocal(FXFT_Get_Postscript_Name(m_Face));
}
+
int32_t CFPF_SkiaFont::GetGlyphIndex(FX_WCHAR wUnicode) {
- if (!m_Face) {
+ if (!m_Face)
return wUnicode;
- }
- if (FXFT_Select_Charmap(m_Face, FXFT_ENCODING_UNICODE)) {
+ if (FXFT_Select_Charmap(m_Face, FXFT_ENCODING_UNICODE))
return 0;
- }
return FXFT_Get_Char_Index(m_Face, wUnicode);
}
+
int32_t CFPF_SkiaFont::GetGlyphWidth(int32_t iGlyphIndex) {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
if (FXFT_Load_Glyph(
m_Face, iGlyphIndex,
FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
@@ -73,28 +74,27 @@ int32_t CFPF_SkiaFont::GetGlyphWidth(int32_t iGlyphIndex) {
return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
FXFT_Get_Glyph_HoriAdvance(m_Face));
}
+
int32_t CFPF_SkiaFont::GetAscent() const {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
FXFT_Get_Face_Ascender(m_Face));
}
+
int32_t CFPF_SkiaFont::GetDescent() const {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
FXFT_Get_Face_Descender(m_Face));
}
+
FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox) {
- if (!m_Face) {
+ if (!m_Face)
return FALSE;
- }
if (FXFT_Is_Face_Tricky(m_Face)) {
- if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72)) {
+ if (FXFT_Set_Char_Size(m_Face, 0, 1000 * 64, 72, 72))
return FALSE;
- }
if (FXFT_Load_Glyph(m_Face, iGlyphIndex,
FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
@@ -135,6 +135,7 @@ FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox) {
FXFT_Get_Glyph_HoriBearingY(m_Face) - FXFT_Get_Glyph_Height(m_Face));
return TRUE;
}
+
FX_BOOL CFPF_SkiaFont::GetBBox(FX_RECT& rtBBox) {
if (!m_Face) {
return FALSE;
@@ -149,64 +150,68 @@ FX_BOOL CFPF_SkiaFont::GetBBox(FX_RECT& rtBBox) {
FXFT_Get_Face_yMax(m_Face));
return TRUE;
}
+
int32_t CFPF_SkiaFont::GetHeight() const {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
FXFT_Get_Face_Height(m_Face));
}
+
int32_t CFPF_SkiaFont::GetItalicAngle() const {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
+
TT_Postscript* ttInfo =
(TT_Postscript*)FT_Get_Sfnt_Table(m_Face, ft_sfnt_post);
- if (ttInfo) {
+ if (ttInfo)
return ttInfo->italicAngle;
- }
return 0;
}
+
uint32_t CFPF_SkiaFont::GetFontData(uint32_t dwTable,
uint8_t* pBuffer,
uint32_t dwSize) {
- if (!m_Face) {
+ if (!m_Face)
return 0;
- }
+
FT_ULong ulSize = pdfium::base::checked_cast<FT_ULong>(dwSize);
- if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, &ulSize)) {
+ if (FXFT_Load_Sfnt_Table(m_Face, dwTable, 0, pBuffer, &ulSize))
return 0;
- }
return pdfium::base::checked_cast<uint32_t>(ulSize);
}
+
FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr,
CFPF_SkiaFontDescriptor* pFontDes,
const CFX_ByteStringC& bsFamily,
uint32_t dwStyle,
uint8_t uCharset) {
- if (!pFontMgr || !pFontDes) {
+ if (!pFontMgr || !pFontDes)
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;
+ break;
+ }
case FPF_SKIAFONTTYPE_File: {
CFPF_SkiaFileFont* pFont = (CFPF_SkiaFileFont*)pFontDes;
m_Face = pFontMgr->GetFontFace(pFont->m_pFile, pFont->m_iFaceIndex);
- } break;
+ break;
+ }
case FPF_SKIAFONTTYPE_Buffer: {
CFPF_SkiaBufferFont* pFont = (CFPF_SkiaBufferFont*)pFontDes;
m_Face = pFontMgr->GetFontFace((const uint8_t*)pFont->m_pBuffer,
pFont->m_szBuffer, pFont->m_iFaceIndex);
- } break;
+ break;
+ }
default:
return FALSE;
}
- if (!m_Face) {
+ if (!m_Face)
return FALSE;
- }
+
m_dwStyle = dwStyle;
m_uCharset = uCharset;
m_pFontMgr = pFontMgr;
@@ -214,4 +219,5 @@ FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr,
m_dwRefCount = 1;
return TRUE;
}
-#endif
+
+#endif // _FX_OS_ == _FX_ANDROID_