Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
FontLoader.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 #include <Windows.h>
6 #include <dwrite.h>
7 
8 #include <Strings/components/utils/saferelease/saferelease.h>
9 
10 #ifndef BLAM
11 #define BLAM
12 #endif
13 
17 typedef std::vector<std::wstring> MFFontList;
18 
45 {
49  namespace MFFontGlobals
50  {
61  BLAM int push(MFFontList &collection);
62 
68  BLAM std::vector<MFFontList>& getFontFileLists();
69 
76  BLAM void addFontCollection(std::string id, IDWriteFontCollection* collection);
77 
85  BLAM IDWriteFontCollection* getFontCollection(std::string id);
86 
91  }
92 
101  BLAM HRESULT CreateFontCollection(MFFontList &newCollection, std::string font_id);
102 
106  class MFFontCollectionLoader : public IDWriteFontCollectionLoader
107  {
108  public:
113  {
114  reference_count = 0;
115  }
116 
118  // IUnknown Methods //
120 
126  virtual HRESULT __stdcall QueryInterface(REFIID iid, void** ppvObject);
127 
131  virtual ULONG __stdcall AddRef();
132 
136  virtual ULONG __stdcall Release();
137 
139  // IDWriteFontCollectionLoader Methods //
141 
152  virtual HRESULT __stdcall CreateEnumeratorFromKey(IDWriteFactory* factory, void const* collectionKey, UINT32 collectionKeySize, IDWriteFontFileEnumerator** fontFileEnumerator);
153 
154  private:
155  ULONG reference_count;
156  };
157 
163  class MFFontFileEnumerator : public IDWriteFontFileEnumerator
164  {
165  public:
169  MFFontFileEnumerator(IDWriteFactory* factory);
170 
179  HRESULT Initialize(UINT const* collectionKey, UINT32 keySize);
180 
185  {
186  SafeRelease(&current_file);
187  }
188 
190  // IUnknown Methods //
192 
198  virtual HRESULT __stdcall QueryInterface(REFIID iid, void** ppvObject);
199 
203  virtual ULONG __stdcall AddRef();
204 
208  virtual ULONG __stdcall Release();
209 
211  // IDWriteFontFileEnumerator Methods //
213 
221  virtual HRESULT __stdcall MoveNext(BOOL* hasCurrentFile);
222 
230  virtual HRESULT __stdcall GetCurrentFontFile(IDWriteFontFile** fontFile);
231 
232  private:
233  ULONG reference_count;
234 
235  IDWriteFontFile* current_file;
236  std::vector<std::wstring> file_paths;
237  size_t next_index;
238  };
239 
240 }
BlamRendering::DirectX::D2D::MF::MFFontCollectionLoader::MFFontCollectionLoader
MFFontCollectionLoader()
Sets the reference count to 0.
Definition: FontLoader.h:112
BLAM
#define BLAM
Definition: FontLoader.h:11
BlamRendering::DirectX::D2D::MF::MFFontFileEnumerator::Initialize
HRESULT Initialize(UINT const *collectionKey, UINT32 keySize)
Initializes a the enumerator.
Definition: MFFontFileEnumerator.cpp:16
BlamRendering::DirectX::D2D::MF::MFFontFileEnumerator::GetCurrentFontFile
virtual HRESULT __stdcall GetCurrentFontFile(IDWriteFontFile **fontFile)
Retrieves the current font file.
Definition: MFFontFileEnumerator.cpp:91
BlamRendering::DirectX::D2D::MF
Namespace containing things relating to the MF font loader.
Definition: FontLoader.h:44
BlamRendering::DirectX::D2D::MF::MFFontFileEnumerator::Release
virtual ULONG __stdcall Release()
Releases the object.
Definition: MFFontFileEnumerator.cpp:56
BlamRendering::DirectX::D2D::MF::MFFontFileEnumerator::QueryInterface
virtual HRESULT __stdcall QueryInterface(REFIID iid, void **ppvObject)
Queries the interface.
Definition: MFFontFileEnumerator.cpp:36
BlamRendering::DirectX::D2D::MF::MFFontCollectionLoader::QueryInterface
virtual HRESULT __stdcall QueryInterface(REFIID iid, void **ppvObject)
Queries the interface.
Definition: MFFontCollectionLoader.cpp:5
BlamRendering::DirectX::D2D::MF::MFFontFileEnumerator::~MFFontFileEnumerator
~MFFontFileEnumerator()
Releases the current file in the enumerator.
Definition: FontLoader.h:184
BlamRendering::DirectX::D2D::MF::MFFontCollectionLoader::CreateEnumeratorFromKey
virtual HRESULT __stdcall CreateEnumeratorFromKey(IDWriteFactory *factory, void const *collectionKey, UINT32 collectionKeySize, IDWriteFontFileEnumerator **fontFileEnumerator)
Creates a new Font File Enumerator.
Definition: MFFontCollectionLoader.cpp:37
BlamRendering::DirectX::D2D::MF::MFFontFileEnumerator::MFFontFileEnumerator
MFFontFileEnumerator(IDWriteFactory *factory)
Sets reference counts and indexes to 0.
Definition: MFFontFileEnumerator.cpp:9
BlamRendering::DirectX::D2D::MF::MFFontFileEnumerator::MoveNext
virtual HRESULT __stdcall MoveNext(BOOL *hasCurrentFile)
Moves to the next item in the enumerator.
Definition: MFFontFileEnumerator.cpp:68
BlamRendering::DirectX::D2D::MF::MFFontFileEnumerator::AddRef
virtual ULONG __stdcall AddRef()
Acquires a new reference to the object.
Definition: MFFontFileEnumerator.cpp:51
BlamRendering::DirectX::D2D::MF::MFFontGlobals::getFontFileLists
BLAM std::vector< MFFontList > & getFontFileLists()
Retrieves the list of font lists.
Definition: FontLoader.cpp:95
MFFontList
std::vector< std::wstring > MFFontList
Somewhat pointless font list type definition, but it does make things slightly easier to read.
Definition: FontLoader.h:17
BlamRendering::DirectX::D2D::MF::MFFontCollectionLoader::AddRef
virtual ULONG __stdcall AddRef()
Acquires a new reference to the object.
Definition: MFFontCollectionLoader.cpp:20
BlamRendering::DirectX::D2D::MF::MFFontGlobals::addFontCollection
BLAM void addFontCollection(std::string id, IDWriteFontCollection *collection)
Adds a font collection to the list of font collections.
Definition: FontLoader.cpp:65
BlamRendering::DirectX::D2D::MF::MFFontCollectionLoader::Release
virtual ULONG __stdcall Release()
Releases the object.
Definition: MFFontCollectionLoader.cpp:25
BlamRendering::DirectX::D2D::MF::CreateFontCollection
BLAM HRESULT CreateFontCollection(MFFontList &newCollection, std::string font_id)
Creates a new font collection.
Definition: FontLoader.cpp:26
BlamRendering::DirectX::D2D::MF::MFFontFileEnumerator
Class to implement the DirectWrite Font File Enumerator interface.
Definition: FontLoader.h:163
BlamRendering::DirectX::D2D::MF::MFFontGlobals::push
BLAM int push(MFFontList &collection)
Inserts a font list into the list of font lists.
Definition: FontLoader.cpp:56
BlamRendering::DirectX::D2D::MF::MFFontCollectionLoader
Class to assist in the loading of font collections.
Definition: FontLoader.h:106
BlamRendering::DirectX::D2D::MF::MFFontGlobals::getFontCollection
BLAM IDWriteFontCollection * getFontCollection(std::string id)
Retrieves a font collection from the list of font collections.
Definition: FontLoader.cpp:70
BlamRendering::DirectX::D2D::MF::MFFontGlobals::cleanupCollectionList
BLAM void cleanupCollectionList()
Cleans up the font collection list.
Definition: FontLoader.cpp:85