summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fpdf_sysfontinfo.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
committerNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
commit9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch)
treec97037f398d714665aefccb6eb54d0969ad7030c /fpdfsdk/src/fpdf_sysfontinfo.cpp
parent780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff)
downloadpdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz
XFA: clang-format all pdfium code.
No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \ xargs ../../buildtools/mac/clang-format -i Then manually merged https://codereview.chromium.org/1269223002/ See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none
Diffstat (limited to 'fpdfsdk/src/fpdf_sysfontinfo.cpp')
-rw-r--r--fpdfsdk/src/fpdf_sysfontinfo.cpp286
1 files changed, 150 insertions, 136 deletions
diff --git a/fpdfsdk/src/fpdf_sysfontinfo.cpp b/fpdfsdk/src/fpdf_sysfontinfo.cpp
index 6b7d6fbe4c..a0fdb5083d 100644
--- a/fpdfsdk/src/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/src/fpdf_sysfontinfo.cpp
@@ -8,167 +8,181 @@
#include "../include/fsdk_define.h"
#include "../include/pdfwindow/PWL_FontMap.h"
-class CFX_ExternalFontInfo final : public IFX_SystemFontInfo
-{
-public:
- CFX_ExternalFontInfo(FPDF_SYSFONTINFO* pInfo) : m_pInfo(pInfo) { }
-
- virtual void Release() override
- {
- if (m_pInfo->Release)
- m_pInfo->Release(m_pInfo);
- delete this;
- }
-
- virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override
- {
- if (m_pInfo->EnumFonts) {
- m_pInfo->EnumFonts(m_pInfo, pMapper);
- return TRUE;
- }
- return FALSE;
- }
-
- virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* family, int& iExact) override
- {
- if (m_pInfo->MapFont)
- return m_pInfo->MapFont(m_pInfo, weight, bItalic, charset, pitch_family, family, &iExact);
- return NULL;
- }
-
- virtual void* GetFont(const FX_CHAR* family) override
- {
- if (m_pInfo->GetFont)
- return m_pInfo->GetFont(m_pInfo, family);
- return NULL;
- }
-
- virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, uint8_t* buffer, FX_DWORD size) override
- {
- if (m_pInfo->GetFontData)
- return m_pInfo->GetFontData(m_pInfo, hFont, table, buffer, size);
- return 0;
- }
-
- virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override
- {
- if (m_pInfo->GetFaceName == NULL) return FALSE;
- FX_DWORD size = m_pInfo->GetFaceName(m_pInfo, hFont, NULL, 0);
- if (size == 0) return FALSE;
- char* buffer = FX_Alloc(char, size);
- size = m_pInfo->GetFaceName(m_pInfo, hFont, buffer, size);
- name = CFX_ByteString(buffer, size);
- FX_Free(buffer);
- return TRUE;
- }
-
- virtual FX_BOOL GetFontCharset(void* hFont, int& charset) override
- {
- if (m_pInfo->GetFontCharset) {
- charset = m_pInfo->GetFontCharset(m_pInfo, hFont);
- return TRUE;
- }
- return FALSE;
- }
-
- virtual void DeleteFont(void* hFont) override
- {
- if (m_pInfo->DeleteFont)
- m_pInfo->DeleteFont(m_pInfo, hFont);
- }
-
-private:
- ~CFX_ExternalFontInfo() { }
-
- FPDF_SYSFONTINFO* const m_pInfo;
+class CFX_ExternalFontInfo final : public IFX_SystemFontInfo {
+ public:
+ CFX_ExternalFontInfo(FPDF_SYSFONTINFO* pInfo) : m_pInfo(pInfo) {}
+
+ virtual void Release() override {
+ if (m_pInfo->Release)
+ m_pInfo->Release(m_pInfo);
+ delete this;
+ }
+
+ virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override {
+ if (m_pInfo->EnumFonts) {
+ m_pInfo->EnumFonts(m_pInfo, pMapper);
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ virtual void* MapFont(int weight,
+ FX_BOOL bItalic,
+ int charset,
+ int pitch_family,
+ const FX_CHAR* family,
+ int& iExact) override {
+ if (m_pInfo->MapFont)
+ return m_pInfo->MapFont(m_pInfo, weight, bItalic, charset, pitch_family,
+ family, &iExact);
+ return NULL;
+ }
+
+ virtual void* GetFont(const FX_CHAR* family) override {
+ if (m_pInfo->GetFont)
+ return m_pInfo->GetFont(m_pInfo, family);
+ return NULL;
+ }
+
+ virtual FX_DWORD GetFontData(void* hFont,
+ FX_DWORD table,
+ uint8_t* buffer,
+ FX_DWORD size) override {
+ if (m_pInfo->GetFontData)
+ return m_pInfo->GetFontData(m_pInfo, hFont, table, buffer, size);
+ return 0;
+ }
+
+ virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override {
+ if (m_pInfo->GetFaceName == NULL)
+ return FALSE;
+ FX_DWORD size = m_pInfo->GetFaceName(m_pInfo, hFont, NULL, 0);
+ if (size == 0)
+ return FALSE;
+ char* buffer = FX_Alloc(char, size);
+ size = m_pInfo->GetFaceName(m_pInfo, hFont, buffer, size);
+ name = CFX_ByteString(buffer, size);
+ FX_Free(buffer);
+ return TRUE;
+ }
+
+ virtual FX_BOOL GetFontCharset(void* hFont, int& charset) override {
+ if (m_pInfo->GetFontCharset) {
+ charset = m_pInfo->GetFontCharset(m_pInfo, hFont);
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ virtual void DeleteFont(void* hFont) override {
+ if (m_pInfo->DeleteFont)
+ m_pInfo->DeleteFont(m_pInfo, hFont);
+ }
+
+ private:
+ ~CFX_ExternalFontInfo() {}
+
+ FPDF_SYSFONTINFO* const m_pInfo;
};
-DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, const char* name, int charset)
-{
- ((CFX_FontMapper*)mapper)->AddInstalledFont(name, charset);
+DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper,
+ const char* name,
+ int charset) {
+ ((CFX_FontMapper*)mapper)->AddInstalledFont(name, charset);
}
-DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfoExt)
-{
- if (pFontInfoExt->version != 1)
- return;
+DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfoExt) {
+ if (pFontInfoExt->version != 1)
+ return;
- CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo(
- new CFX_ExternalFontInfo(pFontInfoExt));
+ CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo(
+ new CFX_ExternalFontInfo(pFontInfoExt));
}
-DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap()
-{
- return CPWL_FontMap::defaultTTFMap;
+DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap() {
+ return CPWL_FontMap::defaultTTFMap;
}
-struct FPDF_SYSFONTINFO_DEFAULT : public FPDF_SYSFONTINFO
-{
- IFX_SystemFontInfo* m_pFontInfo;
+struct FPDF_SYSFONTINFO_DEFAULT : public FPDF_SYSFONTINFO {
+ IFX_SystemFontInfo* m_pFontInfo;
};
-static void DefaultRelease(struct _FPDF_SYSFONTINFO* pThis)
-{
- ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->Release();
+static void DefaultRelease(struct _FPDF_SYSFONTINFO* pThis) {
+ ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->Release();
}
-static void DefaultEnumFonts(struct _FPDF_SYSFONTINFO* pThis, void* pMapper)
-{
- ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->EnumFontList((CFX_FontMapper*)pMapper);
+static void DefaultEnumFonts(struct _FPDF_SYSFONTINFO* pThis, void* pMapper) {
+ ((FPDF_SYSFONTINFO_DEFAULT*)pThis)
+ ->m_pFontInfo->EnumFontList((CFX_FontMapper*)pMapper);
}
-static void* DefaultMapFont(struct _FPDF_SYSFONTINFO* pThis, int weight, int bItalic, int charset, int pitch_family, const char* family, int* bExact)
-{
- return ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->MapFont(weight, bItalic, charset, pitch_family, family, *bExact);
+static void* DefaultMapFont(struct _FPDF_SYSFONTINFO* pThis,
+ int weight,
+ int bItalic,
+ int charset,
+ int pitch_family,
+ const char* family,
+ int* bExact) {
+ return ((FPDF_SYSFONTINFO_DEFAULT*)pThis)
+ ->m_pFontInfo->MapFont(weight, bItalic, charset, pitch_family, family,
+ *bExact);
}
-void* DefaultGetFont(struct _FPDF_SYSFONTINFO* pThis, const char* family)
-{
- return ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->GetFont(family);
+void* DefaultGetFont(struct _FPDF_SYSFONTINFO* pThis, const char* family) {
+ return ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->GetFont(family);
}
-static unsigned long DefaultGetFontData(struct _FPDF_SYSFONTINFO* pThis, void* hFont,
- unsigned int table, unsigned char* buffer, unsigned long buf_size)
-{
- return ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->GetFontData(hFont, table, buffer, buf_size);
+static unsigned long DefaultGetFontData(struct _FPDF_SYSFONTINFO* pThis,
+ void* hFont,
+ unsigned int table,
+ unsigned char* buffer,
+ unsigned long buf_size) {
+ return ((FPDF_SYSFONTINFO_DEFAULT*)pThis)
+ ->m_pFontInfo->GetFontData(hFont, table, buffer, buf_size);
}
-static unsigned long DefaultGetFaceName(struct _FPDF_SYSFONTINFO* pThis, void* hFont, char* buffer, unsigned long buf_size)
-{
- CFX_ByteString name;
- if (!((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->GetFaceName(hFont, name)) return 0;
- if (name.GetLength() >= (long)buf_size) return name.GetLength() + 1;
- FXSYS_strcpy(buffer, name);
- return name.GetLength() + 1;
+static unsigned long DefaultGetFaceName(struct _FPDF_SYSFONTINFO* pThis,
+ void* hFont,
+ char* buffer,
+ unsigned long buf_size) {
+ CFX_ByteString name;
+ if (!((FPDF_SYSFONTINFO_DEFAULT*)pThis)
+ ->m_pFontInfo->GetFaceName(hFont, name))
+ return 0;
+ if (name.GetLength() >= (long)buf_size)
+ return name.GetLength() + 1;
+ FXSYS_strcpy(buffer, name);
+ return name.GetLength() + 1;
}
-static int DefaultGetFontCharset(struct _FPDF_SYSFONTINFO* pThis, void* hFont)
-{
- int charset;
- if (!((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->GetFontCharset(hFont, charset)) return 0;
- return charset;
+static int DefaultGetFontCharset(struct _FPDF_SYSFONTINFO* pThis, void* hFont) {
+ int charset;
+ if (!((FPDF_SYSFONTINFO_DEFAULT*)pThis)
+ ->m_pFontInfo->GetFontCharset(hFont, charset))
+ return 0;
+ return charset;
}
-static void DefaultDeleteFont(struct _FPDF_SYSFONTINFO* pThis, void* hFont)
-{
- ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->DeleteFont(hFont);
+static void DefaultDeleteFont(struct _FPDF_SYSFONTINFO* pThis, void* hFont) {
+ ((FPDF_SYSFONTINFO_DEFAULT*)pThis)->m_pFontInfo->DeleteFont(hFont);
}
-DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo()
-{
- IFX_SystemFontInfo* pFontInfo = IFX_SystemFontInfo::CreateDefault();
- if (pFontInfo == NULL) return NULL;
-
- FPDF_SYSFONTINFO_DEFAULT* pFontInfoExt = FX_Alloc(FPDF_SYSFONTINFO_DEFAULT, 1);
- pFontInfoExt->DeleteFont = DefaultDeleteFont;
- pFontInfoExt->EnumFonts = DefaultEnumFonts;
- pFontInfoExt->GetFaceName = DefaultGetFaceName;
- pFontInfoExt->GetFont = DefaultGetFont;
- pFontInfoExt->GetFontCharset = DefaultGetFontCharset;
- pFontInfoExt->GetFontData = DefaultGetFontData;
- pFontInfoExt->MapFont = DefaultMapFont;
- pFontInfoExt->Release = DefaultRelease;
- pFontInfoExt->version = 1;
- pFontInfoExt->m_pFontInfo = pFontInfo;
- return pFontInfoExt;
+DLLEXPORT FPDF_SYSFONTINFO* STDCALL FPDF_GetDefaultSystemFontInfo() {
+ IFX_SystemFontInfo* pFontInfo = IFX_SystemFontInfo::CreateDefault();
+ if (pFontInfo == NULL)
+ return NULL;
+
+ FPDF_SYSFONTINFO_DEFAULT* pFontInfoExt =
+ FX_Alloc(FPDF_SYSFONTINFO_DEFAULT, 1);
+ pFontInfoExt->DeleteFont = DefaultDeleteFont;
+ pFontInfoExt->EnumFonts = DefaultEnumFonts;
+ pFontInfoExt->GetFaceName = DefaultGetFaceName;
+ pFontInfoExt->GetFont = DefaultGetFont;
+ pFontInfoExt->GetFontCharset = DefaultGetFontCharset;
+ pFontInfoExt->GetFontData = DefaultGetFontData;
+ pFontInfoExt->MapFont = DefaultMapFont;
+ pFontInfoExt->Release = DefaultRelease;
+ pFontInfoExt->version = 1;
+ pFontInfoExt->m_pFontInfo = pFontInfo;
+ return pFontInfoExt;
}