summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.cpp30
-rw-r--r--xfa/fgas/font/cfgas_fontmgr.h8
2 files changed, 15 insertions, 23 deletions
diff --git a/xfa/fgas/font/cfgas_fontmgr.cpp b/xfa/fgas/font/cfgas_fontmgr.cpp
index b2150f99b8..c8aed88547 100644
--- a/xfa/fgas/font/cfgas_fontmgr.cpp
+++ b/xfa/fgas/font/cfgas_fontmgr.cpp
@@ -634,20 +634,18 @@ ByteString CFX_FontSourceEnum_File::GetNextFile() {
return bsName;
}
-bool CFX_FontSourceEnum_File::HasStartPosition() {
+void CFX_FontSourceEnum_File::GetNext() {
m_wsNext = GetNextFile().UTF8Decode();
- return !m_wsNext.IsEmpty();
}
-std::pair<bool, RetainPtr<IFX_SeekableStream>>
-CFX_FontSourceEnum_File::GetNext() {
- if (m_wsNext.IsEmpty())
- return {false, nullptr};
+bool CFX_FontSourceEnum_File::HasNext() const {
+ return !m_wsNext.IsEmpty();
+}
- auto stream = IFX_SeekableStream::CreateFromFilename(m_wsNext.c_str(),
- FX_FILEMODE_ReadOnly);
- m_wsNext = GetNextFile().UTF8Decode();
- return {true, stream};
+RetainPtr<IFX_SeekableStream> CFX_FontSourceEnum_File::GetStream() const {
+ ASSERT(HasNext());
+ return IFX_SeekableStream::CreateFromFilename(m_wsNext.c_str(),
+ FX_FILEMODE_ReadOnly);
}
CFGAS_FontMgr::CFGAS_FontMgr()
@@ -684,16 +682,12 @@ bool CFGAS_FontMgr::EnumFontsFromFontMapper() {
bool CFGAS_FontMgr::EnumFontsFromFiles() {
CFX_GEModule::Get()->GetFontMgr()->InitFTLibrary();
- if (!m_pFontSource->HasStartPosition())
- return !m_InstalledFonts.empty();
-
- bool has_next;
- RetainPtr<IFX_SeekableStream> stream;
- std::tie(has_next, stream) = m_pFontSource->GetNext();
- while (has_next) {
+ m_pFontSource->GetNext();
+ while (m_pFontSource->HasNext()) {
+ RetainPtr<IFX_SeekableStream> stream = m_pFontSource->GetStream();
if (stream)
RegisterFaces(stream, nullptr);
- std::tie(has_next, stream) = m_pFontSource->GetNext();
+ m_pFontSource->GetNext();
}
return !m_InstalledFonts.empty();
}
diff --git a/xfa/fgas/font/cfgas_fontmgr.h b/xfa/fgas/font/cfgas_fontmgr.h
index bc2a7af2a7..3c63a1c636 100644
--- a/xfa/fgas/font/cfgas_fontmgr.h
+++ b/xfa/fgas/font/cfgas_fontmgr.h
@@ -11,7 +11,6 @@
#include <map>
#include <memory>
#include <set>
-#include <utility>
#include <vector>
#include "core/fxcrt/fx_extension.h"
@@ -98,10 +97,9 @@ class CFX_FontSourceEnum_File {
CFX_FontSourceEnum_File();
~CFX_FontSourceEnum_File();
- bool HasStartPosition();
-
- // <next exists, stream for next>
- std::pair<bool, RetainPtr<IFX_SeekableStream>> GetNext();
+ void GetNext();
+ bool HasNext() const;
+ RetainPtr<IFX_SeekableStream> GetStream() const;
private:
struct HandleParentPath {