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.

155 lines
3.0 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. /* loadfnt2.c - MW font support code */
  5. #define NOWINMESSAGES
  6. #define NOVIRTUALKEYCODES
  7. #define NOSYSMETRICS
  8. #define NOMENUS
  9. #define NOWINSTYLES
  10. #define NOCTLMGR
  11. #define NOCLIPBOARD
  12. #include <windows.h>
  13. #include "mw.h"
  14. #include "macro.h"
  15. #define NOUAC
  16. #include "cmddefs.h"
  17. #include "fontdefs.h"
  18. #include "docdefs.h"
  19. extern int vifceMac;
  20. extern union FCID vfcidScreen;
  21. extern union FCID vfcidPrint;
  22. extern struct FCE rgfce[ifceMax];
  23. extern struct FCE *vpfceMru;
  24. extern struct FCE *vpfceScreen;
  25. extern struct FCE *vpfcePrint;
  26. extern struct DOD (**hpdocdod)[];
  27. struct FCE * (PfceLruGet(void));
  28. struct FCE * (PfceFcidScan(union FCID *));
  29. struct FCE * (PfceLruGet())
  30. /* tosses out the LRU cache entry's information */
  31. {
  32. struct FCE *pfce;
  33. pfce = vpfceMru->pfcePrev;
  34. FreePfce(pfce);
  35. return(pfce);
  36. }
  37. FreePfce(pfce)
  38. /* frees the font objects for this cache entry */
  39. struct FCE *pfce;
  40. {
  41. int ifce;
  42. HFONT hfont;
  43. if (pfce->fcidRequest.lFcid != fcidNil)
  44. {
  45. hfont = pfce->hfont;
  46. /* see if we're about to toss the screen or printer's current font */
  47. if (pfce == vpfceScreen)
  48. {
  49. ResetFont(FALSE);
  50. }
  51. else if (pfce == vpfcePrint)
  52. {
  53. ResetFont(TRUE);
  54. }
  55. #ifdef DFONT
  56. CommSzNum("Deleting font: ", hfont);
  57. #endif /* DFONT */
  58. if (hfont != NULL)
  59. {
  60. DeleteObject(hfont);
  61. pfce->hfont = NULL;
  62. }
  63. if (pfce->hffn != 0)
  64. {
  65. FreeH(pfce->hffn);
  66. }
  67. pfce->fcidRequest.lFcid = fcidNil;
  68. }
  69. }
  70. FreeFonts(fScreen, fPrinter)
  71. /* frees up the font objects for the screen, and the printer */
  72. int fScreen, fPrinter;
  73. {
  74. int ifce, bit;
  75. for (ifce = 0; ifce < vifceMac; ifce++)
  76. {
  77. bit = (rgfce[ifce].fcidRequest.strFcid.wFcid & bitPrintFcid) != 0;
  78. if (bit && fPrinter || !bit && fScreen)
  79. FreePfce(&rgfce[ifce]);
  80. }
  81. }
  82. struct FCE * (PfceFcidScan(pfcid))
  83. union FCID *pfcid;
  84. /* look for this font the "hard way" in the LRU list */
  85. {
  86. struct FFN **hffn, **hffnT;
  87. register struct FCE *pfce;
  88. struct FFN **MpFcidHffn();
  89. hffn = MpFcidHffn(pfcid);
  90. pfce = vpfceMru;
  91. do
  92. {
  93. hffnT = pfce->hffn;
  94. if (hffnT != NULL)
  95. if (WCompSz((*hffn)->szFfn, (*hffnT)->szFfn) == 0 &&
  96. pfcid->strFcid.hps == pfce->fcidRequest.strFcid.hps &&
  97. pfcid->strFcid.wFcid == pfce->fcidRequest.strFcid.wFcid)
  98. {
  99. pfce->fcidRequest.strFcid.doc = pfcid->strFcid.doc;
  100. pfce->fcidRequest.strFcid.ftc = pfcid->strFcid.ftc;
  101. return(pfce);
  102. }
  103. pfce = pfce->pfceNext;
  104. }
  105. while (pfce != vpfceMru);
  106. return(NULL);
  107. }
  108. struct FFN **MpFcidHffn(pfcid)
  109. /* makes sure we use a font code that exists in the table - this is insurance
  110. against out of memory problems */
  111. union FCID *pfcid;
  112. {
  113. int ftc;
  114. struct FFNTB **hffntb;
  115. ftc = pfcid->strFcid.ftc;
  116. hffntb = HffntbGet(pfcid->strFcid.doc);
  117. if (ftc >= (*hffntb)->iffnMac)
  118. ftc = 0;
  119. return((*hffntb)->mpftchffn[ftc]);
  120. }
  121.