summaryrefslogtreecommitdiff
path: root/core/fxge/android/fpf_skiafontmgr.h
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-03-14 13:35:12 -0400
committerDan Sinclair <dsinclair@chromium.org>2016-03-14 13:35:12 -0400
commit764ec513eecbebd12781bcc96ce81ed5e736ee92 (patch)
tree12763fde4be1f10ea1183d92185917b2b587e00b /core/fxge/android/fpf_skiafontmgr.h
parent97da97662417085774f75c26e535c6fbe70266ae (diff)
downloadpdfium-764ec513eecbebd12781bcc96ce81ed5e736ee92.tar.xz
Move core/src/ up to core/.
This CL moves the core/src/ files up to core/ and fixes up the include guards, includes and build files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1800523005 .
Diffstat (limited to 'core/fxge/android/fpf_skiafontmgr.h')
-rw-r--r--core/fxge/android/fpf_skiafontmgr.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/core/fxge/android/fpf_skiafontmgr.h b/core/fxge/android/fpf_skiafontmgr.h
new file mode 100644
index 0000000000..9f5cafbed5
--- /dev/null
+++ b/core/fxge/android/fpf_skiafontmgr.h
@@ -0,0 +1,127 @@
+// Copyright 2014 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_FPF_SKIAFONTMGR_H_
+#define CORE_FXGE_ANDROID_FPF_SKIAFONTMGR_H_
+
+#include "core/include/fxcrt/fx_system.h"
+
+#if _FX_OS_ == _FX_ANDROID_
+
+#include <map>
+#include <vector>
+
+#include "core/include/fxge/fpf.h"
+#include "core/include/fxge/fx_font.h"
+
+#define FPF_SKIAFONTTYPE_Unknown 0
+#define FPF_SKIAFONTTYPE_Path 1
+#define FPF_SKIAFONTTYPE_File 2
+#define FPF_SKIAFONTTYPE_Buffer 3
+
+class CFPF_SkiaFont;
+
+class CFPF_SkiaFontDescriptor {
+ public:
+ CFPF_SkiaFontDescriptor()
+ : m_pFamily(NULL),
+ m_dwStyle(0),
+ m_iFaceIndex(0),
+ m_dwCharsets(0),
+ m_iGlyphNum(0) {}
+ virtual ~CFPF_SkiaFontDescriptor() { FX_Free(m_pFamily); }
+
+ virtual int32_t GetType() const { return FPF_SKIAFONTTYPE_Unknown; }
+
+ void SetFamily(const FX_CHAR* 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;
+};
+
+class CFPF_SkiaPathFont : public CFPF_SkiaFontDescriptor {
+ public:
+ CFPF_SkiaPathFont() : m_pPath(NULL) {}
+ ~CFPF_SkiaPathFont() override { FX_Free(m_pPath); }
+
+ // CFPF_SkiaFontDescriptor
+ int32_t GetType() const override { return FPF_SKIAFONTTYPE_Path; }
+
+ void SetPath(const FX_CHAR* 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;
+ }
+ FX_CHAR* m_pPath;
+};
+
+class CFPF_SkiaFileFont : public CFPF_SkiaFontDescriptor {
+ public:
+ CFPF_SkiaFileFont() : m_pFile(NULL) {}
+
+ // CFPF_SkiaFontDescriptor
+ int32_t GetType() const override { return FPF_SKIAFONTTYPE_File; }
+ IFX_FileRead* m_pFile;
+};
+
+class CFPF_SkiaBufferFont : public CFPF_SkiaFontDescriptor {
+ public:
+ CFPF_SkiaBufferFont() : m_pBuffer(NULL), m_szBuffer(0) {}
+
+ // CFPF_SkiaFontDescriptor
+ int32_t GetType() const override { return FPF_SKIAFONTTYPE_Buffer; }
+
+ void* m_pBuffer;
+ size_t m_szBuffer;
+};
+
+class CFPF_SkiaFontMgr : public IFPF_FontMgr {
+ public:
+ CFPF_SkiaFontMgr();
+ ~CFPF_SkiaFontMgr() override;
+
+ // IFPF_FontMgr
+ void LoadSystemFonts() override;
+ void LoadPrivateFont(IFX_FileRead* pFontFile) override;
+ void LoadPrivateFont(const CFX_ByteStringC& bsFileName) override;
+ void LoadPrivateFont(void* pBuffer, size_t szBuffer) override;
+ IFPF_Font* CreateFont(const CFX_ByteStringC& bsFamilyname,
+ uint8_t uCharset,
+ FX_DWORD dwStyle,
+ FX_DWORD dwMatch = 0) override;
+
+ FX_BOOL InitFTLibrary();
+ 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;
+ FXFT_Library m_FTLibrary;
+ std::vector<CFPF_SkiaFontDescriptor*> m_FontFaces;
+ std::map<FX_DWORD, CFPF_SkiaFont*> m_FamilyFonts;
+};
+
+#endif
+
+#endif // CORE_FXGE_ANDROID_FPF_SKIAFONTMGR_H_