ReactOS  0.4.15-dev-2153-g62b4c61
CFontCache Class Reference

#include <CFontCache.hpp>

Public Member Functions

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

Protected Member Functions

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

Private Attributes

CAtlArray< CFontInfom_Fonts
 
CStringW m_FontFolderPath
 

Friends

class CFontExtModule
 

Detailed Description

Definition at line 26 of file CFontCache.hpp.

Constructor & Destructor Documentation

◆ CFontCache()

CFontCache::CFontCache ( )
protected

Definition at line 67 of file CFontCache.cpp.

68 {
69 }

Member Function Documentation

◆ Filename()

CStringW CFontCache::Filename ( const FontPidlEntry fontEntry,
bool  alwaysFullPath = false 
)

Definition at line 96 of file CFontCache.cpp.

97 {
98  CStringW File;
99 
100  if (fontEntry->Index < m_Fonts.GetCount())
101  {
102  CFontInfo& info = m_Fonts[fontEntry->Index];
103 
104  if (info.Name().CompareNoCase(fontEntry->Name) == 0)
105  File = info.File();
106  }
107 
108  for (UINT n = 0; File.IsEmpty() && n < Size(); ++n)
109  {
110  if (m_Fonts[n].Name().CompareNoCase(fontEntry->Name) == 0)
111  File = m_Fonts[n].File();
112  }
113 
114  if (!File.IsEmpty() && alwaysFullPath)
115  {
116  // Ensure this is a full path
117  if (PathIsRelativeW(File))
118  {
120  }
121  }
122 
123  return File;
124 }
BOOL WINAPI PathIsRelativeW(LPCWSTR lpszPath)
Definition: path.c:1558
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:658
GLdouble n
Definition: glext.h:7729
CStringW m_FontFolderPath
Definition: CFontCache.hpp:30
CAtlArray< CFontInfo > m_Fonts
Definition: CFontCache.hpp:29
WCHAR Name[1]
Definition: fontpidl.hpp:17
CStringW Name(size_t Index)
Definition: CFontCache.cpp:85
unsigned int UINT
Definition: ndis.h:50
size_t Size()
Definition: CFontCache.cpp:77
Definition: File.h:15
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID _In_ LONG _In_z_ PCHAR File
Definition: wdfdevice.h:4061

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

◆ FontPath()

const CStringW& CFontCache::FontPath ( ) const
inline

Definition at line 40 of file CFontCache.hpp.

40 { return m_FontFolderPath; }
CStringW m_FontFolderPath
Definition: CFontCache.hpp:30

Referenced by CFontExt::Drop().

◆ Insert()

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

Definition at line 126 of file CFontCache.cpp.

