summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-27 11:50:23 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-27 16:01:47 +0000
commite950b119ac10aa8fcaf3b3e06ea0e8f6d5f48ee0 (patch)
tree85e41fea1374f03696f0b289492bc77fdc3a0648
parentc29c16f8cb98f4892dd13b0c7b6b08280687d6b0 (diff)
downloadpdfium-e950b119ac10aa8fcaf3b3e06ea0e8f6d5f48ee0.tar.xz
Move static methods to anonymous namespace
This CL moves the static CFGAS_FontMgr methods to the anonymous namespace. Change-Id: I2835099ed9e503ee04daca3012a4ddd278255fdc Reviewed-on: https://pdfium-review.googlesource.com/14830 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp157
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.h3
2 files changed, 77 insertions, 83 deletions
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index 4eddfd2d6b..936b46f380 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -182,10 +182,61 @@ uint32_t GetFontFamilyHash(const wchar_t* pszFontFamily,
return FX_HashCode_GetW(wsFont.AsStringView(), false);
}
+uint32_t GetGdiFontStyles(const LOGFONTW& lf) {
+ uint32_t dwStyles = 0;
+ if ((lf.lfPitchAndFamily & 0x03) == FIXED_PITCH)
+ dwStyles |= FX_FONTSTYLE_FixedPitch;
+ uint8_t nFamilies = lf.lfPitchAndFamily & 0xF0;
+ if (nFamilies == FF_ROMAN)
+ dwStyles |= FX_FONTSTYLE_Serif;
+ if (nFamilies == FF_SCRIPT)
+ dwStyles |= FX_FONTSTYLE_Script;
+ if (lf.lfCharSet == SYMBOL_CHARSET)
+ dwStyles |= FX_FONTSTYLE_Symbolic;
+ return dwStyles;
+}
+
+int32_t CALLBACK GdiFontEnumProc(ENUMLOGFONTEX* lpelfe,
+ NEWTEXTMETRICEX* lpntme,
+ DWORD dwFontType,
+ LPARAM lParam) {
+ if (dwFontType != TRUETYPE_FONTTYPE)
+ return 1;
+ const LOGFONTW& lf = ((LPENUMLOGFONTEXW)lpelfe)->elfLogFont;
+ if (lf.lfFaceName[0] == L'@')
+ return 1;
+ FX_FONTDESCRIPTOR* pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1);
+ memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR));
+ pFont->uCharSet = lf.lfCharSet;
+ pFont->dwFontStyles = GetGdiFontStyles(lf);
+ FXSYS_wcsncpy(pFont->wsFontFace, (const wchar_t*)lf.lfFaceName, 31);
+ pFont->wsFontFace[31] = 0;
+ memcpy(&pFont->FontSignature, &lpntme->ntmFontSig,
+ sizeof(lpntme->ntmFontSig));
+ reinterpret_cast<std::deque<FX_FONTDESCRIPTOR>*>(lParam)->push_back(*pFont);
+ FX_Free(pFont);
+ return 1;
+}
+
+void EnumGdiFonts(std::deque<FX_FONTDESCRIPTOR>* fonts,
+ const wchar_t* pwsFaceName,
+ wchar_t wUnicode) {
+ HDC hDC = ::GetDC(nullptr);
+ LOGFONTW lfFind;
+ memset(&lfFind, 0, sizeof(lfFind));
+ lfFind.lfCharSet = DEFAULT_CHARSET;
+ if (pwsFaceName) {
+ FXSYS_wcsncpy(lfFind.lfFaceName, pwsFaceName, 31);
+ lfFind.lfFaceName[31] = 0;
+ }
+ EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind, (FONTENUMPROCW)GdiFontEnumProc,
+ (LPARAM)fonts, 0);
+ ::ReleaseDC(nullptr, hDC);
+}
+
} // namespace
-CFGAS_FontMgr::CFGAS_FontMgr()
- : m_pEnumerator(FX_GetDefFontEnumerator()), m_FontFaces(100) {
+CFGAS_FontMgr::CFGAS_FontMgr() : m_pEnumerator(EnumGdiFonts), m_FontFaces(100) {
if (m_pEnumerator)
m_pEnumerator(&m_FontFaces, nullptr, 0xFEFF);
}
@@ -381,62 +432,6 @@ const FX_FONTDESCRIPTOR* CFGAS_FontMgr::FindFont(const wchar_t* pszFontFamily,
return &m_FontFaces.back();
}
-uint32_t FX_GetGdiFontStyles(const LOGFONTW& lf) {
- uint32_t dwStyles = 0;
- if ((lf.lfPitchAndFamily & 0x03) == FIXED_PITCH)
- dwStyles |= FX_FONTSTYLE_FixedPitch;
- uint8_t nFamilies = lf.lfPitchAndFamily & 0xF0;
- if (nFamilies == FF_ROMAN)
- dwStyles |= FX_FONTSTYLE_Serif;
- if (nFamilies == FF_SCRIPT)
- dwStyles |= FX_FONTSTYLE_Script;
- if (lf.lfCharSet == SYMBOL_CHARSET)
- dwStyles |= FX_FONTSTYLE_Symbolic;
- return dwStyles;
-}
-
-static int32_t CALLBACK FX_GdiFontEnumProc(ENUMLOGFONTEX* lpelfe,
- NEWTEXTMETRICEX* lpntme,
- DWORD dwFontType,
- LPARAM lParam) {
- if (dwFontType != TRUETYPE_FONTTYPE)
- return 1;
- const LOGFONTW& lf = ((LPENUMLOGFONTEXW)lpelfe)->elfLogFont;
- if (lf.lfFaceName[0] == L'@')
- return 1;
- FX_FONTDESCRIPTOR* pFont = FX_Alloc(FX_FONTDESCRIPTOR, 1);
- memset(pFont, 0, sizeof(FX_FONTDESCRIPTOR));
- pFont->uCharSet = lf.lfCharSet;
- pFont->dwFontStyles = FX_GetGdiFontStyles(lf);
- FXSYS_wcsncpy(pFont->wsFontFace, (const wchar_t*)lf.lfFaceName, 31);
- pFont->wsFontFace[31] = 0;
- memcpy(&pFont->FontSignature, &lpntme->ntmFontSig,
- sizeof(lpntme->ntmFontSig));
- reinterpret_cast<std::deque<FX_FONTDESCRIPTOR>*>(lParam)->push_back(*pFont);
- FX_Free(pFont);
- return 1;
-}
-
-static void FX_EnumGdiFonts(std::deque<FX_FONTDESCRIPTOR>* fonts,
- const wchar_t* pwsFaceName,
- wchar_t wUnicode) {
- HDC hDC = ::GetDC(nullptr);
- LOGFONTW lfFind;
- memset(&lfFind, 0, sizeof(lfFind));
- lfFind.lfCharSet = DEFAULT_CHARSET;
- if (pwsFaceName) {
- FXSYS_wcsncpy(lfFind.lfFaceName, pwsFaceName, 31);
- lfFind.lfFaceName[31] = 0;
- }
- EnumFontFamiliesExW(hDC, (LPLOGFONTW)&lfFind,
- (FONTENUMPROCW)FX_GdiFontEnumProc, (LPARAM)fonts, 0);
- ::ReleaseDC(nullptr, hDC);
-}
-
-FX_LPEnumAllFonts FX_GetDefFontEnumerator() {
- return FX_EnumGdiFonts;
-}
-
#else // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
namespace {
@@ -611,6 +606,27 @@ const FX_BIT2CHARSET g_FX_Bit2Charset[4][16] = {
constexpr wchar_t kFolderSeparator = L'/';
+extern "C" {
+
+unsigned long ftStreamRead(FXFT_Stream stream,
+ unsigned long offset,
+ unsigned char* buffer,
+ unsigned long count) {
+ if (count == 0)
+ return 0;
+
+ IFX_SeekableReadStream* pFile =
+ static_cast<IFX_SeekableReadStream*>(stream->descriptor.pointer);
+ if (!pFile->ReadBlock(buffer, offset, count))
+ return 0;
+
+ return count;
+}
+
+void ftStreamClose(FXFT_Stream stream) {}
+
+}; // extern "C"
+
} // namespace
CFX_FontDescriptor::CFX_FontDescriptor()
@@ -892,27 +908,6 @@ RetainPtr<CFGAS_GEFont> CFGAS_FontMgr::LoadFont(const WideString& wsFaceName,
return pFont;
}
-extern "C" {
-
-unsigned long _ftStreamRead(FXFT_Stream stream,
- unsigned long offset,
- unsigned char* buffer,
- unsigned long count) {
- if (count == 0)
- return 0;
-
- IFX_SeekableReadStream* pFile =
- static_cast<IFX_SeekableReadStream*>(stream->descriptor.pointer);
- if (!pFile->ReadBlock(buffer, offset, count))
- return 0;
-
- return count;
-}
-
-void _ftStreamClose(FXFT_Stream stream) {}
-
-}; // extern "C"
-
FXFT_Face CFGAS_FontMgr::LoadFace(
const RetainPtr<IFX_SeekableReadStream>& pFontStream,
int32_t iFaceIndex) {
@@ -937,8 +932,8 @@ FXFT_Face CFGAS_FontMgr::LoadFace(
ftStream->descriptor.pointer = static_cast<void*>(pFontStream.Get());
ftStream->pos = 0;
ftStream->size = static_cast<unsigned long>(pFontStream->GetSize());
- ftStream->read = _ftStreamRead;
- ftStream->close = _ftStreamClose;
+ ftStream->read = ftStreamRead;
+ ftStream->close = ftStreamClose;
FXFT_Open_Args ftArgs;
memset(&ftArgs, 0, sizeof(FXFT_Open_Args));
diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index 76b65f8719..b97c4b219d 100644
--- a/xfa/fgas/font/cfgas_fontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -79,9 +79,8 @@ typedef void (*FX_LPEnumAllFonts)(std::deque<FX_FONTDESCRIPTOR>* fonts,
const wchar_t* pwsFaceName,
wchar_t wUnicode);
-FX_LPEnumAllFonts FX_GetDefFontEnumerator();
-
#else // _FX_PLATFORM_ == _FX_PLATFORM_WINDOWS_
+
class CFX_FontDescriptor {
public:
CFX_FontDescriptor();