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.

378 lines
11 KiB

  1. /*****************************************************************************
  2. * fontlink.hxx
  3. *
  4. * Global variables and constants for Font Linking functionality.
  5. *
  6. * History
  7. * 2-10-93 Gerrit van Wingerden
  8. * Wrote it.
  9. *
  10. *
  11. * Copyright (c) 1993-1999 Microsoft Corporation
  12. ******************************************************************************/
  13. #ifndef _FONTLINK_INCLUDE_
  14. #define _FONTLINK_INCLUDE_
  15. //
  16. // RFONT->flEUDCState
  17. //
  18. #define EUDC_INITIALIZED 0x001
  19. #define EUDC_WIDTH_REQUESTED 0x040
  20. #define TT_SYSTEM_INITIALIZED 0x080
  21. #define EUDC_NO_CACHE 0x100
  22. #define QUICK_FACE_NAME_LINKS 8
  23. // These are used to partition the glyph data by font. We make them global
  24. // structs rather attach a new copy with each ESTROBJ since all TextOut's with
  25. // EUDC chars are done under the global EUDC semaphore.
  26. enum
  27. {
  28. EUDCTYPE_BASEFONT = 0,
  29. EUDCTYPE_SYSTEM_TT_FONT,
  30. EUDCTYPE_SYSTEM_WIDE,
  31. EUDCTYPE_DEFAULT,
  32. EUDCTYPE_FACENAME
  33. };
  34. // These are used to indentify the type of facename link.
  35. enum
  36. {
  37. //
  38. // This linked font is loaded at system initialization stage,
  39. // or by calling EudcLoadLink(). and this font can be unloaded by
  40. // calling EudcUnloadLink(). but it is not loaded/unloaded by
  41. // calling EnableEUDC().
  42. // The configuration is setted by per System.
  43. //
  44. FONTLINK_SYSTEM = 0,
  45. //
  46. // This linked font is loaded when user logged-on system,
  47. // or by calling EnableEUDC(). and this font is can be unloaded by
  48. // calling both of EudcUnloadLink() and EnableEUDC().
  49. // The configuration is setted by per User.
  50. //
  51. FONTLINK_USER
  52. };
  53. //
  54. // FontLink Configuration value.
  55. //
  56. // [Key]
  57. //
  58. // \HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\FontLink
  59. //
  60. // [Value]
  61. //
  62. // FontLinkControl
  63. //
  64. // [ValueType]
  65. //
  66. // REG_DWORD
  67. //
  68. // +-----------
  69. // 01234567
  70. // +-----------
  71. #define FLINK_DISABLE_FONTLINK 0x00000001
  72. // +-----------
  73. #define FLINK_DISABLE_LINK_BY_FONTTYPE 0x000000F0
  74. #define FLINK_DISABLE_BITMAPFONT 0x00000010
  75. #define FLINK_DISABLE_VECTORFONT 0x00000020
  76. #define FLINK_DISABLE_TTFONT 0x00000040
  77. #define FLINK_DISABLE_DEVFONT 0x00000080
  78. // +-----------
  79. #define FLINK_DISABLE_LINK_BY_EUDCTYPE 0x00000F00 // not implemented
  80. #define FLINK_DISABLE_SYSTEMWIDE 0x00000100 // not implemented
  81. #define FLINK_DISABLE_FACENAME 0x00000200 // not implemented
  82. // +-----------
  83. #define FLINK_NOT_ELIMINATE_INTERNALLEADING 0x00001000
  84. #define FLINK_SCALE_EUDC_BY_HEIGHT 0x00004000
  85. // +-----------
  86. extern ULONG ulFontLinkControl;
  87. #define FLINK_LOAD_FACENAME_SYSTEM 0x0001
  88. #define FLINK_UNLOAD_FACENAME_SYSTEM 0x0002
  89. #define FLINK_LOAD_FACENAME_USER 0x0004
  90. #define FLINK_UNLOAD_FACENAME_USER 0x0008
  91. // PFEDATA->FontLinkFlag
  92. #define FLINK_FACENAME_SPECIFIED 0x0001
  93. // Semaphores
  94. extern HSEMAPHORE ghsemEUDC1;
  95. // extern KEVENT gfmEUDC2;
  96. // change it to long so that one can assert that it is always >= 0
  97. extern LONG gcEUDCCount;
  98. extern BOOL gbAnyLinkedFonts;
  99. //
  100. // System EUDC PFE array.
  101. //
  102. class PFE;
  103. extern PFE *gappfeSysEUDC[2];
  104. // This structure is used to do a quick lookup to see if a glyph is in a linked
  105. // font file or the system EUDC file. Each UNICODE point falling between the
  106. // lowest and highest char in the font is represented by a bit in an array of
  107. // bits. If the bit is set, the character is in the font otherwise it isn't.
  108. typedef struct _QUICKLOOKUP
  109. {
  110. WCHAR wcLow;
  111. WCHAR wcHigh;
  112. UINT *puiBits;
  113. } QUICKLOOKUP;
  114. extern UINT gauiQLMask[];
  115. extern QUICKLOOKUP gqlEUDC;
  116. extern QUICKLOOKUP gqlTTSystem;
  117. #define IS_IN_FACENAME_LINK(pql,wc) \
  118. ((wc >= pql->wcLow) && \
  119. (wc <= pql->wcHigh) && \
  120. (pql->puiBits[(wc-pql->wcLow)/32] & (0x80000000 >> ((wc-pql->wcLow)%32))))
  121. #define IS_IN_SYSTEM_EUDC(wc) \
  122. ((wc >= gqlEUDC.wcLow) && \
  123. (wc <= gqlEUDC.wcHigh) && \
  124. (gqlEUDC.puiBits[wc/32] & ( 0x80000000 >> (wc%32))))
  125. #define IS_IN_SYSTEM_TT(wc) \
  126. ((wc >= gqlTTSystem.wcLow) && \
  127. (wc <= gqlTTSystem.wcHigh) && \
  128. (gqlTTSystem.puiBits[(wc-gqlTTSystem.wcLow)/32] & \
  129. (0x80000000 >> ((wc-gqlTTSystem.wcLow)%32))))
  130. //
  131. // The definition for appfe array in PFEDATA structure
  132. //
  133. #define PFE_NORMAL 0
  134. #define PFE_VERTICAL 1
  135. #define IS_SYSTEM_EUDC_PRESENT() \
  136. (((gappfeSysEUDC[PFE_NORMAL] != NULL) || (gappfeSysEUDC[PFE_VERTICAL] != NULL)) ? \
  137. TRUE : FALSE)
  138. #define IS_FACENAME_EUDC_PRESENT(apfe) \
  139. (((apfe[PFE_NORMAL] != NULL) || (apfe[PFE_VERTICAL] != NULL)) ? TRUE : FALSE)
  140. // EUDC Load Data structure for PFTOBJ::bLoadFont()
  141. typedef struct _EUDCLOAD
  142. {
  143. PPFE *pppfeData; // pointer to array of EUDC PFE
  144. WCHAR *LinkedFace; // pointer wish FaceName in TrueType TTC font
  145. } EUDCLOAD, *PEUDCLOAD;
  146. // FontLink Entry structure
  147. //
  148. // LIST_ENTRY BaseFontListHead
  149. // |
  150. // |-> FLENTRY FaceNameFont1
  151. // | { LIST_ENTRY linkedFontList }
  152. // | |
  153. // | |-> PFEDATA appfeLinkedFont1[2]
  154. // | |-> PFEDATA appfeLinkedFont2[2]
  155. // | |
  156. // | |....
  157. // |
  158. // |-> FLENTRY FaceNameFont2
  159. // | { LIST_ENTRY linkedFontList }
  160. // | |
  161. // | |-> PFEDATA appfeLinkedFont1[2]
  162. // | |-> PFEDATA appfeLinkedFont2[2]
  163. // | |
  164. // | |....
  165. // |
  166. // |....
  167. //
  168. typedef struct _FLENTRY
  169. {
  170. LIST_ENTRY baseFontList; // Pointer to next FLENTRY structure
  171. LIST_ENTRY linkedFontListHead; // list entry for linked font list for this
  172. // base font
  173. WCHAR awcFaceName[LF_FACESIZE+1]; // Base font face name
  174. UINT uiNumLinks; // Number of Linked font for this Base font
  175. ULONG ulTimeStamp; // Timestump for current link.
  176. } FLENTRY, *PFLENTRY;
  177. typedef struct _PFEDATA
  178. {
  179. LIST_ENTRY linkedFontList; // Pointer to next LIST_ENTRY
  180. INT FontLinkType; // FONTLINK_SYSTEM or FONTLINK_USER
  181. ULONG FontLinkFlag; // Information flags.
  182. PFE *appfe[2]; // PPFE array for this Base font
  183. } PFEDATA, *PPFEDATA;
  184. // Internal LogFont structure for EUDC.
  185. typedef struct _EUDCLOGFONT
  186. {
  187. FLONG fsSelection; // ifi.fsSelection
  188. FLONG flBaseFontType; // fo.flFontType
  189. LONG lBaseWidth;
  190. LONG lBaseHeight;
  191. LONG lEscapement;
  192. ULONG ulOrientation;
  193. BOOL bContinuousScaling;
  194. } EUDCLOGFONT, *PEUDCLOGFONT;
  195. // Pointer to null list
  196. extern LIST_ENTRY NullListHead;
  197. // pointer to QUICKLOOKUP table for system EUDC font
  198. extern QUICKLOOKUP gqlEUDC;
  199. // the flag definition for gflEUDCDebug
  200. #define DEBUG_FONTLINK_INIT 0x0001
  201. #define DEBUG_FONTLINK_LOAD 0x0002
  202. #define DEBUG_FONTLINK_UNLOAD 0x0004
  203. #define DEBUG_FONTLINK_TEXTOUT 0x0008
  204. #define DEBUG_FONTLINK_RFONT 0x0010
  205. #define DEBUG_FONTLINK_QUERY 0x0020
  206. #define DEBUG_SYSTEM_EUDC 0x1000
  207. #define DEBUG_FACENAME_EUDC 0x2000
  208. #define DEBUG_FONTLINK_CONTROL 0x4000
  209. #define DEBUG_FONTLINK_DUMP 0x8000
  210. extern FLONG gflEUDCDebug;
  211. #if 0
  212. #define FLINKMESSAGE(Flags,Message) \
  213. if(gflEUDCDebug & Flags) \
  214. DbgPrint(Message);
  215. #define FLINKMESSAGE2(Flags,Message1,Message2) \
  216. if(gflEUDCDebug & Flags) \
  217. DbgPrint(Message1,Message2);
  218. #else
  219. #define FLINKMESSAGE(Flags,Message)
  220. #define FLINKMESSAGE2(Flags,Message1,Message2)
  221. #endif
  222. // Prototype definition in flinkgdi.cxx
  223. PFLENTRY FindBaseFontEntry
  224. (
  225. const WCHAR * BaseFontName
  226. );
  227. BOOL FindDefaultLinkedFontEntry
  228. (
  229. const WCHAR * CandidateFaceName,
  230. const WCHAR * CandidatePathName
  231. );
  232. class ESTROBJ;
  233. class ECLIPOBJ;
  234. class RFONTOBJ;
  235. BOOL bProxyDrvTextOut
  236. (
  237. XDCOBJ& dco,
  238. SURFACE *pSurf,
  239. ESTROBJ& to,
  240. ECLIPOBJ& co,
  241. RECTL *prclExtra,
  242. RECTL *prclBackground,
  243. BRUSHOBJ *pboFore,
  244. BRUSHOBJ *pboOpaque,
  245. POINTL *pptlBrushOrg,
  246. RFONTOBJ& rfo,
  247. PDEVOBJ *pdo,
  248. FLONG flCaps,
  249. RECTL *prclExclude
  250. );
  251. extern WCHAR EudcDefaultChar;
  252. extern BOOL bInitializeEUDC(VOID);
  253. // Font Association related stuff
  254. #define OEM_ASSOC 1 // equal to (Charset(255) + 2) & 0xf)
  255. #define ANSI_ASSOC 2 // equal to (Charset( 0) + 2) & 0xf)
  256. #define SYMBOL_ASSOC 4 // equal to (Charset( 2) + 2) & 0xf)
  257. #define MAX_ASSOC SYMBOL_ASSOC
  258. // Font Association configuration variable
  259. typedef struct _FONT_DEFAULTASSOC
  260. {
  261. BOOL ValidRegData;
  262. ULONG DefaultFontType;
  263. WCHAR DefaultFontTypeID[25]; // FontPackageXXXX
  264. WCHAR DefaultFontFaceName[LF_FACESIZE+1];
  265. WCHAR DefaultFontPathName[MAX_PATH+1];
  266. PFE *DefaultFontPFEs[2];
  267. } FONT_DEFAULTASSOC, *PFONT_DEFAULTASSOC;
  268. #define NUMBER_OF_FONTASSOC_DEFAULT 7
  269. extern UINT fFontAssocStatus;
  270. extern BOOL bReadyToInitializeFontAssocDefault;
  271. extern BOOL bFinallyInitializeFontAssocDefault;
  272. extern FONT_DEFAULTASSOC FontAssocDefaultTable[NUMBER_OF_FONTASSOC_DEFAULT];
  273. typedef struct _FONT_ASSOC_SUB
  274. {
  275. #if DBG
  276. UINT UniqNo;
  277. #endif
  278. WCHAR AssociatedName[LF_FACESIZE+1];
  279. WCHAR OriginalName[LF_FACESIZE+1];
  280. } FONT_ASSOC_SUB, *PFONT_ASSOC_SUB;
  281. // SystemEUDC stuff
  282. extern PFE *gappfeSystemDBCS[2];
  283. extern BOOL gbSystemDBCSFontEnabled;
  284. // moving the following definition to public wingdi.h
  285. // to avoid conflict with external component that were already using this flag, renaming it
  286. // to CLIP_DFA_DISABLE with same value
  287. // #define CLIP_DFA_OVERRIDE (4<<4)
  288. #define INCREMENTEUDCCOUNT \
  289. { \
  290. GreAcquireSemaphore(ghsemEUDC1); \
  291. gcEUDCCount++; \
  292. GreReleaseSemaphore(ghsemEUDC1); \
  293. }
  294. #define DECREMENTEUDCCOUNT \
  295. { \
  296. GreAcquireSemaphore(ghsemEUDC1); \
  297. gcEUDCCount--; \
  298. GreReleaseSemaphore(ghsemEUDC1); \
  299. }
  300. #endif // _FONTLINK_INCLUDE_