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.

185 lines
4.2 KiB

  1. /*++
  2. Copyright (c) 1996 - 1999 Microsoft Corporation
  3. Module Name:
  4. fontfree.c
  5. Abstract:
  6. Frees any font memory, no matter where allocated. This should be
  7. called from DrvDisableSurface to free any memory allocated for
  8. holding font information.
  9. Environment:
  10. Windows NT Unidrv driver
  11. Revision History:
  12. 01/03/97 -ganeshp-
  13. Created
  14. --*/
  15. #include "font.h"
  16. VOID
  17. VFontFreeMem(
  18. PDEV *pPDev
  19. )
  20. /*++
  21. Routine Description:
  22. Called to free all memory allocated for font information.
  23. Basically we track through all the font data contained in
  24. FONTPDEV, freeing as we come across it.
  25. Arguments:
  26. pPDev - Pointer to PDEV.
  27. Return Value: None.
  28. Note:
  29. 01-03-97: Created it -ganeshp-
  30. --*/
  31. {
  32. /*
  33. * The PDEV contains only one thing of interest to us - a pointer
  34. * to the FONTPDEV, which contains all the font memory.
  35. */
  36. register FONTMAP *pFM; /* Working through per font data */
  37. int iIndex;
  38. FONTPDEV *pFontPDev;
  39. FONTMAP_DEV *pFMDev;
  40. pFontPDev = pPDev->pFontPDev;
  41. if (pFontPDev)
  42. pFM = pFontPDev->pFontMap; /* The per font type data */
  43. else
  44. {
  45. WARNING(("\nUnifont!VFontFreeMem: NULL pFontPDev\n"));
  46. return;
  47. }
  48. /*
  49. * If there is font stuff, free it up now.
  50. */
  51. if( pFM )
  52. {
  53. /* Loop through per font */
  54. for( iIndex = 0;
  55. iIndex < pPDev->iFonts;
  56. ++iIndex, (PBYTE)pFM += SIZEOFDEVPFM() )
  57. {
  58. pFMDev = pFM->pSubFM;
  59. if (pFM->dwSignature != FONTMAP_ID)
  60. continue;
  61. /* The UNICODE tree data */
  62. if( pFMDev->pUCTree )
  63. MEMFREEANDRESET(pFMDev->pUCTree );
  64. /* May also need to free the translation table */
  65. if( pFM->flFlags & FM_FREE_GLYDATA && pFMDev->pvNTGlyph)
  66. {
  67. pFM->flFlags &= ~FM_FREE_GLYDATA;
  68. MEMFREEANDRESET(pFMDev->pvNTGlyph );
  69. }
  70. /* The IFIMETRICS data */
  71. if( pFM->pIFIMet )
  72. {
  73. if (pFM->flFlags & FM_IFIRES)
  74. {
  75. /* Data is a resource, so No need to free. */
  76. }
  77. else
  78. {
  79. MEMFREEANDRESET(pFM->pIFIMet);
  80. }
  81. }
  82. if( !(pFM->flFlags & FM_FONTCMD) )
  83. {
  84. /* The font select/deselect commands - if present */
  85. if( pFMDev->cmdFontSel.pCD)
  86. MEMFREEANDRESET(pFMDev->cmdFontSel.pCD);
  87. if( pFMDev->cmdFontDesel.pCD)
  88. MEMFREEANDRESET(pFMDev->cmdFontDesel.pCD);
  89. }
  90. /* Free the width table, if one is allocated */
  91. if( pFMDev->W.psWidth )
  92. {
  93. if( !(pFM->flFlags & FM_WIDTHRES) )
  94. MEMFREEANDRESET(pFMDev->W.psWidth );
  95. }
  96. }
  97. /* Finally - free the FONTMAP array! */
  98. MEMFREEANDRESET(pFontPDev->pFontMap );
  99. }
  100. pPDev->iFonts = 0;
  101. /*
  102. * There may also be font installer information to free up.
  103. */
  104. /*
  105. * Free the downloaded font information. This MUST be done whenever
  106. * the printer is reset (and thus looses fonts), which typically
  107. * is an event that happens during DrvRestartPDEV.
  108. */
  109. VFreeDL( pPDev );
  110. /* Free the Text sorting array, if allocated */
  111. if (pFontPDev->pPSHeader)
  112. {
  113. VFreePS( pPDev );
  114. }
  115. if (pFontPDev)
  116. {
  117. /* Free different structuress */
  118. if (pFontPDev->FontList.pdwList)
  119. MEMFREEANDRESET(pFontPDev->FontList.pdwList);
  120. if (pFontPDev->FontCartInfo.pFontCartMap)
  121. MEMFREEANDRESET(pFontPDev->FontCartInfo.pFontCartMap);
  122. if (pFontPDev->pTTFontSubReg)
  123. MEMFREEANDRESET(pFontPDev->pTTFontSubReg);
  124. if (pFontPDev->hUFFFile)
  125. FICloseFontFile(pFontPDev->hUFFFile);
  126. MEMFREEANDRESET(pFontPDev);
  127. pPDev->pFontPDev = NULL;
  128. }
  129. return;
  130. }