ReactOS 0.4.15-dev-7942-gd23573b
CFontCache Class Reference

#include <CFontCache.hpp>

Public Member Functions

void Read ()
 
void SetFontDir (const LPCWSTR Path)
 
const CStringW & FontPath () const
 
size_t Size ()
 
CStringW Name (size_t Index)
 
CFontInfoFind (const FontPidlEntry *fontEntry)
 
CStringW Filename (CFontInfo *info, bool alwaysFullPath=false)
 

Protected Member Functions

 CFontCache ()
 
void Insert (CAtlList< CFontInfo > &fonts, const CStringW &KeyName)
 

Private Attributes

CAtlArray< CFontInfom_Fonts
 
CStringW m_FontFolderPath
 

Friends

class CFontExtModule
 

Detailed Description

Definition at line 38 of file CFontCache.hpp.

Constructor & Destructor Documentation

◆ CFontCache()

CFontCache::CFontCache ( )
protected

Definition at line 116 of file CFontCache.cpp.

117{
118}

Member Function Documentation

◆ Filename()

CStringW CFontCache::Filename ( CFontInfo info,
bool  alwaysFullPath = false 
)

Definition at line 164 of file CFontCache.cpp.

165{
167 if (info)
168 {
169 File = info->File();
170
171 if (!File.IsEmpty() && alwaysFullPath)
172 {
173 // Ensure this is a full path
175 {
177 }
178 }
179 }
180
181 return File;
182}
CStringW m_FontFolderPath
Definition: CFontCache.hpp:42
Definition: File.h:16
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1579

Referenced by _CDataObject_CreateInstance(), CFontExt::GetDisplayNameOf(), CFontExt::GetUIObjectOf(), CFontInfo::ReadAttrs(), and RunFontViewer().

◆ Find()

CFontInfo * CFontCache::Find ( const FontPidlEntry fontEntry)

Definition at line 145 of file CFontCache.cpp.

146{
147 if (fontEntry->Index < m_Fonts.GetCount())
148 {
149 if (m_Fonts[fontEntry->Index].Name().CompareNoCase(fontEntry->Name) == 0)
150 return &m_Fonts[fontEntry->Index];
151 }
152
153 for (UINT n = 0; n < Size(); ++n)
154 {
155 if (m_Fonts[n].Name().CompareNoCase(fontEntry->Name) == 0)
156 {
157 return &m_Fonts[n];
158 }
159 }
160 return nullptr;
161}
struct NameRec_ * Name
Definition: cdprocs.h:460
CAtlArray< CFontInfo > m_Fonts
Definition: CFontCache.hpp:41
size_t Size()
Definition: CFontCache.cpp:126
GLdouble n
Definition: glext.h:7729
unsigned int UINT
Definition: ndis.h:50
WCHAR Name[1]
Definition: fontpidl.hpp:17

Referenced by _CDataObject_CreateInstance(), CFontExt::CompareIDs(), CFontExt::GetDetailsOf(), CFontExt::GetDisplayNameOf(), CFontExt::GetUIObjectOf(), and RunFontViewer().

◆ FontPath()

const CStringW & CFontCache::FontPath ( ) const
inline

Definition at line 53 of file CFontCache.hpp.

53{ return m_FontFolderPath; }

Referenced by CFontExt::Drop().

◆ Insert()

void CFontCache::Insert ( CAtlList< CFontInfo > &  fonts,
const CStringW KeyName 
)
protected

Definition at line 184 of file CFontCache.cpp.

185{
186 POSITION it = fonts.GetHeadPosition();
187 while (it != NULL)
188 {
189 POSITION lastit = it;
190 const CFontInfo& info = fonts.GetNext(it);
191 if (info.Name().CompareNoCase(KeyName) >= 0)
192 {
193 fonts.InsertBefore(lastit, CFontInfo(KeyName));
194 return;
195 }
196 }
197 fonts.AddTail(CFontInfo(KeyName));
198}
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:626
POSITION GetHeadPosition() const
Definition: atlcoll.h:551
POSITION InsertBefore(_In_ POSITION pos, INARGTYPE element)
Definition: atlcoll.h:683
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:563
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2699

