From 4d67473d6ce55ad6361dae84b00283445f148f37 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 14 Mar 2017 15:12:09 -0400 Subject: Replace FX_POSITION in GFGAS_FontMgr with bool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iddd99312aee6447c05be5633eead023a004e65e1 Reviewed-on: https://pdfium-review.googlesource.com/3034 Reviewed-by: Nicolás Peña Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fxcrt/fx_system.h | 2 -- xfa/fgas/font/cfgas_fontmgr.cpp | 20 ++++++++++---------- xfa/fgas/font/cfgas_fontmgr.h | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/core/fxcrt/fx_system.h b/core/fxcrt/fx_system.h index 321a8e272e..94fc20050a 100644 --- a/core/fxcrt/fx_system.h +++ b/core/fxcrt/fx_system.h @@ -67,8 +67,6 @@ extern "C" { #endif // __cplusplus -typedef void* FX_POSITION; // Keep until fxcrt containers gone - #define IsFloatZero(f) ((f) < 0.0001 && (f) > -0.0001) #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp index 0173a6a24c..1746a2427d 100644 --- a/xfa/fgas/font/cfgas_fontmgr.cpp +++ b/xfa/fgas/font/cfgas_fontmgr.cpp @@ -542,19 +542,18 @@ CFX_ByteString CFX_FontSourceEnum_File::GetNextFile() { return bsName; } -FX_POSITION CFX_FontSourceEnum_File::GetStartPosition() { +bool CFX_FontSourceEnum_File::HasStartPosition() { m_wsNext = GetNextFile().UTF8Decode(); - if (m_wsNext.GetLength() == 0) - return (FX_POSITION)0; - return (FX_POSITION)-1; + return m_wsNext.GetLength() != 0; } -CFX_RetainPtr CFX_FontSourceEnum_File::GetNext( - FX_POSITION& pos) { +CFX_RetainPtr CFX_FontSourceEnum_File::GetNext() { + if (m_wsNext.GetLength() == 0) + return nullptr; + CFX_RetainPtr pAccess = IFX_FileAccess::CreateDefault(m_wsNext.AsStringC()); m_wsNext = GetNextFile().UTF8Decode(); - pos = m_wsNext.GetLength() != 0 ? pAccess.Get() : nullptr; return pAccess; } @@ -600,9 +599,10 @@ bool CFGAS_FontMgr::EnumFontsFromFontMapper() { bool CFGAS_FontMgr::EnumFontsFromFiles() { CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary(); - FX_POSITION pos = m_pFontSource->GetStartPosition(); - while (pos) { - CFX_RetainPtr pFontSource = m_pFontSource->GetNext(pos); + if (!m_pFontSource->HasStartPosition()) + return !m_InstalledFonts.empty(); + + while (CFX_RetainPtr pFontSource = m_pFontSource->GetNext()) { CFX_RetainPtr pFontStream = pFontSource->CreateFileStream(FX_FILEMODE_ReadOnly); if (pFontStream) diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h index 63a8d3b146..5918a23143 100644 --- a/xfa/fgas/font/cfgas_fontmgr.h +++ b/xfa/fgas/font/cfgas_fontmgr.h @@ -169,8 +169,8 @@ class CFX_FontSourceEnum_File { CFX_FontSourceEnum_File(); ~CFX_FontSourceEnum_File(); - FX_POSITION GetStartPosition(); - CFX_RetainPtr GetNext(FX_POSITION& pos); + bool HasStartPosition(); + CFX_RetainPtr GetNext(); private: CFX_ByteString GetNextFile(); -- cgit v1.2.3