Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.4 KiB

  1. /*
  2. * Font Cache
  3. */
  4. #ifndef DUI_BASE_FONTCACHE_H_INCLUDED
  5. #define DUI_BASE_FONTCACHE_H_INCLUDED
  6. #pragma once
  7. namespace DirectUI
  8. {
  9. // Supported styles
  10. #define FS_None 0x00000000
  11. #define FS_Italic 0x00000001
  12. #define FS_Underline 0x00000002
  13. #define FS_StrikeOut 0x00000004
  14. class FontCache
  15. {
  16. public:
  17. static HRESULT Create(UINT uCacheSize, OUT FontCache** ppCache);
  18. void Destroy();
  19. HFONT CheckOutFont(LPWSTR szFamily, int dSize, int dWeight, int dStyle, int dAngle);
  20. void CheckInFont() { _fLock = false; }
  21. struct FontRecord
  22. {
  23. HFONT hFont;
  24. WCHAR szFamily[LF_FACESIZE];
  25. int dSize;
  26. int dWeight;
  27. int dStyle;
  28. int dAngle;
  29. UINT uHits;
  30. };
  31. struct RecordIdx // Array sorted by frequency of use
  32. {
  33. FontCache* pfcContext; // Context used for global sort routine
  34. UINT idx; // Refers to a FontRecord location
  35. };
  36. UINT _GetRecordHits(UINT uRec) { return (_pDB + uRec)->uHits; }
  37. FontCache() {}
  38. HRESULT Initialize(UINT uCacheSize);
  39. virtual ~FontCache();
  40. private:
  41. bool _fLock;
  42. UINT _uCacheSize;
  43. FontRecord* _pDB; // Array of cached records
  44. RecordIdx* _pFreq; // Array of sorted record indicies by frequency of use
  45. };
  46. } // namespace DirectUI
  47. #endif // DUI_BASE_FONTCACHE_H_INCLUDED