Source code of Windows XP (NT5)
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.

62 lines
1019 B

  1. /* _KERN.H
  2. *
  3. * Purpose:
  4. * Latin pair-kerning cache.
  5. *
  6. * Authors:
  7. * Keith Curtis
  8. *
  9. * Copyright (c) 1995-2000, Microsoft Corporation. All rights reserved.
  10. */
  11. #include "_array.h"
  12. struct KPE
  13. {
  14. WCHAR chFirst;
  15. WCHAR chSecond;
  16. short du;
  17. };
  18. typedef unsigned int KERNHASHKEY;
  19. enum KernCacheInitState
  20. {
  21. Unitialized, //Don't know if there are kerning pairs
  22. Initialized, //There are kerning pairs
  23. NoKerningPairs //No kerning pairs found
  24. };
  25. class CKernCache
  26. {
  27. public:
  28. CKernCache::CKernCache()
  29. {
  30. _kcis = Unitialized;
  31. }
  32. BOOL FInit(HFONT hfont);
  33. void Free(void)
  34. {
  35. _pmpkpe.Clear(AF_DELETEMEM);
  36. }
  37. void Add(WCHAR chFirst, WCHAR chSecond, LONG du);
  38. LONG FetchDup(WCHAR chFirst, WCHAR chSecond, long dvpFont);
  39. private:
  40. void Init(HFONT hfont);
  41. inline int Hash(KERNHASHKEY kernhashkey)
  42. {
  43. return kernhashkey % _pmpkpe.Count();
  44. }
  45. static inline KERNHASHKEY MakeHashKey(WCHAR chFirst, WCHAR chSecond)
  46. {
  47. return chFirst | (chSecond << 16);
  48. }
  49. CArray<KPE> _pmpkpe;
  50. KernCacheInitState _kcis;
  51. };