Referenced by Read().

◆ Name()

CStringW CFontCache::Name ( size_t  Index)

Definition at line 134 of file CFontCache.cpp.

135{
136 if (m_Fonts.GetCount() == 0u)
137 Read();
138
139 if (Index >= m_Fonts.GetCount())
140 return CStringW();
141
142 return m_Fonts[Index].Name();
143}
void Read()
Definition: CFontCache.cpp:200
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
CAtlStringW CStringW
Definition: atlstr.h:130
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by CEnumFonts::Next().

◆ Read()

void CFontCache::Read ( )

Definition at line 200 of file CFontCache.cpp.

201{
203 CRegKey key;
204
205 // Enumerate all registered font names
207 {
209 DWORD dwAllocated = 128;
210 DWORD ilIndex = 0;
212 do
213 {
214 DWORD dwSize = dwAllocated;
215 PWSTR Buffer = KeyName.GetBuffer(dwSize);
216 Status = RegEnumValueW(key.m_hKey, ilIndex, Buffer, &dwSize, NULL, NULL, NULL, NULL);
217 KeyName.ReleaseBuffer(dwSize);
218 if (Status == ERROR_SUCCESS)
219 {
220 // Insert will create an ordered list
221 Insert(fonts, KeyName);
222 ilIndex++;
223 continue;
224 }
226 break;
227 else if (Status == ERROR_MORE_DATA)
228 {
229 dwAllocated += 128;
230 }
231 } while (Status == ERROR_MORE_DATA || Status == ERROR_SUCCESS);
232 }
233
234 // Move the fonts from a list to an array (for easy indexing)
235 m_Fonts.SetCount(fonts.GetCount());
236 size_t Index = 0;
237 POSITION it = fonts.GetHeadPosition();
238 while (it != NULL)
239 {
240 m_Fonts[Index] = fonts.GetNext(it);
241 Index++;
242 }
243}
size_t GetCount() const
Definition: atlcoll.h:539
Definition: bufpool.h:45
void Insert(CAtlList< CFontInfo > &fonts, const CStringW &KeyName)
Definition: CFontCache.cpp:184
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define ERROR_SUCCESS
Definition: deptool.c:10
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
#define FONT_HIVE
Definition: precomp.h:30
#define FONT_KEY
Definition: precomp.h:31
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define KEY_READ
Definition: nt_native.h:1023
Definition: copy.c:22
uint16_t * PWSTR
Definition: typedefs.h:56

Referenced by CFontExt::Drop(), Name(), and Size().

◆ SetFontDir()

void CFontCache::SetFontDir ( const LPCWSTR  Path)

Definition at line 120 of file CFontCache.cpp.

121{
124}
PRTL_UNICODE_STRING_BUFFER Path
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394

Referenced by CFontExt::Initialize().

◆ Size()

size_t CFontCache::Size ( )

Definition at line 126 of file CFontCache.cpp.

127{
128 if (m_Fonts.GetCount() == 0u)
129 Read();
130
131 return m_Fonts.GetCount();
132}

Referenced by Find().

Friends And Related Function Documentation

◆ CFontExtModule

friend class CFontExtModule
friend

Definition at line 61 of file CFontCache.hpp.

Member Data Documentation

◆ m_FontFolderPath

CStringW CFontCache::m_FontFolderPath
private

Definition at line 42 of file CFontCache.hpp.

Referenced by Filename(), FontPath(), and SetFontDir().

◆ m_Fonts

CAtlArray<CFontInfo> CFontCache::m_Fonts
private

Definition at line 41 of file CFontCache.hpp.

Referenced by Find(), Name(), Read(), and Size().


The documentation for this class was generated from the following files: