summaryrefslogtreecommitdiff
path: root/core/src/fxge/android
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2015-08-04 12:19:10 -0700
committerNico Weber <thakis@chromium.org>2015-08-04 12:19:10 -0700
commitb048f791a15f2da781a01eba5b09eb9d389f9c11 (patch)
tree6850a73c18bbc41eaf4b1fdc6b3c96646d45587b /core/src/fxge/android
parentc8eeed31f217d99a706b0cbf5e4ce0bcc12beb64 (diff)
downloadpdfium-b048f791a15f2da781a01eba5b09eb9d389f9c11.tar.xz
clang-format all pdfium code.
No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163' | \ xargs ../../buildtools/mac/clang-format -i See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1265503005 .
Diffstat (limited to 'core/src/fxge/android')
-rw-r--r--core/src/fxge/android/fpf_skiafont.cpp378
-rw-r--r--core/src/fxge/android/fpf_skiafont.h84
-rw-r--r--core/src/fxge/android/fpf_skiafontmgr.cpp915
-rw-r--r--core/src/fxge/android/fpf_skiafontmgr.h182
-rw-r--r--core/src/fxge/android/fpf_skiamodule.cpp42
-rw-r--r--core/src/fxge/android/fpf_skiamodule.h18
-rw-r--r--core/src/fxge/android/fx_android_font.cpp131
-rw-r--r--core/src/fxge/android/fx_android_font.h51
-rw-r--r--core/src/fxge/android/fx_android_imp.cpp34
9 files changed, 902 insertions, 933 deletions
diff --git a/core/src/fxge/android/fpf_skiafont.cpp b/core/src/fxge/android/fpf_skiafont.cpp
index 2dad01057a..ba202acc92 100644
--- a/core/src/fxge/android/fpf_skiafont.cpp
+++ b/core/src/fxge/android/fpf_skiafont.cpp
@@ -8,197 +8,203 @@
#if _FX_OS_ == _FX_ANDROID_
#include "fpf_skiafont.h"
#include "fpf_skiafontmgr.h"
-#define FPF_EM_ADJUST(em, a) (em == 0 ? (a) : (a) * 1000 / em)
+#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_dwStyle(0)
- , m_uCharset(0)
- , m_dwRefCount(0)
-{
-}
-CFPF_SkiaFont::~CFPF_SkiaFont()
-{
- if (m_Face) {
- FXFT_Done_Face(m_Face);
- }
-}
-void CFPF_SkiaFont::Release()
-{
- if (--m_dwRefCount == 0) {
- delete this;
- }
-}
-IFPF_Font* CFPF_SkiaFont::Retain()
-{
- m_dwRefCount++;
- return (IFPF_Font*)this;
-}
-FPF_HFONT CFPF_SkiaFont::GetHandle()
-{
- return NULL;
-}
-CFX_ByteString CFPF_SkiaFont::GetFamilyName()
-{
- if (!m_Face) {
- return CFX_ByteString();
- }
- return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face));
-}
-CFX_WideString CFPF_SkiaFont::GetPsName()
-{
- 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) {
- return wUnicode;
- }
- 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) {
- return 0;
- }
- if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
- return 0;
- }
- 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) {
- 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) {
- return 0;
- }
- return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_Descender(m_Face));
+ : m_pFontMgr(NULL),
+ m_pFontDes(NULL),
+ m_Face(NULL),
+ m_dwStyle(0),
+ m_uCharset(0),
+ m_dwRefCount(0) {}
+CFPF_SkiaFont::~CFPF_SkiaFont() {
+ if (m_Face) {
+ FXFT_Done_Face(m_Face);
+ }
+}
+void CFPF_SkiaFont::Release() {
+ if (--m_dwRefCount == 0) {
+ delete this;
+ }
+}
+IFPF_Font* CFPF_SkiaFont::Retain() {
+ m_dwRefCount++;
+ return (IFPF_Font*)this;
+}
+FPF_HFONT CFPF_SkiaFont::GetHandle() {
+ return NULL;
+}
+CFX_ByteString CFPF_SkiaFont::GetFamilyName() {
+ if (!m_Face) {
+ return CFX_ByteString();
+ }
+ return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face));
+}
+CFX_WideString CFPF_SkiaFont::GetPsName() {
+ 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) {
+ return wUnicode;
+ }
+ if (FXFT_Select_Charmap(m_Face, FXFT_ENCODING_UNICODE)) {
+ return 0;
+ }
+ return FXFT_Get_Char_Index(m_Face, wUnicode);
}
-FX_BOOL CFPF_SkiaFont::GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox)
-{
- if (!m_Face) {
- return FALSE;
- }
- if (FXFT_Is_Face_Tricky(m_Face)) {
- 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);
- return FALSE;
- }
- FXFT_Glyph glyph;
- if (FXFT_Get_Glyph(m_Face->glyph, &glyph)) {
- FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
- return FALSE;
- }
- FXFT_BBox cbox;
- FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox);
- int32_t x_ppem = m_Face->size->metrics.x_ppem;
- int32_t y_ppem = m_Face->size->metrics.y_ppem;
- rtBBox.left = FPF_EM_ADJUST(x_ppem, cbox.xMin);
- rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax);
- rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax);
- rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin);
- rtBBox.top = FX_MIN(rtBBox.top, GetAscent());
- rtBBox.bottom = FX_MAX(rtBBox.bottom, GetDescent());
- FXFT_Done_Glyph(glyph);
- return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0;
- }
- if (FXFT_Load_Glyph(m_Face, iGlyphIndex, FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
- return FALSE;
- }
- rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingX(m_Face));
- rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingY(m_Face));
- rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face));
- rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), 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;
- }
- rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_xMin(m_Face));
- rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_yMin(m_Face));
- rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_xMax(m_Face));
- rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), FXFT_Get_Face_yMax(m_Face));
- return TRUE;
-}
-int32_t CFPF_SkiaFont::GetHeight() const
-{
- 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::GetGlyphWidth(int32_t iGlyphIndex) {
+ if (!m_Face) {
+ return 0;
+ }
+ if (FXFT_Load_Glyph(
+ m_Face, iGlyphIndex,
+ FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
+ return 0;
+ }
+ return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Glyph_HoriAdvance(m_Face));
}
-int32_t CFPF_SkiaFont::GetItalicAngle() const
-{
- if (!m_Face) {
- return 0;
- }
- TT_Postscript *ttInfo = (TT_Postscript*)FT_Get_Sfnt_Table(m_Face, ft_sfnt_post);
- if (ttInfo) {
- return ttInfo->italicAngle;
- }
+int32_t CFPF_SkiaFont::GetAscent() const {
+ if (!m_Face) {
return 0;
+ }
+ return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Face_Ascender(m_Face));
}
-FX_DWORD CFPF_SkiaFont::GetFontData(FX_DWORD dwTable, uint8_t* pBuffer, FX_DWORD dwSize)
-{
- 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)) {
- return 0;
- }
- return pdfium::base::checked_cast<FX_DWORD>(ulSize);
+int32_t CFPF_SkiaFont::GetDescent() const {
+ 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) {
+ return FALSE;
+ }
+ if (FXFT_Is_Face_Tricky(m_Face)) {
+ 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);
+ return FALSE;
+ }
+ FXFT_Glyph glyph;
+ if (FXFT_Get_Glyph(m_Face->glyph, &glyph)) {
+ FXFT_Set_Pixel_Sizes(m_Face, 0, 64);
+ return FALSE;
+ }
+ FXFT_BBox cbox;
+ FXFT_Glyph_Get_CBox(glyph, FXFT_GLYPH_BBOX_PIXELS, &cbox);
+ int32_t x_ppem = m_Face->size->metrics.x_ppem;
+ int32_t y_ppem = m_Face->size->metrics.y_ppem;
+ rtBBox.left = FPF_EM_ADJUST(x_ppem, cbox.xMin);
+ rtBBox.right = FPF_EM_ADJUST(x_ppem, cbox.xMax);
+ rtBBox.top = FPF_EM_ADJUST(y_ppem, cbox.yMax);
+ rtBBox.bottom = FPF_EM_ADJUST(y_ppem, cbox.yMin);
+ rtBBox.top = FX_MIN(rtBBox.top, GetAscent());
+ rtBBox.bottom = FX_MAX(rtBBox.bottom, GetDescent());
+ FXFT_Done_Glyph(glyph);
+ return FXFT_Set_Pixel_Sizes(m_Face, 0, 64) == 0;
+ }
+ if (FXFT_Load_Glyph(
+ m_Face, iGlyphIndex,
+ FXFT_LOAD_NO_SCALE | FXFT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH)) {
+ return FALSE;
+ }
+ rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Glyph_HoriBearingX(m_Face));
+ rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Glyph_HoriBearingY(m_Face));
+ rtBBox.right = FPF_EM_ADJUST(
+ FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Glyph_HoriBearingX(m_Face) + FXFT_Get_Glyph_Width(m_Face));
+ rtBBox.top = FPF_EM_ADJUST(
+ FXFT_Get_Face_UnitsPerEM(m_Face),
+ 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;
+ }
+ rtBBox.left = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Face_xMin(m_Face));
+ rtBBox.top = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Face_yMin(m_Face));
+ rtBBox.right = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Face_xMax(m_Face));
+ rtBBox.bottom = FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Face_yMax(m_Face));
+ return TRUE;
+}
+int32_t CFPF_SkiaFont::GetHeight() const {
+ if (!m_Face) {
+ return 0;
+ }
+ return FPF_EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face),
+ FXFT_Get_Face_Height(m_Face));
}
-FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uCharset)
-{
- 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;
- case FPF_SKIAFONTTYPE_File: {
- CFPF_SkiaFileFont *pFont = (CFPF_SkiaFileFont*)pFontDes;
- m_Face = pFontMgr->GetFontFace(pFont->m_pFile, pFont->m_iFaceIndex);
- }
- 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;
- default:
- return FALSE;
- }
- if (!m_Face) {
- return FALSE;
- }
- m_dwStyle = dwStyle;
- m_uCharset = uCharset;
- m_pFontMgr = pFontMgr;
- m_pFontDes = pFontDes;
- m_dwRefCount = 1;
- return TRUE;
+int32_t CFPF_SkiaFont::GetItalicAngle() const {
+ if (!m_Face) {
+ return 0;
+ }
+ TT_Postscript* ttInfo =
+ (TT_Postscript*)FT_Get_Sfnt_Table(m_Face, ft_sfnt_post);
+ if (ttInfo) {
+ return ttInfo->italicAngle;
+ }
+ return 0;
+}
+FX_DWORD CFPF_SkiaFont::GetFontData(FX_DWORD dwTable,
+ uint8_t* pBuffer,
+ FX_DWORD dwSize) {
+ 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)) {
+ return 0;
+ }
+ return pdfium::base::checked_cast<FX_DWORD>(ulSize);
+}
+FX_BOOL CFPF_SkiaFont::InitFont(CFPF_SkiaFontMgr* pFontMgr,
+ CFPF_SkiaFontDescriptor* pFontDes,
+ const CFX_ByteStringC& bsFamily,
+ FX_DWORD dwStyle,
+ uint8_t uCharset) {
+ 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;
+ case FPF_SKIAFONTTYPE_File: {
+ CFPF_SkiaFileFont* pFont = (CFPF_SkiaFileFont*)pFontDes;
+ m_Face = pFontMgr->GetFontFace(pFont->m_pFile, pFont->m_iFaceIndex);
+ } 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;
+ default:
+ return FALSE;
+ }
+ if (!m_Face) {
+ return FALSE;
+ }
+ m_dwStyle = dwStyle;
+ m_uCharset = uCharset;
+ m_pFontMgr = pFontMgr;
+ m_pFontDes = pFontDes;
+ m_dwRefCount = 1;
+ return TRUE;
}
#endif
diff --git a/core/src/fxge/android/fpf_skiafont.h b/core/src/fxge/android/fpf_skiafont.h
index 49819d4c11..4a841940df 100644
--- a/core/src/fxge/android/fpf_skiafont.h
+++ b/core/src/fxge/android/fpf_skiafont.h
@@ -11,48 +11,48 @@
class CFPF_SkiaFontDescriptor;
class CFPF_SkiaFontMgr;
class SkTypeface;
-class CFPF_SkiaFont : public IFPF_Font
-{
-public:
- CFPF_SkiaFont();
- virtual ~CFPF_SkiaFont();
- virtual void Release();
- virtual IFPF_Font* Retain();
-
- virtual FPF_HFONT GetHandle();
-
- virtual CFX_ByteString GetFamilyName();
- virtual CFX_WideString GetPsName();
-
- virtual FX_DWORD GetFontStyle() const
- {
- return m_dwStyle;
- }
- virtual uint8_t GetCharset() const
- {
- return m_uCharset;
- }
-
- virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode);
- virtual int32_t GetGlyphWidth(int32_t iGlyphIndex);
-
- virtual int32_t GetAscent() const;
- virtual int32_t GetDescent() const;
-
- virtual FX_BOOL GetGlyphBBox(int32_t iGlyphIndex, FX_RECT &rtBBox);
- virtual FX_BOOL GetBBox(FX_RECT &rtBBox);
-
- virtual int32_t GetHeight() const;
- virtual int32_t GetItalicAngle() const;
- virtual FX_DWORD GetFontData(FX_DWORD dwTable, uint8_t* pBuffer, FX_DWORD dwSize);
- FX_BOOL InitFont(CFPF_SkiaFontMgr *pFontMgr, CFPF_SkiaFontDescriptor *pFontDes, const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uCharset);
-protected:
- CFPF_SkiaFontMgr *m_pFontMgr;
- CFPF_SkiaFontDescriptor *m_pFontDes;
- FXFT_Face m_Face;
- FX_DWORD m_dwStyle;
- uint8_t m_uCharset;
- FX_DWORD m_dwRefCount;
+class CFPF_SkiaFont : public IFPF_Font {
+ public:
+ CFPF_SkiaFont();
+ virtual ~CFPF_SkiaFont();
+ virtual void Release();
+ virtual IFPF_Font* Retain();
+
+ virtual FPF_HFONT GetHandle();
+
+ virtual CFX_ByteString GetFamilyName();
+ virtual CFX_WideString GetPsName();
+
+ virtual FX_DWORD GetFontStyle() const { return m_dwStyle; }
+ virtual uint8_t GetCharset() const { return m_uCharset; }
+
+ virtual int32_t GetGlyphIndex(FX_WCHAR wUnicode);
+ virtual int32_t GetGlyphWidth(int32_t iGlyphIndex);
+
+ virtual int32_t GetAscent() const;
+ virtual int32_t GetDescent() const;
+
+ virtual FX_BOOL GetGlyphBBox(int32_t iGlyphIndex, FX_RECT& rtBBox);
+ virtual FX_BOOL GetBBox(FX_RECT& rtBBox);
+
+ virtual int32_t GetHeight() const;
+ virtual int32_t GetItalicAngle() const;
+ virtual FX_DWORD GetFontData(FX_DWORD dwTable,
+ uint8_t* pBuffer,
+ FX_DWORD dwSize);
+ FX_BOOL InitFont(CFPF_SkiaFontMgr* pFontMgr,
+ CFPF_SkiaFontDescriptor* pFontDes,
+ const CFX_ByteStringC& bsFamily,
+ FX_DWORD dwStyle,
+ uint8_t uCharset);
+
+ protected:
+ CFPF_SkiaFontMgr* m_pFontMgr;
+ CFPF_SkiaFontDescriptor* m_pFontDes;
+ FXFT_Face m_Face;
+ FX_DWORD m_dwStyle;
+ uint8_t m_uCharset;
+ FX_DWORD m_dwRefCount;
};
#endif
diff --git a/core/src/fxge/android/fpf_skiafontmgr.cpp b/core/src/fxge/android/fpf_skiafontmgr.cpp
index 86bb052435..b18e9c83be 100644
--- a/core/src/fxge/android/fpf_skiafontmgr.cpp
+++ b/core/src/fxge/android/fpf_skiafontmgr.cpp
@@ -6,466 +6,446 @@
#include "fx_fpf.h"
#if _FX_OS_ == _FX_ANDROID_
-#define FPF_SKIAMATCHWEIGHT_NAME1 62
-#define FPF_SKIAMATCHWEIGHT_NAME2 60
-#define FPF_SKIAMATCHWEIGHT_1 16
-#define FPF_SKIAMATCHWEIGHT_2 8
+#define FPF_SKIAMATCHWEIGHT_NAME1 62
+#define FPF_SKIAMATCHWEIGHT_NAME2 60
+#define FPF_SKIAMATCHWEIGHT_1 16
+#define FPF_SKIAMATCHWEIGHT_2 8
#include "fpf_skiafontmgr.h"
#include "fpf_skiafont.h"
#ifdef __cplusplus
extern "C" {
#endif
-static unsigned long FPF_SkiaStream_Read(FXFT_Stream stream, unsigned long offset, unsigned char* buffer, unsigned long count)
-{
- IFX_FileRead *pFileRead = (IFX_FileRead*)stream->descriptor.pointer;
- if (!pFileRead) {
- return 0;
- }
- if (count > 0) {
- if (pFileRead->ReadBlock(buffer, (FX_FILESIZE)offset, (size_t)count) != count) {
- return 0;
- }
- }
- return count;
-}
-static void FPF_SkiaStream_Close(FXFT_Stream stream)
-{
+static unsigned long FPF_SkiaStream_Read(FXFT_Stream stream,
+ unsigned long offset,
+ unsigned char* buffer,
+ unsigned long count) {
+ IFX_FileRead* pFileRead = (IFX_FileRead*)stream->descriptor.pointer;
+ if (!pFileRead) {
+ return 0;
+ }
+ if (count > 0) {
+ if (pFileRead->ReadBlock(buffer, (FX_FILESIZE)offset, (size_t)count) !=
+ count) {
+ return 0;
+ }
+ }
+ return count;
}
+static void FPF_SkiaStream_Close(FXFT_Stream stream) {}
#ifdef __cplusplus
};
#endif
typedef struct _FPF_SKIAFONTMAP {
- FX_DWORD dwFamily;
- FX_DWORD dwSubSt;
+ FX_DWORD dwFamily;
+ FX_DWORD dwSubSt;
} FPF_SKIAFONTMAP, *FPF_LPSKIAFONTMAP;
-typedef FPF_SKIAFONTMAP const * FPF_LPCSKIAFONTMAP;
+typedef FPF_SKIAFONTMAP const* FPF_LPCSKIAFONTMAP;
static const FPF_SKIAFONTMAP g_SkiaFontmap[] = {
- {0x58c5083, 0xc8d2e345},
- {0x5dfade2, 0xe1633081},
- {0x684317d, 0xe1633081},
- {0x14ee2d13, 0xc8d2e345},
- {0x3918fe2d, 0xbbeeec72},
- {0x3b98b31c, 0xe1633081},
- {0x3d49f40e, 0xe1633081},
- {0x432c41c5, 0xe1633081},
- {0x491b6ad0, 0xe1633081},
- {0x5612cab1, 0x59b9f8f1},
- {0x779ce19d, 0xc8d2e345},
- {0x7cc9510b, 0x59b9f8f1},
- {0x83746053, 0xbbeeec72},
- {0xaaa60c03, 0xbbeeec72},
- {0xbf85ff26, 0xe1633081},
- {0xc04fe601, 0xbbeeec72},
- {0xca3812d5, 0x59b9f8f1},
- {0xca383e15, 0x59b9f8f1},
- {0xcad5eaf6, 0x59b9f8f1},
- {0xcb7a04c8, 0xc8d2e345},
- {0xfb4ce0de, 0xe1633081},
+ {0x58c5083, 0xc8d2e345}, {0x5dfade2, 0xe1633081},
+ {0x684317d, 0xe1633081}, {0x14ee2d13, 0xc8d2e345},
+ {0x3918fe2d, 0xbbeeec72}, {0x3b98b31c, 0xe1633081},
+ {0x3d49f40e, 0xe1633081}, {0x432c41c5, 0xe1633081},
+ {0x491b6ad0, 0xe1633081}, {0x5612cab1, 0x59b9f8f1},
+ {0x779ce19d, 0xc8d2e345}, {0x7cc9510b, 0x59b9f8f1},
+ {0x83746053, 0xbbeeec72}, {0xaaa60c03, 0xbbeeec72},
+ {0xbf85ff26, 0xe1633081}, {0xc04fe601, 0xbbeeec72},
+ {0xca3812d5, 0x59b9f8f1}, {0xca383e15, 0x59b9f8f1},
+ {0xcad5eaf6, 0x59b9f8f1}, {0xcb7a04c8, 0xc8d2e345},
+ {0xfb4ce0de, 0xe1633081},
};
-FX_DWORD FPF_SkiaGetSubstFont(FX_DWORD dwHash)
-{
- int32_t iStart = 0;
- int32_t iEnd = sizeof(g_SkiaFontmap) / sizeof(FPF_SKIAFONTMAP);
- while (iStart <= iEnd) {
- int32_t iMid = (iStart + iEnd) / 2;
- FPF_LPCSKIAFONTMAP pItem = &g_SkiaFontmap[iMid];
- if (dwHash < pItem->dwFamily) {
- iEnd = iMid - 1;
- } else if (dwHash > pItem->dwFamily) {
- iStart = iMid + 1;
- } else {
- return pItem->dwSubSt;
- }
+FX_DWORD FPF_SkiaGetSubstFont(FX_DWORD dwHash) {
+ int32_t iStart = 0;
+ int32_t iEnd = sizeof(g_SkiaFontmap) / sizeof(FPF_SKIAFONTMAP);
+ while (iStart <= iEnd) {
+ int32_t iMid = (iStart + iEnd) / 2;
+ FPF_LPCSKIAFONTMAP pItem = &g_SkiaFontmap[iMid];
+ if (dwHash < pItem->dwFamily) {
+ iEnd = iMid - 1;
+ } else if (dwHash > pItem->dwFamily) {
+ iStart = iMid + 1;
+ } else {
+ return pItem->dwSubSt;
}
- return 0;
+ }
+ return 0;
}
static const FPF_SKIAFONTMAP g_SkiaSansFontMap[] = {
- {0x58c5083, 0xd5b8d10f},
- {0x14ee2d13, 0xd5b8d10f},
- {0x779ce19d, 0xd5b8d10f},
- {0xcb7a04c8, 0xd5b8d10f},
- {0xfb4ce0de, 0xd5b8d10f},
+ {0x58c5083, 0xd5b8d10f}, {0x14ee2d13, 0xd5b8d10f},
+ {0x779ce19d, 0xd5b8d10f}, {0xcb7a04c8, 0xd5b8d10f},
+ {0xfb4ce0de, 0xd5b8d10f},
};
-FX_DWORD FPF_SkiaGetSansFont(FX_DWORD dwHash)
-{
- int32_t iStart = 0;
- int32_t iEnd = sizeof(g_SkiaSansFontMap) / sizeof(FPF_SKIAFONTMAP);
- while (iStart <= iEnd) {
- int32_t iMid = (iStart + iEnd) / 2;
- FPF_LPCSKIAFONTMAP pItem = &g_SkiaSansFontMap[iMid];
- if (dwHash < pItem->dwFamily) {
- iEnd = iMid - 1;
- } else if (dwHash > pItem->dwFamily) {
- iStart = iMid + 1;
- } else {
- return pItem->dwSubSt;
- }
- }
- return 0;
-}
-static uint32_t FPF_GetHashCode_StringA(const FX_CHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase = FALSE)
-{
- if (!pStr) {
- return 0;
- }
- if (iLength < 0) {
- iLength = FXSYS_strlen(pStr);
- }
- const FX_CHAR* pStrEnd = pStr + iLength;
- uint32_t uHashCode = 0;
- if (bIgnoreCase) {
- while (pStr < pStrEnd) {
- uHashCode = 31 * uHashCode + FXSYS_tolower(*pStr++);
- }
+FX_DWORD FPF_SkiaGetSansFont(FX_DWORD dwHash) {
+ int32_t iStart = 0;
+ int32_t iEnd = sizeof(g_SkiaSansFontMap) / sizeof(FPF_SKIAFONTMAP);
+ while (iStart <= iEnd) {
+ int32_t iMid = (iStart + iEnd) / 2;
+ FPF_LPCSKIAFONTMAP pItem = &g_SkiaSansFontMap[iMid];
+ if (dwHash < pItem->dwFamily) {
+ iEnd = iMid - 1;
+ } else if (dwHash > pItem->dwFamily) {
+ iStart = iMid + 1;
} else {
- while (pStr < pStrEnd) {
- uHashCode = 31 * uHashCode + *pStr ++;
- }
+ return pItem->dwSubSt;
}
- return uHashCode;
+ }
+ return 0;
+}
+static uint32_t FPF_GetHashCode_StringA(const FX_CHAR* pStr,
+ int32_t iLength,
+ FX_BOOL bIgnoreCase = FALSE) {
+ if (!pStr) {
+ return 0;
+ }
+ if (iLength < 0) {
+ iLength = FXSYS_strlen(pStr);
+ }
+ const FX_CHAR* pStrEnd = pStr + iLength;
+ uint32_t uHashCode = 0;
+ if (bIgnoreCase) {
+ while (pStr < pStrEnd) {
+ uHashCode = 31 * uHashCode + FXSYS_tolower(*pStr++);
+ }
+ } else {
+ while (pStr < pStrEnd) {
+ uHashCode = 31 * uHashCode + *pStr++;
+ }
+ }
+ return uHashCode;
}
enum FPF_SKIACHARSET {
- FPF_SKIACHARSET_Ansi = 1 << 0,
- FPF_SKIACHARSET_Default = 1 << 1,
- FPF_SKIACHARSET_Symbol = 1 << 2,
- FPF_SKIACHARSET_ShiftJIS = 1 << 3,
- FPF_SKIACHARSET_Korean = 1 << 4,
- FPF_SKIACHARSET_Johab = 1 << 5,
- FPF_SKIACHARSET_GB2312 = 1 << 6,
- FPF_SKIACHARSET_BIG5 = 1 << 7,
- FPF_SKIACHARSET_Greek = 1 << 8,
- FPF_SKIACHARSET_Turkish = 1 << 9,
- FPF_SKIACHARSET_Vietnamese = 1 << 10,
- FPF_SKIACHARSET_Hebrew = 1 << 11,
- FPF_SKIACHARSET_Arabic = 1 << 12,
- FPF_SKIACHARSET_Baltic = 1 << 13,
- FPF_SKIACHARSET_Cyrillic = 1 << 14,
- FPF_SKIACHARSET_Thai = 1 << 15,
- FPF_SKIACHARSET_EeasternEuropean = 1 << 16,
- FPF_SKIACHARSET_PC = 1 << 17,
- FPF_SKIACHARSET_OEM = 1 << 18,
+ FPF_SKIACHARSET_Ansi = 1 << 0,
+ FPF_SKIACHARSET_Default = 1 << 1,
+ FPF_SKIACHARSET_Symbol = 1 << 2,
+ FPF_SKIACHARSET_ShiftJIS = 1 << 3,
+ FPF_SKIACHARSET_Korean = 1 << 4,
+ FPF_SKIACHARSET_Johab = 1 << 5,
+ FPF_SKIACHARSET_GB2312 = 1 << 6,
+ FPF_SKIACHARSET_BIG5 = 1 << 7,
+ FPF_SKIACHARSET_Greek = 1 << 8,
+ FPF_SKIACHARSET_Turkish = 1 << 9,
+ FPF_SKIACHARSET_Vietnamese = 1 << 10,
+ FPF_SKIACHARSET_Hebrew = 1 << 11,
+ FPF_SKIACHARSET_Arabic = 1 << 12,
+ FPF_SKIACHARSET_Baltic = 1 << 13,
+ FPF_SKIACHARSET_Cyrillic = 1 << 14,
+ FPF_SKIACHARSET_Thai = 1 << 15,
+ FPF_SKIACHARSET_EeasternEuropean = 1 << 16,
+ FPF_SKIACHARSET_PC = 1 << 17,
+ FPF_SKIACHARSET_OEM = 1 << 18,
};
-static FX_DWORD FPF_SkiaGetCharset(uint8_t uCharset)
-{
- switch (uCharset) {
- case FXFONT_ANSI_CHARSET:
- return FPF_SKIACHARSET_Ansi;
- case FXFONT_DEFAULT_CHARSET:
- return FPF_SKIACHARSET_Default;
- case FXFONT_SYMBOL_CHARSET:
- return FPF_SKIACHARSET_Symbol;
- case FXFONT_SHIFTJIS_CHARSET:
- return FPF_SKIACHARSET_ShiftJIS;
- case FXFONT_HANGEUL_CHARSET:
- return FPF_SKIACHARSET_Korean;
- case FXFONT_GB2312_CHARSET:
- return FPF_SKIACHARSET_GB2312;
- case FXFONT_CHINESEBIG5_CHARSET:
- return FPF_SKIACHARSET_BIG5;
- case FXFONT_GREEK_CHARSET:
- return FPF_SKIACHARSET_Greek;
- case FXFONT_TURKISH_CHARSET:
- return FPF_SKIACHARSET_Turkish;
- case FXFONT_HEBREW_CHARSET:
- return FPF_SKIACHARSET_Hebrew;
- case FXFONT_ARABIC_CHARSET:
- return FPF_SKIACHARSET_Arabic;
- case FXFONT_BALTIC_CHARSET:
- return FPF_SKIACHARSET_Baltic;
- case FXFONT_RUSSIAN_CHARSET:
- return FPF_SKIACHARSET_Cyrillic;
- case FXFONT_THAI_CHARSET:
- return FPF_SKIACHARSET_Thai;
- case FXFONT_EASTEUROPE_CHARSET:
- return FPF_SKIACHARSET_EeasternEuropean;
- }
- return FPF_SKIACHARSET_Default;
-}
-static FX_DWORD FPF_SKIANormalizeFontName(const CFX_ByteStringC& bsfamily)
-{
- FX_DWORD dwHash = 0;
- int32_t iLength = bsfamily.GetLength();
- const FX_CHAR* pBuffer = bsfamily.GetCStr();
- for (int32_t i = 0; i < iLength; i++) {
- FX_CHAR ch = pBuffer[i];
- if (ch == ' ' || ch == '-' || ch == ',') {
- continue;
- }
- dwHash = 31 * dwHash + FXSYS_tolower(ch);
- }
- return dwHash;
+static FX_DWORD FPF_SkiaGetCharset(uint8_t uCharset) {
+ switch (uCharset) {
+ case FXFONT_ANSI_CHARSET:
+ return FPF_SKIACHARSET_Ansi;
+ case FXFONT_DEFAULT_CHARSET:
+ return FPF_SKIACHARSET_Default;
+ case FXFONT_SYMBOL_CHARSET:
+ return FPF_SKIACHARSET_Symbol;
+ case FXFONT_SHIFTJIS_CHARSET:
+ return FPF_SKIACHARSET_ShiftJIS;
+ case FXFONT_HANGEUL_CHARSET:
+ return FPF_SKIACHARSET_Korean;
+ case FXFONT_GB2312_CHARSET:
+ return FPF_SKIACHARSET_GB2312;
+ case FXFONT_CHINESEBIG5_CHARSET:
+ return FPF_SKIACHARSET_BIG5;
+ case FXFONT_GREEK_CHARSET:
+ return FPF_SKIACHARSET_Greek;
+ case FXFONT_TURKISH_CHARSET:
+ return FPF_SKIACHARSET_Turkish;
+ case FXFONT_HEBREW_CHARSET:
+ return FPF_SKIACHARSET_Hebrew;
+ case FXFONT_ARABIC_CHARSET:
+ return FPF_SKIACHARSET_Arabic;
+ case FXFONT_BALTIC_CHARSET:
+ return FPF_SKIACHARSET_Baltic;
+ case FXFONT_RUSSIAN_CHARSET:
+ return FPF_SKIACHARSET_Cyrillic;
+ case FXFONT_THAI_CHARSET:
+ return FPF_SKIACHARSET_Thai;
+ case FXFONT_EASTEUROPE_CHARSET:
+ return FPF_SKIACHARSET_EeasternEuropean;
+ }
+ return FPF_SKIACHARSET_Default;
}
-static FX_DWORD FPF_SKIAGetFamilyHash(const CFX_ByteStringC& bsFamily, FX_DWORD dwStyle, uint8_t uCharset)
-{
- CFX_ByteString bsFont(bsFamily);
- if (dwStyle & FXFONT_BOLD) {
- bsFont += "Bold";
- }
- if (dwStyle & FXFONT_ITALIC) {
- bsFont += "Italic";
- }
- if (dwStyle & FXFONT_SERIF) {
- bsFont += "Serif";
- }
- bsFont += uCharset;
- return FPF_GetHashCode_StringA(bsFont.c_str(), bsFont.GetLength(), TRUE);
+static FX_DWORD FPF_SKIANormalizeFontName(const CFX_ByteStringC& bsfamily) {
+ FX_DWORD dwHash = 0;
+ int32_t iLength = bsfamily.GetLength();
+ const FX_CHAR* pBuffer = bsfamily.GetCStr();
+ for (int32_t i = 0; i < iLength; i++) {
+ FX_CHAR ch = pBuffer[i];
+ if (ch == ' ' || ch == '-' || ch == ',') {
+ continue;
+ }
+ dwHash = 31 * dwHash + FXSYS_tolower(ch);
+ }
+ return dwHash;
}
-static FX_BOOL FPF_SkiaIsCJK(uint8_t uCharset)
-{
- return (uCharset == FXFONT_GB2312_CHARSET) || (uCharset == FXFONT_CHINESEBIG5_CHARSET)
- || (uCharset == FXFONT_HANGEUL_CHARSET) || (uCharset == FXFONT_SHIFTJIS_CHARSET);
+static FX_DWORD FPF_SKIAGetFamilyHash(const CFX_ByteStringC& bsFamily,
+ FX_DWORD dwStyle,
+ uint8_t uCharset) {
+ CFX_ByteString bsFont(bsFamily);
+ if (dwStyle & FXFONT_BOLD) {
+ bsFont += "Bold";
+ }
+ if (dwStyle & FXFONT_ITALIC) {
+ bsFont += "Italic";
+ }
+ if (dwStyle & FXFONT_SERIF) {
+ bsFont += "Serif";
+ }
+ bsFont += uCharset;
+ return FPF_GetHashCode_StringA(bsFont.c_str(), bsFont.GetLength(), TRUE);
}
-static FX_BOOL FPF_SkiaMaybeSymbol(const CFX_ByteStringC& bsFacename)
-{
- CFX_ByteString bsName = bsFacename;
- bsName.MakeLower();
- return bsName.Find("symbol") > -1;
+static FX_BOOL FPF_SkiaIsCJK(uint8_t uCharset) {
+ return (uCharset == FXFONT_GB2312_CHARSET) ||
+ (uCharset == FXFONT_CHINESEBIG5_CHARSET) ||
+ (uCharset == FXFONT_HANGEUL_CHARSET) ||
+ (uCharset == FXFONT_SHIFTJIS_CHARSET);
}
-static FX_BOOL FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename)
-{
- CFX_ByteString bsName = bsFacename;
- bsName.MakeLower();
- return bsName.Find("arabic") > -1;
+static FX_BOOL FPF_SkiaMaybeSymbol(const CFX_ByteStringC& bsFacename) {
+ CFX_ByteString bsName = bsFacename;
+ bsName.MakeLower();
+ return bsName.Find("symbol") > -1;
}
-CFPF_SkiaFontMgr::CFPF_SkiaFontMgr()
- : m_bLoaded(FALSE), m_FTLibrary(NULL)
-{
+static FX_BOOL FPF_SkiaMaybeArabic(const CFX_ByteStringC& bsFacename) {
+ CFX_ByteString bsName = bsFacename;
+ bsName.MakeLower();
+ return bsName.Find("arabic") > -1;
}
-CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr()
-{
- void *pkey = NULL;
- CFPF_SkiaFont *pValue = NULL;
- FX_POSITION pos = m_FamilyFonts.GetStartPosition();
- while (pos) {
- m_FamilyFonts.GetNextAssoc(pos, pkey, (void*&)pValue);
- if (pValue) {
- pValue->Release();
- }
- }
- m_FamilyFonts.RemoveAll();
- for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) {
- CFPF_SkiaFontDescriptor *pFont = (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(i);
- delete pFont;
- }
- m_FontFaces.RemoveAll();
- if (m_FTLibrary) {
- FXFT_Done_FreeType(m_FTLibrary);
- }
+CFPF_SkiaFontMgr::CFPF_SkiaFontMgr() : m_bLoaded(FALSE), m_FTLibrary(NULL) {}
+CFPF_SkiaFontMgr::~CFPF_SkiaFontMgr() {
+ void* pkey = NULL;
+ CFPF_SkiaFont* pValue = NULL;
+ FX_POSITION pos = m_FamilyFonts.GetStartPosition();
+ while (pos) {
+ m_FamilyFonts.GetNextAssoc(pos, pkey, (void*&)pValue);
+ if (pValue) {
+ pValue->Release();
+ }
+ }
+ m_FamilyFonts.RemoveAll();
+ for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) {
+ CFPF_SkiaFontDescriptor* pFont =
+ (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(i);
+ delete pFont;
+ }
+ m_FontFaces.RemoveAll();
+ if (m_FTLibrary) {
+ FXFT_Done_FreeType(m_FTLibrary);
+ }
}
-FX_BOOL CFPF_SkiaFontMgr::InitFTLibrary()
-{
- if (m_FTLibrary == NULL) {
- FXFT_Init_FreeType(&m_FTLibrary);
- }
- return m_FTLibrary != NULL;
+FX_BOOL CFPF_SkiaFontMgr::InitFTLibrary() {
+ if (m_FTLibrary == NULL) {
+ FXFT_Init_FreeType(&m_FTLibrary);
+ }
+ return m_FTLibrary != NULL;
}
-void CFPF_SkiaFontMgr::LoadSystemFonts()
-{
- if (m_bLoaded) {
- return;
- }
- ScanPath(FX_BSTRC("/system/fonts"));
- OutputSystemFonts();
- m_bLoaded = TRUE;
-}
-void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile)
-{
+void CFPF_SkiaFontMgr::LoadSystemFonts() {
+ if (m_bLoaded) {
+ return;
+ }
+ ScanPath(FX_BSTRC("/system/fonts"));
+ OutputSystemFonts();
+ m_bLoaded = TRUE;
}
-void CFPF_SkiaFontMgr::LoadPrivateFont(const CFX_ByteStringC& bsFileName)
-{
+void CFPF_SkiaFontMgr::LoadPrivateFont(IFX_FileRead* pFontFile) {}
+void CFPF_SkiaFontMgr::LoadPrivateFont(const CFX_ByteStringC& bsFileName) {}
+void CFPF_SkiaFontMgr::LoadPrivateFont(void* pBuffer, size_t szBuffer) {}
+IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname,
+ uint8_t uCharset,
+ FX_DWORD dwStyle,
+ FX_DWORD dwMatch) {
+ FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
+ IFPF_Font* pFont = NULL;
+ if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
+ if (pFont) {
+ return pFont->Retain();
+ }
+ }
+ FX_DWORD dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname);
+ FX_DWORD dwSubst = FPF_SkiaGetSubstFont(dwFaceName);
+ FX_DWORD dwSubstSans = FPF_SkiaGetSansFont(dwFaceName);
+ FX_BOOL bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname);
+ if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) {
+ uCharset = FXFONT_ARABIC_CHARSET;
+ } else if (uCharset == FXFONT_ANSI_CHARSET &&
+ (dwMatch & FPF_MATCHFONT_REPLACEANSI)) {
+ uCharset = FXFONT_DEFAULT_CHARSET;
+ }
+ int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 +
+ FPF_SKIAMATCHWEIGHT_2 * 2;
+ int32_t nItem = -1;
+ int32_t nMax = -1;
+ int32_t nGlyphNum = 0;
+ for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) {
+ CFPF_SkiaPathFont* pFontDes = (CFPF_SkiaPathFont*)m_FontFaces.ElementAt(i);
+ if (!(pFontDes->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) {
+ continue;
+ }
+ int32_t nFind = 0;
+ FX_DWORD dwSysFontName = FPF_SKIANormalizeFontName(pFontDes->m_pFamily);
+ if (dwFaceName == dwSysFontName) {
+ nFind += FPF_SKIAMATCHWEIGHT_NAME1;
+ }
+ FX_BOOL bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1);
+ if ((dwStyle & FXFONT_BOLD) == (pFontDes->m_dwStyle & FXFONT_BOLD)) {
+ nFind += FPF_SKIAMATCHWEIGHT_1;
+ }
+ if ((dwStyle & FXFONT_ITALIC) == (pFontDes->m_dwStyle & FXFONT_ITALIC)) {
+ nFind += FPF_SKIAMATCHWEIGHT_1;
+ }
+ if ((dwStyle & FXFONT_FIXED_PITCH) ==
+ (pFontDes->m_dwStyle & FXFONT_FIXED_PITCH)) {
+ nFind += FPF_SKIAMATCHWEIGHT_2;
+ }
+ if ((dwStyle & FXFONT_SERIF) == (pFontDes->m_dwStyle & FXFONT_SERIF)) {
+ nFind += FPF_SKIAMATCHWEIGHT_1;
+ }
+ if ((dwStyle & FXFONT_SCRIPT) == (pFontDes->m_dwStyle & FXFONT_SCRIPT)) {
+ nFind += FPF_SKIAMATCHWEIGHT_2;
+ }
+ if (dwSubst == dwSysFontName || dwSubstSans == dwSysFontName) {
+ nFind += FPF_SKIAMATCHWEIGHT_NAME2;
+ bMatchedName = TRUE;
+ }
+ if (uCharset == FXFONT_DEFAULT_CHARSET || bMaybeSymbol) {
+ if (nFind > nMax && bMatchedName) {
+ nMax = nFind;
+ nItem = i;
+ }
+ } else if (FPF_SkiaIsCJK(uCharset)) {
+ if (bMatchedName || pFontDes->m_iGlyphNum > nGlyphNum) {
+ nItem = i;
+ nGlyphNum = pFontDes->m_iGlyphNum;
+ }
+ } else if (nFind > nMax) {
+ nMax = nFind;
+ nItem = i;
+ }
+ if (nExpectVal <= nFind) {
+ nItem = i;
+ break;
+ }
+ }
+ if (nItem > -1) {
+ CFPF_SkiaFontDescriptor* pFontDes =
+ (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(nItem);
+ CFPF_SkiaFont* pFont = new CFPF_SkiaFont;
+ if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) {
+ m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
+ return pFont->Retain();
+ }
+ pFont->Release();
+ }
+ return NULL;
}
-void CFPF_SkiaFontMgr::LoadPrivateFont(void* pBuffer, size_t szBuffer)
-{
-}
-IFPF_Font* CFPF_SkiaFontMgr::CreateFont(const CFX_ByteStringC& bsFamilyname, uint8_t uCharset, FX_DWORD dwStyle, FX_DWORD dwMatch)
-{
- FX_DWORD dwHash = FPF_SKIAGetFamilyHash(bsFamilyname, dwStyle, uCharset);
- IFPF_Font *pFont = NULL;
- if (m_FamilyFonts.Lookup((void*)(uintptr_t)dwHash, (void*&)pFont)) {
- if (pFont) {
- return pFont->Retain();
- }
- }
- FX_DWORD dwFaceName = FPF_SKIANormalizeFontName(bsFamilyname);
- FX_DWORD dwSubst = FPF_SkiaGetSubstFont(dwFaceName);
- FX_DWORD dwSubstSans = FPF_SkiaGetSansFont(dwFaceName);
- FX_BOOL bMaybeSymbol = FPF_SkiaMaybeSymbol(bsFamilyname);
- if (uCharset != FXFONT_ARABIC_CHARSET && FPF_SkiaMaybeArabic(bsFamilyname)) {
- uCharset = FXFONT_ARABIC_CHARSET;
- } else if (uCharset == FXFONT_ANSI_CHARSET && (dwMatch & FPF_MATCHFONT_REPLACEANSI)) {
- uCharset = FXFONT_DEFAULT_CHARSET;
- }
- int32_t nExpectVal = FPF_SKIAMATCHWEIGHT_NAME1 + FPF_SKIAMATCHWEIGHT_1 * 3 + FPF_SKIAMATCHWEIGHT_2 * 2;
- int32_t nItem = -1;
- int32_t nMax = -1;
- int32_t nGlyphNum = 0;
- for (int32_t i = m_FontFaces.GetUpperBound(); i >= 0; i--) {
- CFPF_SkiaPathFont *pFontDes = (CFPF_SkiaPathFont*)m_FontFaces.ElementAt(i);
- if(!(pFontDes->m_dwCharsets & FPF_SkiaGetCharset(uCharset))) {
- continue;
- }
- int32_t nFind = 0;
- FX_DWORD dwSysFontName = FPF_SKIANormalizeFontName(pFontDes->m_pFamily);
- if (dwFaceName == dwSysFontName) {
- nFind += FPF_SKIAMATCHWEIGHT_NAME1;
- }
- FX_BOOL bMatchedName = (nFind == FPF_SKIAMATCHWEIGHT_NAME1);
- if ((dwStyle & FXFONT_BOLD) == (pFontDes->m_dwStyle & FXFONT_BOLD)) {
- nFind += FPF_SKIAMATCHWEIGHT_1;
- }
- if ((dwStyle & FXFONT_ITALIC) == (pFontDes->m_dwStyle & FXFONT_ITALIC)) {
- nFind += FPF_SKIAMATCHWEIGHT_1;
- }
- if ((dwStyle & FXFONT_FIXED_PITCH) == (pFontDes->m_dwStyle & FXFONT_FIXED_PITCH)) {
- nFind += FPF_SKIAMATCHWEIGHT_2;
- }
- if ((dwStyle & FXFONT_SERIF) == (pFontDes->m_dwStyle & FXFONT_SERIF)) {
- nFind += FPF_SKIAMATCHWEIGHT_1;
- }
- if ((dwStyle & FXFONT_SCRIPT) == (pFontDes->m_dwStyle & FXFONT_SCRIPT)) {
- nFind += FPF_SKIAMATCHWEIGHT_2;
- }
- if (dwSubst == dwSysFontName || dwSubstSans == dwSysFontName) {
- nFind += FPF_SKIAMATCHWEIGHT_NAME2;
- bMatchedName = TRUE;
- }
- if (uCharset == FXFONT_DEFAULT_CHARSET || bMaybeSymbol) {
- if (nFind > nMax && bMatchedName) {
- nMax = nFind;
- nItem = i;
- }
- } else if (FPF_SkiaIsCJK(uCharset)) {
- if (bMatchedName || pFontDes->m_iGlyphNum > nGlyphNum) {
- nItem = i;
- nGlyphNum = pFontDes->m_iGlyphNum;
- }
- } else if (nFind > nMax) {
- nMax = nFind;
- nItem = i;
- }
- if (nExpectVal <= nFind) {
- nItem = i;
- break;
- }
- }
- if (nItem > -1) {
- CFPF_SkiaFontDescriptor *pFontDes = (CFPF_SkiaFontDescriptor*)m_FontFaces.ElementAt(nItem);
- CFPF_SkiaFont *pFont = new CFPF_SkiaFont;
- if (pFont->InitFont(this, pFontDes, bsFamilyname, dwStyle, uCharset)) {
- m_FamilyFonts.SetAt((void*)(uintptr_t)dwHash, (void*)pFont);
- return pFont->Retain();
- }
- pFont->Release();
- }
+FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead,
+ int32_t iFaceIndex) {
+ if (!pFileRead) {
return NULL;
+ }
+ if (pFileRead->GetSize() == 0) {
+ return NULL;
+ }
+ if (iFaceIndex < 0) {
+ return NULL;
+ }
+ FXFT_StreamRec streamRec;
+ FXSYS_memset(&streamRec, 0, sizeof(FXFT_StreamRec));
+ streamRec.size = pFileRead->GetSize();
+ streamRec.descriptor.pointer = pFileRead;
+ streamRec.read = FPF_SkiaStream_Read;
+ streamRec.close = FPF_SkiaStream_Close;
+ FXFT_Open_Args args;
+ args.flags = FT_OPEN_STREAM;
+ args.stream = &streamRec;
+ FXFT_Face face;
+ if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
+ return NULL;
+ }
+ FXFT_Set_Pixel_Sizes(face, 0, 64);
+ return face;
}
-FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead *pFileRead, int32_t iFaceIndex)
-{
- if (!pFileRead) {
- return NULL;
- }
- if (pFileRead->GetSize() == 0) {
- return NULL;
- }
- if (iFaceIndex < 0) {
- return NULL;
- }
- FXFT_StreamRec streamRec;
- FXSYS_memset(&streamRec, 0, sizeof(FXFT_StreamRec));
- streamRec.size = pFileRead->GetSize();
- streamRec.descriptor.pointer = pFileRead;
- streamRec.read = FPF_SkiaStream_Read;
- streamRec.close = FPF_SkiaStream_Close;
- FXFT_Open_Args args;
- args.flags = FT_OPEN_STREAM;
- args.stream = &streamRec;
- FXFT_Face face;
- if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
- return NULL;
- }
- FXFT_Set_Pixel_Sizes(face, 0, 64);
- return face;
-}
-FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex )
-{
- if (bsFile.IsEmpty()) {
- return NULL;
- }
- if (iFaceIndex < 0) {
- return NULL;
- }
- FXFT_Open_Args args;
- args.flags = FT_OPEN_PATHNAME;
- args.pathname = (FT_String*)bsFile.GetCStr();
- FXFT_Face face;
- if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
- return FALSE;
- }
- FXFT_Set_Pixel_Sizes(face, 0, 64);
- return face;
+FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const CFX_ByteStringC& bsFile,
+ int32_t iFaceIndex) {
+ if (bsFile.IsEmpty()) {
+ return NULL;
+ }
+ if (iFaceIndex < 0) {
+ return NULL;
+ }
+ FXFT_Open_Args args;
+ args.flags = FT_OPEN_PATHNAME;
+ args.pathname = (FT_String*)bsFile.GetCStr();
+ FXFT_Face face;
+ if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
+ return FALSE;
+ }
+ FXFT_Set_Pixel_Sizes(face, 0, 64);
+ return face;
}
-FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer, size_t szBuffer, int32_t iFaceIndex )
-{
- if (!pBuffer || szBuffer < 1) {
- return NULL;
- }
- if (iFaceIndex < 0) {
- return NULL;
- }
- FXFT_Open_Args args;
- args.flags = FT_OPEN_MEMORY;
- args.memory_base = pBuffer;
- args.memory_size = szBuffer;
- FXFT_Face face;
- if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
- return FALSE;
- }
- FXFT_Set_Pixel_Sizes(face, 0, 64);
- return face;
+FXFT_Face CFPF_SkiaFontMgr::GetFontFace(const uint8_t* pBuffer,
+ size_t szBuffer,
+ int32_t iFaceIndex) {
+ if (!pBuffer || szBuffer < 1) {
+ return NULL;
+ }
+ if (iFaceIndex < 0) {
+ return NULL;
+ }
+ FXFT_Open_Args args;
+ args.flags = FT_OPEN_MEMORY;
+ args.memory_base = pBuffer;
+ args.memory_size = szBuffer;
+ FXFT_Face face;
+ if (FXFT_Open_Face(m_FTLibrary, &args, iFaceIndex, &face)) {
+ return FALSE;
+ }
+ FXFT_Set_Pixel_Sizes(face, 0, 64);
+ return face;
}
-void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteStringC& path)
-{
- void *handle = FX_OpenFolder(path.GetCStr());
- if (!handle) {
- return;
- }
- CFX_ByteString filename;
- FX_BOOL bFolder = FALSE;
- while (FX_GetNextFile(handle, filename, bFolder)) {
- if (bFolder) {
- if (filename == FX_BSTRC(".") || filename == FX_BSTRC("..")) {
- continue;
- }
- } else {
- CFX_ByteString ext = filename.Right(4);
- ext.MakeLower();
- if (ext != FX_BSTRC(".ttf") && ext != FX_BSTRC(".ttc")) {
- continue;
- }
- }
- CFX_ByteString fullpath = path;
- fullpath += "/";
- fullpath += filename;
- if (bFolder) {
- ScanPath(fullpath);
- } else {
- ScanFile(fullpath);
- }
+void CFPF_SkiaFontMgr::ScanPath(const CFX_ByteStringC& path) {
+ void* handle = FX_OpenFolder(path.GetCStr());
+ if (!handle) {
+ return;
+ }
+ CFX_ByteString filename;
+ FX_BOOL bFolder = FALSE;
+ while (FX_GetNextFile(handle, filename, bFolder)) {
+ if (bFolder) {
+ if (filename == FX_BSTRC(".") || filename == FX_BSTRC("..")) {
+ continue;
+ }
+ } else {
+ CFX_ByteString ext = filename.Right(4);
+ ext.MakeLower();
+ if (ext != FX_BSTRC(".ttf") && ext != FX_BSTRC(".ttc")) {
+ continue;
+ }
+ }
+ CFX_ByteString fullpath = path;
+ fullpath += "/";
+ fullpath += filename;
+ if (bFolder) {
+ ScanPath(fullpath);
+ } else {
+ ScanFile(fullpath);
}
- FX_CloseFolder(handle);
+ }
+ FX_CloseFolder(handle);
}
-void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteStringC& file)
-{
- FXFT_Face face = GetFontFace(file);
- if (face) {
- CFPF_SkiaPathFont *pFontDesc = new CFPF_SkiaPathFont;
- pFontDesc->SetPath(file.GetCStr());
- ReportFace(face, pFontDesc);
- m_FontFaces.Add(pFontDesc);
- FXFT_Done_Face(face);
- }
+void CFPF_SkiaFontMgr::ScanFile(const CFX_ByteStringC& file) {
+ FXFT_Face face = GetFontFace(file);
+ if (face) {
+ CFPF_SkiaPathFont* pFontDesc = new CFPF_SkiaPathFont;
+ pFontDesc->SetPath(file.GetCStr());
+ ReportFace(face, pFontDesc);
+ m_FontFaces.Add(pFontDesc);
+ FXFT_Done_Face(face);
+ }
}
-static const FX_DWORD g_FPFSkiaFontCharsets [] = {
+static const FX_DWORD g_FPFSkiaFontCharsets[] = {
FPF_SKIACHARSET_Ansi,
FPF_SKIACHARSET_EeasternEuropean,
FPF_SKIACHARSET_Cyrillic,
@@ -499,54 +479,51 @@ static const FX_DWORD g_FPFSkiaFontCharsets [] = {
FPF_SKIACHARSET_OEM,
FPF_SKIACHARSET_Symbol,
};
-static FX_DWORD FPF_SkiaGetFaceCharset(TT_OS2 *pOS2)
-{
- FX_DWORD dwCharset = 0;
- if (pOS2) {
- for (int32_t i = 0; i < 32; i++) {
- if (pOS2->ulCodePageRange1 & (1 << i)) {
- dwCharset |= g_FPFSkiaFontCharsets[i];
- }
- }
- }
- dwCharset |= FPF_SKIACHARSET_Default;
- return dwCharset;
-}
-void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor *pFontDesc)
-{
- if (!face || !pFontDesc) {
- return;
- }
- pFontDesc->SetFamily(FXFT_Get_Face_Family_Name(face));
- if (FXFT_Is_Face_Bold(face)) {
- pFontDesc->m_dwStyle |= FXFONT_BOLD;
- }
- if (FXFT_Is_Face_Italic(face)) {
- pFontDesc->m_dwStyle |= FXFONT_ITALIC;
- }
- if (FT_IS_FIXED_WIDTH(face)) {
- pFontDesc->m_dwStyle |= FXFONT_FIXED_PITCH;
- }
- TT_OS2 *pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
- if (pOS2) {
- if (pOS2->ulCodePageRange1 & (1 << 31)) {
- pFontDesc->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;
- }
- }
- }
- 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;
+static FX_DWORD FPF_SkiaGetFaceCharset(TT_OS2* pOS2) {
+ FX_DWORD dwCharset = 0;
+ if (pOS2) {
+ for (int32_t i = 0; i < 32; i++) {
+ if (pOS2->ulCodePageRange1 & (1 << i)) {
+ dwCharset |= g_FPFSkiaFontCharsets[i];
+ }
+ }
+ }
+ dwCharset |= FPF_SKIACHARSET_Default;
+ return dwCharset;
}
-void CFPF_SkiaFontMgr::OutputSystemFonts()
-{
+void CFPF_SkiaFontMgr::ReportFace(FXFT_Face face,
+ CFPF_SkiaFontDescriptor* pFontDesc) {
+ if (!face || !pFontDesc) {
+ return;
+ }
+ pFontDesc->SetFamily(FXFT_Get_Face_Family_Name(face));
+ if (FXFT_Is_Face_Bold(face)) {
+ pFontDesc->m_dwStyle |= FXFONT_BOLD;
+ }
+ if (FXFT_Is_Face_Italic(face)) {
+ pFontDesc->m_dwStyle |= FXFONT_ITALIC;
+ }
+ if (FT_IS_FIXED_WIDTH(face)) {
+ pFontDesc->m_dwStyle |= FXFONT_FIXED_PITCH;
+ }
+ TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(face, ft_sfnt_os2);
+ if (pOS2) {
+ if (pOS2->ulCodePageRange1 & (1 << 31)) {
+ pFontDesc->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;
+ }
+ }
+ }
+ 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;
}
+void CFPF_SkiaFontMgr::OutputSystemFonts() {}
#endif
diff --git a/core/src/fxge/android/fpf_skiafontmgr.h b/core/src/fxge/android/fpf_skiafontmgr.h
index 8c721ff68a..c5dd8fd1b2 100644
--- a/core/src/fxge/android/fpf_skiafontmgr.h
+++ b/core/src/fxge/android/fpf_skiafontmgr.h
@@ -8,111 +8,101 @@
#define CORE_SRC_FXGE_ANDROID_FPF_SKIAFONTMGR_H_
#if _FX_OS_ == _FX_ANDROID_
-#define FPF_SKIAFONTTYPE_Unknown 0
-#define FPF_SKIAFONTTYPE_Path 1
-#define FPF_SKIAFONTTYPE_File 2
-#define FPF_SKIAFONTTYPE_Buffer 3
-class CFPF_SkiaFontDescriptor
-{
-public:
- CFPF_SkiaFontDescriptor() : m_pFamily(NULL), m_dwStyle(0), m_iFaceIndex(0), m_dwCharsets(0), m_iGlyphNum(0) {}
- virtual ~CFPF_SkiaFontDescriptor()
- {
- if (m_pFamily) {
- FX_Free(m_pFamily);
- }
+#define FPF_SKIAFONTTYPE_Unknown 0
+#define FPF_SKIAFONTTYPE_Path 1
+#define FPF_SKIAFONTTYPE_File 2
+#define FPF_SKIAFONTTYPE_Buffer 3
+class CFPF_SkiaFontDescriptor {
+ public:
+ CFPF_SkiaFontDescriptor()
+ : m_pFamily(NULL),
+ m_dwStyle(0),
+ m_iFaceIndex(0),
+ m_dwCharsets(0),
+ m_iGlyphNum(0) {}
+ virtual ~CFPF_SkiaFontDescriptor() {
+ if (m_pFamily) {
+ FX_Free(m_pFamily);
}
- virtual int32_t GetType() const
- {
- return FPF_SKIAFONTTYPE_Unknown;
+ }
+ virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; }
+ void SetFamily(const FX_CHAR* pFamily) {
+ if (m_pFamily) {
+ FX_Free(m_pFamily);
}
- void SetFamily(const FX_CHAR* pFamily)
- {
- if (m_pFamily) {
- FX_Free(m_pFamily);
- }
- int32_t iSize = FXSYS_strlen(pFamily);
- m_pFamily = FX_Alloc(FX_CHAR, iSize + 1);
- FXSYS_memcpy(m_pFamily, pFamily, iSize * sizeof(FX_CHAR));
- m_pFamily[iSize] = 0;
- }
- FX_CHAR* m_pFamily;
- FX_DWORD m_dwStyle;
- int32_t m_iFaceIndex;
- FX_DWORD m_dwCharsets;
- int32_t m_iGlyphNum;
+ int32_t iSize = FXSYS_strlen(pFamily);
+ m_pFamily = FX_Alloc(FX_CHAR, iSize + 1);
+ FXSYS_memcpy(m_pFamily, pFamily, iSize * sizeof(FX_CHAR));
+ m_pFamily[iSize] = 0;
+ }
+ FX_CHAR* m_pFamily;
+ FX_DWORD m_dwStyle;
+ int32_t m_iFaceIndex;
+ FX_DWORD m_dwCharsets;
+ int32_t m_iGlyphNum;
};
-class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor
-{
-public:
- CFPF_SkiaPathFont() : m_pPath(NULL) {}
- virtual ~CFPF_SkiaPathFont()
- {
- if (m_pPath) {
- FX_Free(m_pPath);
- }
- }
- virtual int32_t GetType() const
- {
- return FPF_SKIAFONTTYPE_Path;
+class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor {
+ public:
+ CFPF_SkiaPathFont() : m_pPath(NULL) {}
+ virtual ~CFPF_SkiaPathFont() {
+ if (m_pPath) {
+ FX_Free(m_pPath);
}
- void SetPath(const FX_CHAR* pPath)
- {
- if (m_pPath) {
- FX_Free(m_pPath);
- }
- int32_t iSize = FXSYS_strlen(pPath);
- m_pPath = FX_Alloc(FX_CHAR, iSize + 1);
- FXSYS_memcpy(m_pPath, pPath, iSize * sizeof(FX_CHAR));
- m_pPath[iSize] = 0;
+ }
+ virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Path; }
+ void SetPath(const FX_CHAR* pPath) {
+ if (m_pPath) {
+ FX_Free(m_pPath);
}
- FX_CHAR* m_pPath;
+ int32_t iSize = FXSYS_strlen(pPath);
+ m_pPath = FX_Alloc(FX_CHAR, iSize + 1);
+ FXSYS_memcpy(m_pPath, pPath, iSize * sizeof(FX_CHAR));
+ m_pPath[iSize] = 0;
+ }
+ FX_CHAR* m_pPath;
};
-class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor
-{
-public:
- CFPF_SkiaFileFont() : m_pFile(NULL) {}
- virtual int32_t GetType() const
- {
- return FPF_SKIAFONTTYPE_File;
- }
- IFX_FileRead *m_pFile;
+class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor {
+ public:
+ CFPF_SkiaFileFont() : m_pFile(NULL) {}
+ virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_File; }
+ IFX_FileRead* m_pFile;
};
-class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor
-{
-public:
- CFPF_SkiaBufferFont() : m_pBuffer(NULL), m_szBuffer(0) {}
- virtual int32_t GetType() const
- {
- return FPF_SKIAFONTTYPE_Buffer;
- }
- void* m_pBuffer;
- size_t m_szBuffer;
+class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor {
+ public:
+ CFPF_SkiaBufferFont() : m_pBuffer(NULL), m_szBuffer(0) {}
+ virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Buffer; }
+ void* m_pBuffer;
+ size_t m_szBuffer;
};
-class CFPF_SkiaFontMgr : public IFPF_FontMgr
-{
-public:
- CFPF_SkiaFontMgr();
- virtual ~CFPF_SkiaFontMgr();
- FX_BOOL InitFTLibrary();
- virtual void LoadSystemFonts();
- virtual void LoadPrivateFont(IFX_FileRead* pFontFile);
- virtual void LoadPrivateFont(const CFX_ByteStringC& bsFileName);
- virtual void LoadPrivateFont(void* pBuffer, size_t szBuffer);
+class CFPF_SkiaFontMgr : public IFPF_FontMgr {
+ public:
+ CFPF_SkiaFontMgr();
+ virtual ~CFPF_SkiaFontMgr();
+ FX_BOOL InitFTLibrary();
+ virtual void LoadSystemFonts();
+ virtual void LoadPrivateFont(IFX_FileRead* pFontFile);
+ virtual void LoadPrivateFont(const CFX_ByteStringC& bsFileName);
+ virtual void LoadPrivateFont(void* pBuffer, size_t szBuffer);
+
+ virtual IFPF_Font* CreateFont(const CFX_ByteStringC& bsFamilyname,
+ uint8_t uCharset,
+ FX_DWORD dwStyle,
+ FX_DWORD dwMatch = 0);
+ FXFT_Face GetFontFace(IFX_FileRead* pFileRead, int32_t iFaceIndex = 0);
+ FXFT_Face GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex = 0);
+ FXFT_Face GetFontFace(const uint8_t* pBuffer,
+ size_t szBuffer,
+ int32_t iFaceIndex = 0);
- virtual IFPF_Font* CreateFont(const CFX_ByteStringC& bsFamilyname, uint8_t uCharset, FX_DWORD dwStyle, FX_DWORD dwMatch = 0);
- FXFT_Face GetFontFace(IFX_FileRead *pFileRead, int32_t iFaceIndex = 0);
- FXFT_Face GetFontFace(const CFX_ByteStringC& bsFile, int32_t iFaceIndex = 0);
- FXFT_Face GetFontFace(const uint8_t* pBuffer, size_t szBuffer, int32_t iFaceIndex = 0);
-protected:
- void ScanPath(const CFX_ByteStringC& path);
- void ScanFile(const CFX_ByteStringC& file);
- void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor *pFontDesc);
- void OutputSystemFonts();
- FX_BOOL m_bLoaded;
- CFX_PtrArray m_FontFaces;
- FXFT_Library m_FTLibrary;
- CFX_MapPtrToPtr m_FamilyFonts;
+ protected:
+ void ScanPath(const CFX_ByteStringC& path);
+ void ScanFile(const CFX_ByteStringC& file);
+ void ReportFace(FXFT_Face face, CFPF_SkiaFontDescriptor* pFontDesc);
+ void OutputSystemFonts();
+ FX_BOOL m_bLoaded;
+ CFX_PtrArray m_FontFaces;
+ FXFT_Library m_FTLibrary;
+ CFX_MapPtrToPtr m_FamilyFonts;
};
#endif
diff --git a/core/src/fxge/android/fpf_skiamodule.cpp b/core/src/fxge/android/fpf_skiamodule.cpp
index 296073c4e2..fdc3398d30 100644
--- a/core/src/fxge/android/fpf_skiamodule.cpp
+++ b/core/src/fxge/android/fpf_skiamodule.cpp
@@ -8,32 +8,28 @@
#if _FX_OS_ == _FX_ANDROID_
#include "fpf_skiamodule.h"
#include "fpf_skiafontmgr.h"
-static IFPF_DeviceModule *gs_pPFModule = NULL;
-IFPF_DeviceModule* FPF_GetDeviceModule()
-{
- if (!gs_pPFModule) {
- gs_pPFModule = new CFPF_SkiaDeviceModule;
- }
- return gs_pPFModule;
+static IFPF_DeviceModule* gs_pPFModule = NULL;
+IFPF_DeviceModule* FPF_GetDeviceModule() {
+ if (!gs_pPFModule) {
+ gs_pPFModule = new CFPF_SkiaDeviceModule;
+ }
+ return gs_pPFModule;
}
-CFPF_SkiaDeviceModule::~CFPF_SkiaDeviceModule()
-{
- delete m_pFontMgr;
+CFPF_SkiaDeviceModule::~CFPF_SkiaDeviceModule() {
+ delete m_pFontMgr;
}
-void CFPF_SkiaDeviceModule::Destroy()
-{
- delete (CFPF_SkiaDeviceModule*)gs_pPFModule;
- gs_pPFModule = NULL;
+void CFPF_SkiaDeviceModule::Destroy() {
+ delete (CFPF_SkiaDeviceModule*)gs_pPFModule;
+ gs_pPFModule = NULL;
}
-IFPF_FontMgr* CFPF_SkiaDeviceModule::GetFontMgr()
-{
- if (!m_pFontMgr) {
- m_pFontMgr = new CFPF_SkiaFontMgr;
- if (!m_pFontMgr->InitFTLibrary()) {
- delete m_pFontMgr;
- return NULL;
- }
+IFPF_FontMgr* CFPF_SkiaDeviceModule::GetFontMgr() {
+ if (!m_pFontMgr) {
+ m_pFontMgr = new CFPF_SkiaFontMgr;
+ if (!m_pFontMgr->InitFTLibrary()) {
+ delete m_pFontMgr;
+ return NULL;
}
- return (IFPF_FontMgr*)m_pFontMgr;
+ }
+ return (IFPF_FontMgr*)m_pFontMgr;
}
#endif
diff --git a/core/src/fxge/android/fpf_skiamodule.h b/core/src/fxge/android/fpf_skiamodule.h
index 4f0b16ca66..4f1c1193d8 100644
--- a/core/src/fxge/android/fpf_skiamodule.h
+++ b/core/src/fxge/android/fpf_skiamodule.h
@@ -9,15 +9,15 @@
#if _FX_OS_ == _FX_ANDROID_
class CFPF_SkiaFontMgr;
-class CFPF_SkiaDeviceModule : public IFPF_DeviceModule
-{
-public:
- CFPF_SkiaDeviceModule() : m_pFontMgr(NULL) {}
- virtual ~CFPF_SkiaDeviceModule();
- virtual void Destroy();
- virtual IFPF_FontMgr* GetFontMgr();
-protected:
- CFPF_SkiaFontMgr *m_pFontMgr;
+class CFPF_SkiaDeviceModule : public IFPF_DeviceModule {
+ public:
+ CFPF_SkiaDeviceModule() : m_pFontMgr(NULL) {}
+ virtual ~CFPF_SkiaDeviceModule();
+ virtual void Destroy();
+ virtual IFPF_FontMgr* GetFontMgr();
+
+ protected:
+ CFPF_SkiaFontMgr* m_pFontMgr;
};
#endif
diff --git a/core/src/fxge/android/fx_android_font.cpp b/core/src/fxge/android/fx_android_font.cpp
index fd72e47478..f4dfc290a3 100644
--- a/core/src/fxge/android/fx_android_font.cpp
+++ b/core/src/fxge/android/fx_android_font.cpp
@@ -6,82 +6,79 @@
#include "fx_fpf.h"
#if _FX_OS_ == _FX_ANDROID_
-CFX_AndroidFontInfo::CFX_AndroidFontInfo()
- : m_pFontMgr(NULL)
-{
-}
-FX_BOOL CFX_AndroidFontInfo::Init(IFPF_FontMgr *pFontMgr)
-{
- if (!pFontMgr) {
- return FALSE;
- }
- pFontMgr->LoadSystemFonts();
- m_pFontMgr = pFontMgr;
- return TRUE;
-}
-FX_BOOL CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper)
-{
+CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(NULL) {}
+FX_BOOL CFX_AndroidFontInfo::Init(IFPF_FontMgr* pFontMgr) {
+ if (!pFontMgr) {
return FALSE;
+ }
+ pFontMgr->LoadSystemFonts();
+ m_pFontMgr = pFontMgr;
+ return TRUE;
}
-void* CFX_AndroidFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* face, int& iExact)
-{
- if (!m_pFontMgr) {
- return NULL;
- }
- FX_DWORD dwStyle = 0;
- if (weight >= 700) {
- dwStyle |= FXFONT_BOLD;
- }
- if (bItalic) {
- dwStyle |= FXFONT_ITALIC;
- }
- if (pitch_family & FXFONT_FF_FIXEDPITCH) {
- dwStyle |= FXFONT_FIXED_PITCH;
- }
- if (pitch_family & FXFONT_FF_SCRIPT) {
- dwStyle |= FXFONT_SCRIPT;
- }
- if (pitch_family & FXFONT_FF_ROMAN) {
- dwStyle |= FXFONT_SERIF;
- }
- return m_pFontMgr->CreateFont(face, charset, dwStyle, FPF_MATCHFONT_REPLACEANSI);
+FX_BOOL CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
+ return FALSE;
}
-void* CFX_AndroidFontInfo::GetFont(const FX_CHAR* face)
-{
+void* CFX_AndroidFontInfo::MapFont(int weight,
+ FX_BOOL bItalic,
+ int charset,
+ int pitch_family,
+ const FX_CHAR* face,
+ int& iExact) {
+ if (!m_pFontMgr) {
return NULL;
+ }
+ FX_DWORD dwStyle = 0;
+ if (weight >= 700) {
+ dwStyle |= FXFONT_BOLD;
+ }
+ if (bItalic) {
+ dwStyle |= FXFONT_ITALIC;
+ }
+ if (pitch_family & FXFONT_FF_FIXEDPITCH) {
+ dwStyle |= FXFONT_FIXED_PITCH;
+ }
+ if (pitch_family & FXFONT_FF_SCRIPT) {
+ dwStyle |= FXFONT_SCRIPT;
+ }
+ if (pitch_family & FXFONT_FF_ROMAN) {
+ dwStyle |= FXFONT_SERIF;
+ }
+ return m_pFontMgr->CreateFont(face, charset, dwStyle,
+ FPF_MATCHFONT_REPLACEANSI);
}
-FX_DWORD CFX_AndroidFontInfo::GetFontData(void* hFont, FX_DWORD table, uint8_t* buffer, FX_DWORD size)
-{
- if (!hFont) {
- return 0;
- }
- return ((IFPF_Font*)hFont)->GetFontData(table, buffer, size);
+void* CFX_AndroidFontInfo::GetFont(const FX_CHAR* face) {
+ return NULL;
}
-FX_BOOL CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name)
-{
- if (!hFont) {
- return FALSE;
- }
- name = ((IFPF_Font*)hFont)->GetFamilyName();
- return TRUE;
+FX_DWORD CFX_AndroidFontInfo::GetFontData(void* hFont,
+ FX_DWORD table,
+ uint8_t* buffer,
+ FX_DWORD size) {
+ if (!hFont) {
+ return 0;
+ }
+ return ((IFPF_Font*)hFont)->GetFontData(table, buffer, size);
}
-FX_BOOL CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset)
-{
- if (!hFont) {
- return FALSE;
- }
- charset = ((IFPF_Font*)hFont)->GetCharset();
+FX_BOOL CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) {
+ if (!hFont) {
return FALSE;
+ }
+ name = ((IFPF_Font*)hFont)->GetFamilyName();
+ return TRUE;
}
-void CFX_AndroidFontInfo::DeleteFont(void* hFont)
-{
- if (!hFont) {
- return;
- }
- ((IFPF_Font*)hFont)->Release();
+FX_BOOL CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) {
+ if (!hFont) {
+ return FALSE;
+ }
+ charset = ((IFPF_Font*)hFont)->GetCharset();
+ return FALSE;
}
-void* CFX_AndroidFontInfo::RetainFont(void* hFont)
-{
- return NULL;
+void CFX_AndroidFontInfo::DeleteFont(void* hFont) {
+ if (!hFont) {
+ return;
+ }
+ ((IFPF_Font*)hFont)->Release();
+}
+void* CFX_AndroidFontInfo::RetainFont(void* hFont) {
+ return NULL;
}
#endif
diff --git a/core/src/fxge/android/fx_android_font.h b/core/src/fxge/android/fx_android_font.h
index e0101b380b..5675e1cdc2 100644
--- a/core/src/fxge/android/fx_android_font.h
+++ b/core/src/fxge/android/fx_android_font.h
@@ -9,29 +9,34 @@
#if _FX_OS_ == _FX_ANDROID_
class IFPF_FontMgr;
-class CFX_AndroidFontInfo : public IFX_SystemFontInfo
-{
-public:
- CFX_AndroidFontInfo();
- virtual void Release()
- {
- delete this;
- }
-
- virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper);
-
- virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* face, int& bExact);
-
- virtual void* GetFont(const FX_CHAR* face);
- virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, uint8_t* buffer, FX_DWORD size);
- virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name);
- virtual FX_BOOL GetFontCharset(void* hFont, int& charset);
-
- virtual void DeleteFont(void* hFont);
- virtual void* RetainFont(void* hFont);
- FX_BOOL Init(IFPF_FontMgr *pFontMgr);
-protected:
- IFPF_FontMgr *m_pFontMgr;
+class CFX_AndroidFontInfo : public IFX_SystemFontInfo {
+ public:
+ CFX_AndroidFontInfo();
+ virtual void Release() { delete this; }
+
+ virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper);
+
+ virtual void* MapFont(int weight,
+ FX_BOOL bItalic,
+ int charset,
+ int pitch_family,
+ const FX_CHAR* face,
+ int& bExact);
+
+ virtual void* GetFont(const FX_CHAR* face);
+ virtual FX_DWORD GetFontData(void* hFont,
+ FX_DWORD table,
+ uint8_t* buffer,
+ FX_DWORD size);
+ virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name);
+ virtual FX_BOOL GetFontCharset(void* hFont, int& charset);
+
+ virtual void DeleteFont(void* hFont);
+ virtual void* RetainFont(void* hFont);
+ FX_BOOL Init(IFPF_FontMgr* pFontMgr);
+
+ protected:
+ IFPF_FontMgr* m_pFontMgr;
};
#endif
diff --git a/core/src/fxge/android/fx_android_imp.cpp b/core/src/fxge/android/fx_android_imp.cpp
index 7e698cb068..073a665560 100644
--- a/core/src/fxge/android/fx_android_imp.cpp
+++ b/core/src/fxge/android/fx_android_imp.cpp
@@ -6,24 +6,22 @@
#include "fx_fpf.h"
#if _FX_OS_ == _FX_ANDROID_
-void CFX_GEModule::InitPlatform()
-{
- IFPF_DeviceModule *pDeviceModule = FPF_GetDeviceModule();
- if (!pDeviceModule) {
- return;
- }
- IFPF_FontMgr *pFontMgr = pDeviceModule->GetFontMgr();
- if (pFontMgr) {
- CFX_AndroidFontInfo *pFontInfo = new CFX_AndroidFontInfo;
- pFontInfo->Init(pFontMgr);
- m_pFontMgr->SetSystemFontInfo(pFontInfo);
- }
- m_pPlatformData = pDeviceModule;
+void CFX_GEModule::InitPlatform() {
+ IFPF_DeviceModule* pDeviceModule = FPF_GetDeviceModule();
+ if (!pDeviceModule) {
+ return;
+ }
+ IFPF_FontMgr* pFontMgr = pDeviceModule->GetFontMgr();
+ if (pFontMgr) {
+ CFX_AndroidFontInfo* pFontInfo = new CFX_AndroidFontInfo;
+ pFontInfo->Init(pFontMgr);
+ m_pFontMgr->SetSystemFontInfo(pFontInfo);
+ }
+ m_pPlatformData = pDeviceModule;
}
-void CFX_GEModule::DestroyPlatform()
-{
- if (m_pPlatformData) {
- ((IFPF_DeviceModule*)m_pPlatformData)->Destroy();
- }
+void CFX_GEModule::DestroyPlatform() {
+ if (m_pPlatformData) {
+ ((IFPF_DeviceModule*)m_pPlatformData)->Destroy();
+ }
}
#endif