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.

195 lines
4.9 KiB

  1. /************************************************************/
  2. /* Windows Write, Copyright 1985-1992 Microsoft Corporation */
  3. /************************************************************/
  4. /* This routine sets up the screen position used by Word relative to the
  5. current device. */
  6. #define NOGDICAPMASKS
  7. #define NOVIRTUALKEYCODES
  8. #define NOWINMESSAGES
  9. #define NOWINSTYLES
  10. #define NOCLIPBOARD
  11. #define NOCTLMGR
  12. #define NOMENUS
  13. /* HEY! if you change this to wwsmall.h, talk to bobm!
  14. (see Assert(LF_FACESIZE == LocalFaceSize)) */
  15. #include <windows.h>
  16. #include "mw.h"
  17. #include "cmddefs.h"
  18. #include "docdefs.h"
  19. #include "fontdefs.h"
  20. int viffnDefault = -1;
  21. CHAR rgffnFontFamily[6][ibFfnMax];
  22. struct FFN *PffnDefault(ffid)
  23. /* returns pointer to default font structure for this font family ID, which
  24. is set up when we started the program */
  25. FFID ffid;
  26. {
  27. int iffn;
  28. struct FFN *pffn;
  29. if (ffid == FF_DONTCARE)
  30. {
  31. Assert(viffnDefault >= 0);
  32. iffn = viffnDefault;
  33. }
  34. else
  35. iffn = MpFfidIffn(ffid);
  36. pffn = (struct FFN *)(rgffnFontFamily[iffn]);
  37. if (pffn->szFfn[0] == 0)
  38. /* haven't gotten this one yet - must be old word document */
  39. GetDefaultFonts(TRUE, FALSE);
  40. Assert(pffn->szFfn[0] != 0);
  41. return(pffn);
  42. }
  43. GetDefaultFonts(fExtraFonts, fGetAspect)
  44. /* We set up our table of default fonts in two steps. First we choose a single
  45. font, to use as the default font for a new document. Perhaps later, we
  46. are asked for a set of default fonts for different families to help
  47. make sense out of an old, word document. That case is differentiated
  48. by fExtraFonts being TRUE */
  49. int fExtraFonts, fGetAspect;
  50. {
  51. extern int aspectXFont;
  52. extern int aspectYFont;
  53. extern HDC vhDCPrinter;
  54. struct FFN *pffn;
  55. CHAR rgb[ibFfnMax];
  56. Assert(LF_FACESIZE == LocalFaceSize);
  57. #ifndef NEWFONTENUM
  58. Assert(vhDCPrinter);
  59. if (fGetAspect && vhDCPrinter != NULL)
  60. {
  61. extern FARPROC lpFontFaceEnum;
  62. int rgw[6];
  63. rgw[0] = enumFindAspectRatio;
  64. rgw[1] = rgw[2] = 0xFFFF;
  65. rgw[3] = GetDeviceCaps(vhDCPrinter, LOGPIXELSY);
  66. rgw[4] = GetDeviceCaps(vhDCPrinter, LOGPIXELSX);
  67. rgw[5] = TRUE;
  68. EnumFonts(vhDCPrinter, 0L, lpFontFaceEnum, (LPSTR)MAKELONG(&rgw[0], 0));
  69. aspectXFont = rgw[1];
  70. aspectYFont = rgw[2];
  71. }
  72. #endif
  73. if (FInitFontEnum(docNil, fExtraFonts ? 32767 : 1, TRUE))
  74. {
  75. pffn = (struct FFN *)rgb;
  76. while (FEnumFont(pffn))
  77. #ifdef NEWFONTENUM
  78. DefaultFamilyCheck(pffn->ffid, pffn->szFfn, pffn->chs);
  79. #else
  80. DefaultFamilyCheck(pffn->ffid, pffn->szFfn);
  81. #endif
  82. EndFontEnum();
  83. }
  84. /* Fill in just in case we missed some. The order here is important, if
  85. there are no fonts at all, the default font will be the first one. */
  86. {
  87. extern CHAR szModern[];
  88. extern CHAR szRoman[];
  89. extern CHAR szSwiss[];
  90. extern CHAR szScript[];
  91. extern CHAR szDecorative[];
  92. DefaultFamilyCheck(FF_MODERN, szModern, NULL);
  93. if (fExtraFonts)
  94. {
  95. DefaultFamilyCheck(FF_ROMAN, szRoman, NULL);
  96. DefaultFamilyCheck(FF_SWISS, szSwiss, NULL);
  97. DefaultFamilyCheck(FF_SCRIPT, szScript, NULL);
  98. DefaultFamilyCheck(FF_DECORATIVE, szDecorative, NULL);
  99. DefaultFamilyCheck(FF_DONTCARE, szSwiss, NULL);
  100. }
  101. }
  102. }
  103. DefaultFamilyCheck(ffid, sz, chsIfKnown)
  104. FFID ffid;
  105. CHAR *sz;
  106. BYTE chsIfKnown;
  107. {
  108. int iffn;
  109. struct FFN *pffn;
  110. iffn = MpFfidIffn(ffid);
  111. pffn = (struct FFN *)(rgffnFontFamily[iffn]);
  112. if (pffn->szFfn[0] == 0)
  113. {
  114. #ifdef NEWFONTENUM
  115. pffn->chs = chsIfKnown;
  116. #endif
  117. pffn->ffid = ffid;
  118. bltszLimit(sz, pffn->szFfn, LF_FACESIZE);
  119. if (viffnDefault < 0)
  120. /* this font will be chosen for new documents */
  121. viffnDefault = iffn;
  122. }
  123. }
  124. #define iffnSwiss 0
  125. #define iffnRoman 1
  126. #define iffnModern 2
  127. #define iffnScript 3
  128. #define iffnDecorative 4
  129. #define iffnDontCare 5
  130. MpFfidIffn(ffid)
  131. FFID ffid;
  132. {
  133. switch (ffid)
  134. {
  135. default:
  136. Assert( FALSE );
  137. /* FALL THROUGH */
  138. case FF_DONTCARE:
  139. return(iffnDontCare);
  140. case FF_SWISS:
  141. return(iffnSwiss);
  142. case FF_ROMAN:
  143. return(iffnRoman);
  144. case FF_MODERN:
  145. return(iffnModern);
  146. case FF_SCRIPT:
  147. return(iffnScript);
  148. case FF_DECORATIVE:
  149. return(iffnDecorative);
  150. }
  151. }
  152. ResetDefaultFonts(fGetAspect)
  153. int fGetAspect;
  154. {
  155. /* This routine resets the default mapping from a font family to a font face
  156. name. */
  157. bltbc(rgffnFontFamily, 0, 6 * ibFfnMax);
  158. viffnDefault = -1;
  159. GetDefaultFonts(FALSE, fGetAspect);
  160. }
  161.