127 {
128  POSITION it = fonts.GetHeadPosition();
129  while (it != NULL)
130  {
131  POSITION lastit = it;
132  const CFontInfo& info = fonts.GetNext(it);
133  if (info.Name().CompareNoCase(KeyName) >= 0)
134  {
135  fonts.InsertBefore(lastit, CFontInfo(KeyName));
136  return;
137  }
138  }
139  fonts.AddTail(CFontInfo(KeyName));
140 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:549
POSITION InsertBefore(_In_ POSITION pos, INARGTYPE element)
Definition: atlcoll.h:681
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:561
POSITION AddTail(INARGTYPE element)
Definition: atlcoll.h:624
#define NULL
Definition: types.h:112

Referenced by Read().

◆ Name()

CStringW CFontCache::Name ( size_t  Index)

Definition at line 85 of file CFontCache.cpp.

86 {
87  if (m_Fonts.GetCount() == 0u)
88  Read();
89 
90  if (Index >= m_Fonts.GetCount())
91  return CStringW();
92 
93  return m_Fonts[Index].Name();
94 }
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
_In_ WDFCOLLECTION _In_ ULONG Index
CAtlArray< CFontInfo > m_Fonts
Definition: CFontCache.hpp:29
void Read()
Definition: CFontCache.cpp:142
CAtlStringW CStringW
Definition: atlstr.h:130

Referenced by Filename(), and CEnumFonts::Next().

◆ Read()

void CFontCache::Read ( )
protected

Definition at line 142 of file CFontCache.cpp.

143 {
144  CAtlList<CFontInfo> fonts;
145  CRegKey key;
146 
147  // Enumerate all registered font names
149  {
150  LSTATUS Status;
151  DWORD dwAllocated = 128;
152  DWORD ilIndex = 0;
154  do
155  {
156  DWORD dwSize = dwAllocated;
157  PWSTR Buffer = KeyName.GetBuffer(dwSize);
158  Status = RegEnumValueW(key.m_hKey, ilIndex, Buffer, &dwSize, NULL, NULL, NULL, NULL);
159  KeyName.ReleaseBuffer(dwSize);
160  if (Status == ERROR_SUCCESS)
161  {
162  // Insert will create an ordered list
163  Insert(fonts, KeyName);
164  ilIndex++;
165  continue;
166  }
168  break;
169  else if (Status == ERROR_MORE_DATA)
170  {
171  dwAllocated += 128;
172  }
173  } while (Status == ERROR_MORE_DATA || Status == ERROR_SUCCESS);
174  }
175 
176  // Move the fonts from a list to an array (for easy indexing)
177  m_Fonts.SetCount(fonts.GetCount());
178  size_t Index = 0;
179  POSITION it = fonts.GetHeadPosition();
180  while (it != NULL)
181  {
182  m_Fonts[Index] = fonts.GetNext(it);
183  Index++;
184  }
185 }
POSITION GetHeadPosition() const
Definition: atlcoll.h:549
#define ERROR_SUCCESS
Definition: deptool.c:10
void Insert(CAtlList< CFontInfo > &fonts, const CStringW &KeyName)
Definition: CFontCache.cpp:126
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define KEY_READ
Definition: nt_native.h:1023
uint16_t * PWSTR
Definition: typedefs.h:56
#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:2853
Definition: bufpool.h:45
size_t GetCount() const
Definition: atlcoll.h:537
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
Definition: wdfdevice.h:2697
Status
Definition: gdiplustypes.h:24
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:561
#define FONT_HIVE
Definition: precomp.h:30
_In_ WDFCOLLECTION _In_ ULONG Index
CAtlArray< CFontInfo > m_Fonts
Definition: CFontCache.hpp:29
unsigned long DWORD
Definition: ntddk_ex.h:95
static LSTATUS(WINAPI *pRegDeleteTreeW)(HKEY
HKEY key
Definition: reg.c:42
#define ERROR_MORE_DATA
Definition: dderror.h:13
#define NULL
Definition: types.h:112
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
Definition: path.c:41

Referenced by Name(), and Size().

◆ SetFontDir()

void CFontCache::SetFontDir ( const LPCWSTR  Path)

Definition at line 71 of file CFontCache.cpp.

72 {
75 }
CStringW m_FontFolderPath
Definition: CFontCache.hpp:30
bool IsEmpty() const
Definition: atlsimpstr.h:379
PRTL_UNICODE_STRING_BUFFER Path

Referenced by CFontExt::Initialize().

◆ Size()

size_t CFontCache::Size ( )

Definition at line 77 of file CFontCache.cpp.

78 {
79  if (m_Fonts.GetCount() == 0u)
80  Read();
81 
82  return m_Fonts.GetCount();
83 }
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
CAtlArray< CFontInfo > m_Fonts
Definition: CFontCache.hpp:29
void Read()
Definition: CFontCache.cpp:142

Referenced by Filename().

Friends And Related Function Documentation

◆ CFontExtModule

friend class CFontExtModule
friend

Definition at line 46 of file CFontCache.hpp.

Member Data Documentation

◆ m_FontFolderPath

CStringW CFontCache::m_FontFolderPath
private

Definition at line 30 of file CFontCache.hpp.

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

◆ m_Fonts

CAtlArray<CFontInfo> CFontCache::m_Fonts
private

Definition at line 29 of file CFontCache.hpp.

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


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