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.

139 lines
3.2 KiB

  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 2000 Microsoft Corporation
  4. *
  5. * Module Name:
  6. *
  7. * fontcollection.cpp
  8. *
  9. * Revision History:
  10. *
  11. * 03/06/00 DChinn
  12. * Created it.
  13. *
  14. \**************************************************************************/
  15. #include "precomp.hpp"
  16. INT
  17. GpFontCollection::GetFamilyCount()
  18. {
  19. if (!FontTable->IsPrivate() && !FontTable->IsFontLoaded())
  20. FontTable->LoadAllFonts();
  21. return FontTable->EnumerableFonts();
  22. }
  23. GpStatus
  24. GpFontCollection::GetFamilies(
  25. INT numSought,
  26. GpFontFamily* gpfamilies[],
  27. INT* numFound
  28. )
  29. {
  30. if (!FontTable->IsPrivate() && !FontTable->IsFontLoaded())
  31. FontTable->LoadAllFonts();
  32. return FontTable->EnumerateFonts(numSought, gpfamilies, *numFound);
  33. }
  34. GpInstalledFontCollection::GpInstalledFontCollection()
  35. {
  36. FontTable = new GpFontTable;
  37. if (FontTable != NULL)
  38. {
  39. /* verify if we were running out of memory during the creation */
  40. if (!FontTable->IsValid())
  41. {
  42. delete FontTable;
  43. FontTable = NULL;
  44. }
  45. else
  46. {
  47. FontTable->SetPrivate(FALSE);
  48. }
  49. }
  50. }
  51. GpInstalledFontCollection::~GpInstalledFontCollection()
  52. {
  53. delete FontTable;
  54. instance = NULL;
  55. }
  56. // definition of static data member of the singleton class GpInstalledFontCollection
  57. GpInstalledFontCollection* GpInstalledFontCollection::instance = NULL;
  58. GpInstalledFontCollection* GpInstalledFontCollection::GetGpInstalledFontCollection()
  59. {
  60. if (instance == NULL)
  61. {
  62. instance = new GpInstalledFontCollection;
  63. /* verify if there was any memory error during the creation */
  64. if (instance != NULL)
  65. {
  66. if (instance->FontTable == NULL)
  67. {
  68. delete instance;
  69. instance = NULL;
  70. }
  71. }
  72. }
  73. return instance;
  74. }
  75. GpStatus
  76. GpInstalledFontCollection::InstallFontFile(const WCHAR *filename)
  77. {
  78. return (FontTable->AddFontFile(filename, this));
  79. }
  80. GpStatus
  81. GpInstalledFontCollection::UninstallFontFile(const WCHAR *filename)
  82. {
  83. return (FontTable->RemoveFontFile(filename));
  84. }
  85. GpPrivateFontCollection::GpPrivateFontCollection()
  86. {
  87. FontTable = new GpFontTable;
  88. if (FontTable != NULL)
  89. {
  90. /* verify if we were running out of memory during the creation */
  91. if (!FontTable->IsValid())
  92. {
  93. delete FontTable;
  94. FontTable = NULL;
  95. }
  96. else
  97. {
  98. FontTable->SetPrivate(TRUE);
  99. FontTable->SetFontFileLoaded(TRUE);
  100. }
  101. }
  102. }
  103. GpPrivateFontCollection::~GpPrivateFontCollection()
  104. {
  105. delete FontTable;
  106. }
  107. GpStatus
  108. GpPrivateFontCollection::AddFontFile(const WCHAR* filename)
  109. {
  110. return (FontTable->AddFontFile(filename, this));
  111. }
  112. GpStatus
  113. GpPrivateFontCollection::AddMemoryFont(const VOID *memory, INT length)
  114. {
  115. return (FontTable->AddFontMemImage(static_cast<const BYTE *>(memory),
  116. length,
  117. this));
  118. }