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.

1296 lines
39 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: pfeobj.hxx
  3. *
  4. * The physical font entry (PFE) user object, and memory objects.
  5. *
  6. * The physical font entry object:
  7. * ------------------------------
  8. *
  9. * o each font "face" is associated with a physical font entry
  10. *
  11. * o stores information about where a particular font exists
  12. *
  13. * o buffers the font metrics
  14. *
  15. * o buffers the font mappings (which completely specifies the
  16. * character set)
  17. *
  18. * o provides services for the following APIs:
  19. *
  20. * o GetTextFace
  21. *
  22. * o GetTextMetrics
  23. *
  24. * Created: 25-Oct-1990 16:37:07
  25. * Author: Gilman Wong [gilmanw]
  26. *
  27. * Copyright (c) 1990-1999 Microsoft Corporation
  28. *
  29. \**************************************************************************/
  30. #ifndef _PFEOBJ_
  31. #define _PFEOBJ_
  32. /**************************************************************************\
  33. *
  34. * enum ENUMFONTSTYLE
  35. *
  36. * When enumerating fonts via EnumFonts, Windows 3.1 assumes that there are
  37. * 4 basic variations: Regular (same as Normal or Roman), Bold, Italic, or
  38. * Bold-Italic. It doesn't understand other stylistic variations such as
  39. * Demi-bold or Extra-bold.
  40. *
  41. * This enumerated type is used to classify PFEs into one of six categories:
  42. *
  43. * EFSTYLE_REGULAR The basic four styles.
  44. * EFSTYLE_BOLD
  45. * EFSTYLE_ITALIC
  46. * EFSTYLE_BOLDITALIC
  47. *
  48. * EFSTYLE_OTHER This is a unique style that EnumFonts will treat
  49. * specially. The facename will be used as if it were
  50. * the family name.
  51. *
  52. * EFSTYLE_SKIP Ignore this font as a unique style.
  53. *
  54. \**************************************************************************/
  55. typedef enum _ENUMFONTSTYLE { /* efsty */
  56. EFSTYLE_REGULAR = 0,
  57. EFSTYLE_BOLD = 1,
  58. EFSTYLE_ITALIC = 2,
  59. EFSTYLE_BOLDITALIC = 3,
  60. EFSTYLE_SKIP = 4,
  61. EFSTYLE_OTHER = 5
  62. } ENUMFONTSTYLE;
  63. #define EFSTYLE_MAX 6
  64. #ifndef GDIFLAGS_ONLY // used for gdikdx
  65. // Alingment when allocating PFEs in PFE Collect
  66. #if defined(i386)
  67. // natural alignment for x86 is on 32 bit boundary
  68. #define NATURAL_ALIGN(x) (((x) + 3L) & ~3L)
  69. #else
  70. // for mips and alpha we want 64 bit alignment
  71. #define NATURAL_ALIGN(x) (((x) + 7L) & ~7L)
  72. #endif
  73. // The size for each PFE in PFE Collect
  74. #define SZ_PFE(cfsCharSetTable) NATURAL_ALIGN(offsetof(PFE,aiFamilyName) + cfsCharSetTable * sizeof(BYTE))
  75. /*********************************Class************************************\
  76. * struct EFFILTER_INFO
  77. *
  78. * Structure that tells what type of font enumeration filtering should be used.
  79. * Parameters needed for certain types of filtering are also included here.
  80. *
  81. * History:
  82. * 07-Aug-1992 -by- Gilman Wong [gilmanw]
  83. * Wrote it.
  84. \**************************************************************************/
  85. typedef struct _EFFILTER_INFO /* effi */
  86. {
  87. // Aspect ratio filtering -- reject font if aspect ratio does not match
  88. // devices.
  89. BOOL bAspectFilter;
  90. POINTL ptlDeviceAspect;
  91. // Non-True type filtering -- reject all TrueType fonts.
  92. BOOL bNonTrueTypeFilter;
  93. // TrueType filtering -- reject all non-TrueType fonts.
  94. BOOL bTrueTypeFilter;
  95. // EngineFiltering -- reject all engine font (for generic printer driver)
  96. BOOL bEngineFilter;
  97. // Raster filtering -- reject all raster fonts (needed if device is not
  98. // raster-capable.
  99. BOOL bRasterFilter;
  100. // Win 3.1 App compatibility
  101. // TrueType duplicate filtering -- reject all raster fonts with the same
  102. // name as an existing TrueType font
  103. // (GACF_TTIGNORERASTERDUPE flag).
  104. BOOL bTrueTypeDupeFilter;
  105. COUNT cTrueType; // Count of TrueType fonts in a list -- Used for
  106. // compatibility flag GACF_TTIGNORERASTERDUPE. This
  107. // should be set to the value from the HASHBUCKET
  108. // in the FONTHASH table being enumerated.
  109. // added to support EnumFontFamiliesEx. If lfCharSetFilter != DEFAULT_CHARSET,
  110. // only the fonts that support jCharSetFilter will be enumerated.
  111. ULONG lfCharSetFilter;
  112. } EFFILTER_INFO;
  113. #endif // GDIFLAGS_ONLY used for gdikdx
  114. /**************************************************************************\
  115. * FONTHASHTYPE *
  116. * *
  117. * Identifies the list of PFE's to traverse. *
  118. \**************************************************************************/
  119. typedef enum _FONTHASHTYPE
  120. {
  121. FHT_FACE = 0,
  122. FHT_FAMILY = 1,
  123. FHT_UFI = 2
  124. } FONTHASHTYPE;
  125. /*********************************Class************************************\
  126. * class PFE : public OBJECT
  127. *
  128. * Physical font entry object
  129. *
  130. * pPFF The pointer to the physical font file object which
  131. * represents the physical font file for this PFE.
  132. *
  133. * iFont The index of the font in either the font file (IFI)
  134. * or the driver (device managed fonts).
  135. *
  136. * bDeadState This is state information cached from the PFF. If
  137. * TRUE, then this PFE is part of a PFF that has been
  138. * marked for deletion (but deletion has been delayed).
  139. * Therefore, we should not enumerate or map to this
  140. * PFE.
  141. *
  142. * pfdg Pointer to the UNICODE to HGLYPH mapping table. This
  143. * points to memory managed by the driver.
  144. *
  145. * pifi Pointer to the IFIMETRICS. This points to memory
  146. * managed by the driver.
  147. *
  148. * History:
  149. * Wed 23-Dec-1992 00:13:00 -by- Charles Whitmer [chuckwh]
  150. * Changed most uses of HPFE to (PFE *).
  151. *
  152. * Wed 15-Apr-1992 07:10:36 by Kirk Olynyk [kirko]
  153. * Added hpfeNextFace and hpfeNextFamily
  154. *
  155. * 30-Oct-1990 -by- Gilman Wong [gilmanw]
  156. * Wrote it.
  157. \**************************************************************************/
  158. #define PFE_DEVICEFONT 0x00000001L
  159. #define PFE_DEADSTATE 0x00000002L
  160. #define PFE_REMOTEFONT 0x00000004L
  161. #define PFE_EUDC 0x00000008L
  162. #define PFE_SBCS_SYSTEM 0x00000010L
  163. #define PFE_UFIMATCH 0x00000020L
  164. #define PFE_MEMORYFONT 0x00000040L
  165. #define PFE_DBCS_FONT 0x00000080L
  166. #define PFE_VERT_FACE 0x00000100L
  167. #ifndef GDIFLAGS_ONLY // used for gdikdx
  168. // The GISET strucutre is allocated and computed only for tt fonts
  169. // and only if truly needed, that is if ETO_GLYPHINDEX mode of ExtTextOut
  170. // is ever used on this font. This structure describes all glyph handles in
  171. // the font.
  172. typedef struct _GIRUN
  173. {
  174. USHORT giLow; // first glyph index in the run
  175. USHORT cgi; // number of indicies in the run
  176. } GIRUN;
  177. typedef struct _GISET
  178. {
  179. ULONG cgiTotal; // total number of glyph indicies, usually the same as cGlyphsSupported
  180. ULONG cGiRuns; // number of runs
  181. GIRUN agirun[1]; // array of cGiRuns GIRUN's
  182. } GISET;
  183. class PFE /* pfe */
  184. {
  185. public:
  186. // Location of font.
  187. PPFF pPFF; // pointer to physical font file object
  188. ULONG iFont; // index of the font for IFI or device
  189. FLONG flPFE;
  190. // Font data.
  191. FD_GLYPHSET *pfdg; // ptr to wc-->hg map
  192. ULONG_PTR idfdg; // id returned by driver for FD_GLYPHSET
  193. PIFIMETRICS pifi; // pointer to ifimetrics
  194. ULONG_PTR idifi; // id returned by driver for IFIMETRICS
  195. FD_KERNINGPAIR *pkp; // pointer to kerning pairs (lazily loaded on demand)
  196. ULONG_PTR idkp; // id returned by driver for FD_KERNINGPAIR
  197. COUNT ckp; // count of kerning pairs in the FD_KERNINGPAIR arrary
  198. LONG iOrientation; // Cache IFI orientation.
  199. ULONG cjEfdwPFE; // size of enumeration data needed for this pfe
  200. // information needed to support ETO_GLYPHINDEX mode of ExtTextOut.
  201. GISET *pgiset; // initialized to NULL;
  202. // Time stamp.
  203. ULONG ulTimeStamp; // unique time stamp (smaller == older)
  204. // Universal font indentifier
  205. UNIVERSAL_FONT_ID ufi; // Unique ID for this font/face.
  206. // PID of process that created this font (used for remote fonts only)
  207. W32PID pid;
  208. PW32THREAD tid;
  209. #ifdef FE_SB
  210. // EUDC font stuff
  211. // This entry will be used for linked font.
  212. QUICKLOOKUP ql; // QUICKLOOKUP if a linked font
  213. // This entry will be used for base font.
  214. PFLENTRY pFlEntry; // Pointer to linked font list
  215. #endif
  216. // number of entries in the font substitution table such that
  217. // alternate family name is the same as the family name of THIS pfe.
  218. // Example: if this is a pfe for Arial, than if there are two entries
  219. // in the font substitution table, e.g. as below
  220. //
  221. // Arial Grk,161 = Arial,161
  222. // Arial Trk,162 = Arial,162
  223. //
  224. // than cAlt should be set to 2
  225. ULONG cAlt;
  226. // cRef for pfdg
  227. ULONG cPfdgRef;
  228. BYTE aiFamilyName[1]; // aiFamilyNameg[cAltCharSets]
  229. };
  230. #define PPFENULL ((PFE *) NULL)
  231. #define PFEOBJ_FL_STOCK 1
  232. /*********************************Class************************************\
  233. * class PFEOBJ *
  234. * *
  235. * User object for physical font entries. *
  236. * *
  237. * History: *
  238. * Tue 15-Dec-1992 23:55:35 -by- Charles Whitmer [chuckwh] *
  239. * Unified the Family/Face lists. Changed allocation routines. *
  240. * *
  241. * Wed 15-Apr-1992 07:14:54 by Kirk Olynyk [kirko] *
  242. * Added phpfeNextFace(), phpfeNextFamily(), pwszFaceName(), *
  243. * pwszStyleName(), pwszUniqueName(). *
  244. * *
  245. * 25-Oct-1990 -by- Gilman Wong [gilmanw] *
  246. * Wrote it. *
  247. \**************************************************************************/
  248. // links pfe's into enumeration lists
  249. typedef struct _PFELINK
  250. {
  251. struct _PFELINK *ppfelNext;
  252. PFE *ppfe;
  253. } PFELINK;
  254. class PFEOBJ /* pfeo */
  255. {
  256. public:
  257. // Constructor
  258. PFEOBJ(PFE *ppfe_) {ppfe = (PFE *) ppfe_;}
  259. PFEOBJ() {}
  260. // Destructor
  261. ~PFEOBJ() {}
  262. // same as constructor essentially, allows change on the fly
  263. PFE *ppfeSet(PFELINK *ppfel) { return (ppfe = ppfel->ppfe);}
  264. // bValid -- returns TRUE if lock successful.
  265. BOOL bValid() {return(ppfe != PPFENULL);}
  266. // bDelete -- deletes the PFE object.
  267. VOID vDelete(); // PFEOBJ.CXX
  268. // bDeviceFont -- Returns TRUE if a device specific font. We can only
  269. // get metrics from such fonts (no bitmaps or outlines).
  270. BOOL bDeviceFont() {return(ppfe->flPFE & PFE_DEVICEFONT);}
  271. // bEquivNames -- Returns TRUE if font has a list of equivalent names.
  272. BOOL bEquivNames()
  273. {
  274. return (ppfe->pifi->flInfo & FM_INFO_FAMILY_EQUIV);
  275. }
  276. // bDead -- Returns TRUE if the font is in a "ready to die" state. This
  277. // state is inherited from the PFF and is cached here for speed.
  278. BOOL bDead() {return(ppfe->flPFE & PFE_DEADSTATE);}
  279. #ifdef FE_SB
  280. // bEUDC -- Returns TRUE if the font has been loaded as an EUDC font. We
  281. // dont enumerate such fonts.
  282. BOOL bEUDC() {return(ppfe->flPFE & PFE_EUDC);}
  283. VOID vSetLinkedFontEntry( PFLENTRY _pFlEntry )
  284. {ppfe->pFlEntry = _pFlEntry;}
  285. PFLENTRY pGetLinkedFontEntry() {return(ppfe->pFlEntry);}
  286. PLIST_ENTRY pGetLinkedFontList()
  287. {
  288. if(ppfe->pFlEntry != NULL )
  289. return( &(ppfe->pFlEntry->linkedFontListHead) );
  290. else
  291. return( &(NullListHead) );
  292. }
  293. ULONG ulGetLinkTimeStamp()
  294. {
  295. if(ppfe->pFlEntry != NULL )
  296. return( ppfe->pFlEntry->ulTimeStamp );
  297. else
  298. return( 0 );
  299. }
  300. QUICKLOOKUP *pql() {return(&(ppfe->ql));}
  301. BOOL bVerticalFace() {return(ppfe->flPFE & PFE_VERT_FACE);}
  302. BOOL bSBCSSystemFont() {return(ppfe->flPFE & PFE_SBCS_SYSTEM);}
  303. #endif
  304. // vKill -- Puts font in a "ready to die" state. This is a state inherited
  305. // from the PFF and is cached here for speed.
  306. VOID vKill() {ppfe->flPFE |= PFE_DEADSTATE;}
  307. // vRevive -- Clears the "ready to die" state. This is a state inherited
  308. // from the PFF and is cached here for speed.
  309. VOID vRevive() {ppfe->flPFE &= ~PFE_DEADSTATE; }
  310. // hpfec -- returns the handle of PFE collect object.
  311. HPFEC hpfecGet();
  312. PFE *ppfeGet() {return(ppfe);}
  313. // pPFF -- returns the handle of the PFF representing the file from which
  314. // the font (which this PFE represents) came from.
  315. PPFF pPFF () { return(ppfe->pPFF); }
  316. // iFont -- the index or id of the font within the file.
  317. ULONG iFont () { return(ppfe->iFont); }
  318. // bSetFontXform -- calculates the font transform needed to rasterize this
  319. // physical font with the properties in the wish list.
  320. BOOL bSetFontXform ( // PFEOBJ.CXX
  321. XDCOBJ &dc, // for this device
  322. LOGFONTW *plfw, // wish list
  323. PFD_XFORM pfd_xfm, // font transform
  324. FLONG fl_, // flags
  325. FLONG flSim,
  326. POINTL* const pptlSim,
  327. IFIOBJ& ifio,
  328. BOOL bIsLinkedFont // is passed in as TRUE if the font is linked, FALSE otherwise
  329. );
  330. // pifi -- returns a pointer to the IFIMETRICS of this font.
  331. PIFIMETRICS pifi() { return (ppfe->pifi); }
  332. // cjEfdwPFE -- returns the size of enumeration data for this font
  333. ULONG cjEfdwPFE() { return (ppfe->cjEfdwPFE); }
  334. // dpNtmi -- retruns the offset to NTMW_INTERNAL from the top of ENUMFONTDATAW
  335. ULONG dpNtmi();
  336. // pfdg -- returns a pointer to the wchar-->hglyph map
  337. FD_GLYPHSET *pfdg();
  338. VOID vFreepfdg();
  339. // cKernPairs -- returns a pointer to the FD_KERNINGPAIR array for this
  340. // font and the count of kerning pairs.
  341. COUNT cKernPairs ( // PFEOBJ.CXX
  342. FD_KERNINGPAIR **ppkp
  343. );
  344. // flFontType -- returns flags describing the type of font.
  345. FLONG flFontType (); // PFEOBJ.CXX
  346. // pwszFamilyName
  347. // pwszStyleName
  348. // pwszFaceName
  349. // pwszUniqueName -- return pointers to various font name strings.
  350. BOOL bCheckFamilyName(const WCHAR * pwszFaceName, BOOL bIgnoreVertical, BOOL *pbAliasMatch = NULL);
  351. PWSZ pwszFamilyName()
  352. {
  353. return((PWSZ)(((BYTE*) ppfe->pifi) + ppfe->pifi->dpwszFamilyName));
  354. }
  355. PWSZ pwszFamilyNameAlias(BOOL *pbIsFamilyNameAlias)
  356. {
  357. PWSZ pFaceName;
  358. *pbIsFamilyNameAlias = FALSE;
  359. if (ppfe->pifi->flInfo & FM_INFO_FAMILY_EQUIV)
  360. {
  361. *pbIsFamilyNameAlias = TRUE;
  362. }
  363. return((PWSZ)(((BYTE*) ppfe->pifi) + ppfe->pifi->dpwszFamilyName));
  364. }
  365. PWSZ pwszStyleName()
  366. {
  367. return((PWSZ)(((BYTE*) ppfe->pifi) + ppfe->pifi->dpwszStyleName));
  368. }
  369. PWSZ pwszFaceName()
  370. {
  371. return((PWSZ)(((BYTE*) ppfe->pifi) + ppfe->pifi->dpwszFaceName));
  372. }
  373. PWSZ pwszUniqueName()
  374. {
  375. return((PWSZ)(((BYTE*) ppfe->pifi) + ppfe->pifi->dpwszUniqueName));
  376. }
  377. // efstyCompute -- return ENUMFONTSTYLE based on font properties.
  378. ENUMFONTSTYLE efstyCompute(); // PFEOBJ.CXX
  379. // bFilteredOut -- returns TRUE if font should be filtered out of the
  380. // font enumeration.
  381. BOOL bFilteredOut(EFFILTER_INFO *peffi); // PFEOBJ.CXX
  382. // bFilterNotEnum() -- return TRUE if this pfe should be filtered out for enumeration
  383. // either it is embedded font or it is loaded with FR_NOT_ENUM bit set.
  384. BOOL bFilterNotEnum(); // PFEOBJ.CXX
  385. // font stored in private PFT
  386. BOOL bPrivate(); //PFEOBJ.CXX
  387. // font embedded by the current process
  388. BOOL bEmbedOk(); // PFEOBJ.CXX
  389. // bEmbPvtOk() -- return TRUE if the process loaded the font as Embedded or Private
  390. BOOL bEmbPvtOk(); // PFEOBJ.CXX
  391. // bUFIMatchOnly() -- return TRUE if PFE_UFIMATCH bit is set. The font is added to the
  392. // public font table temporarily only for remote printing.
  393. BOOL bUFIMatchOnly() {return(ppfe->flPFE & PFE_UFIMATCH);}
  394. // iOrientation
  395. ULONG iOrientation() {return(ppfe->iOrientation);}
  396. // ulTimeStamp -- returns PFE's time stamp.
  397. ULONG ulTimeStamp() { return ppfe->ulTimeStamp; }
  398. // vUFI returns PFE's universal font identifier
  399. VOID vUFI( PUNIVERSAL_FONT_ID pufi ) { *pufi = *(&ppfe->ufi); }
  400. PUNIVERSAL_FONT_ID pUFI() { return(&ppfe->ufi); }
  401. // make sure current process is the same one that installed this remote PFE
  402. BOOL SameProccess()
  403. {
  404. return((ppfe->pid == 0) || (ppfe->pid == W32GetCurrentPID()));
  405. }
  406. BOOL SameThread()
  407. {
  408. return((ppfe->tid == 0) || (ppfe->tid == (PW32THREAD)PsGetCurrentThread()));
  409. }
  410. // Debugging code
  411. //
  412. VOID vPrint (); // PFEOBJ.CXX
  413. VOID vPrintAll (); // PFEOBJ.CXX
  414. protected:
  415. PFE *ppfe;
  416. };
  417. /*********************************Class************************************\
  418. * class PFEMEMOBJ : public PFEOBJ
  419. *
  420. * Memory object for physical font entries.
  421. *
  422. * Public Interface:
  423. *
  424. * PFEMEMOBJ () // alloc. default PFE size
  425. * ~PFEMEMOBJ () // destructor
  426. *
  427. * BOOL bValid () // validator
  428. * VOID vKeepIt () // preserve memory object
  429. * BOOL bInit ( // initialize PFE
  430. *
  431. * History:
  432. * 29-Oct-1990 -by- Gilman Wong [gilmanw]
  433. * Wrote it.
  434. \**************************************************************************/
  435. #define PFEMO_KEEPIT 0x0001
  436. class PFEMEMOBJ : public PFEOBJ /* pfemo */
  437. {
  438. public:
  439. // Contructors -- Allocate memory for the objects and lock.
  440. PFEMEMOBJ(PFE *ppfe_) {ppfe = ppfe_;}
  441. // Destructor -- Unlock object.
  442. ~PFEMEMOBJ() {}
  443. // bValid -- Validator which returns TRUE if allocation successful.
  444. BOOL bValid() {return(ppfe != PPFENULL);}
  445. // vKeepIt -- Prevent destructor from deleting the new PFE.
  446. // bInit -- Initialize the PFE
  447. // PFEOBJ.CXX
  448. BOOL bInit
  449. (
  450. PPFF pPFF,
  451. ULONG iFont,
  452. FD_GLYPHSET *pfdg,
  453. ULONG_PTR idfdg,
  454. PIFIMETRICS pifi,
  455. ULONG_PTR ididi,
  456. BOOL bDeviceFont,
  457. PUNIVERSAL_FONT_ID pufi // used only for remote fonts on the print server
  458. #ifdef FE_SB
  459. ,BOOL bEUDC
  460. #endif
  461. );
  462. };
  463. /*********************************Class************************************\
  464. * class PFEC : public OBJECT
  465. *
  466. * PFE Collect object
  467. *
  468. * Member:
  469. * pvPFE: pointer embedded for the array of PFE
  470. *
  471. *
  472. * History:
  473. * 3-June-1999 Yung-Jen Tony Tsai [YungT]
  474. * Wrote it.
  475. \**************************************************************************/
  476. class PFEC : public OBJECT
  477. {
  478. public:
  479. PVOID pvPFE;
  480. ULONG cjPFE;
  481. };
  482. /*********************************Class************************************\
  483. * class PFECOBJ
  484. *
  485. * Implementation class for PFE Collect object
  486. *
  487. * Interfaces:
  488. * // Constructor
  489. *
  490. * PFECOBJ(PFEC *ppfec_)
  491. * PFECOBJ()
  492. *
  493. * // Destructor
  494. *
  495. * ~PFECOBJ() {}
  496. *
  497. * PFE * GetPFE(ULONG iFont);
  498. * HPFEC GetHPFEC();
  499. *
  500. *
  501. * History:
  502. * 3-June-1999 Yung-Jen Tony Tsai [YungT]
  503. * Wrote it.
  504. \**************************************************************************/
  505. class PFECOBJ
  506. {
  507. public:
  508. // Constructor
  509. PFECOBJ(PFEC *ppfec_) {ppfec = (PFEC *) ppfec_;}
  510. PFECOBJ() {}
  511. // Destructor
  512. ~PFECOBJ() {}
  513. PFE * GetPFE(ULONG iFont);
  514. HPFEC GetHPFEC();
  515. protected:
  516. PFEC *ppfec;
  517. };
  518. class HPFECOBJ : public PFECOBJ
  519. {
  520. public:
  521. HPFECOBJ(HPFEC hpfec) { ppfec = (PFEC *) HmgShareLock((HOBJ)hpfec,PFE_TYPE); }
  522. ~HPFECOBJ() { if (ppfec != NULL) {DEC_SHARE_REF_CNT(ppfec);} }
  523. };
  524. /**************************************************************************\
  525. * FONT NAME HASHING STRUCTURES AND CONSTANTS
  526. *
  527. *
  528. \**************************************************************************/
  529. #if DBG
  530. typedef VOID (*VPRINT) (char*,...);
  531. #endif
  532. /*********************************Class************************************\
  533. * struct HASHBUCKET
  534. *
  535. * Members:
  536. *
  537. * ppfeEnumHead head of the font enumeration list of PFEs (stable order)
  538. *
  539. * ppfeEnumTail tail of the font enumeration list of PFEs
  540. *
  541. * Notes:
  542. *
  543. * There is a separate list for font enumeration because the shifting order
  544. * of the font mapper's list makes enumeration a little strange. A head
  545. * and tail is maintained for the font enumeration list so that the proper
  546. * order for EnumFonts() can be maintained (Win 3.1 compatibility issue);
  547. * new PFEs may have to be inserted either at the head or the tail of the
  548. * list.
  549. *
  550. * Note that the mapper and enumeration lists both link together the same
  551. * exact set of PFEs, but in different orders.
  552. *
  553. * History:
  554. * 05-Aug-1992 -by- Gilman Wong [gilmanw]
  555. * Wrote it.
  556. \**************************************************************************/
  557. typedef struct _HTABLE /* ht */
  558. {
  559. LONG lTooSmall; // see [1] below
  560. LONG lMin; // smallest available
  561. LONG lMax; // biggest available
  562. LONG lTooBig; // see [2] below
  563. PFE *appfe[1]; //
  564. } HTABLE;
  565. /***
  566. NOTES on the HTABLE structure
  567. [1] If the requested font height is less than or equal to lTooSmall
  568. then none of the fonts in the list can be used. A default small
  569. font must be substituted
  570. [2] If the requested font height is greater than or equal to lTooBig
  571. then none of the fonts in the list can be used. A default big
  572. font must be substituted
  573. ***/
  574. typedef union tagHASHUNION {
  575. WCHAR wcCapName[LF_FACESIZE];
  576. UNIVERSAL_FONT_ID ufi;
  577. } HASHUNION;
  578. typedef struct _HASHBUCKET /* hbkt */
  579. {
  580. struct _HASHBUCKET *pbktCollision;
  581. PFELINK *ppfelEnumHead; // head of font enumeration list
  582. PFELINK *ppfelEnumTail; // tail of font enumeration list
  583. COUNT cTrueType; // count of TrueType fonts in list
  584. COUNT cRaster; // count of Raster fonts in list
  585. FLONG fl; // misc info
  586. // Doubly linked list of buckets. This list is maintained in the order
  587. // that they were loaded. Actually, in the order that the oldest PFE in
  588. // each bucket was loaded.
  589. struct _HASHBUCKET *pbktPrev;
  590. struct _HASHBUCKET *pbktNext;
  591. ULONG ulTime; // time stamp of "oldest" PFE in bucket's list
  592. HASHUNION u; // either the face name or the UFI
  593. } HASHBUCKET;
  594. //
  595. // HASHBUCKET::fl flag constants
  596. //
  597. #define HB_HTABLE_NOT_POSSIBLE 1
  598. #define HB_EQUIV_FAMILY 2
  599. /*********************************Class************************************\
  600. * struct FONTHASH *
  601. * *
  602. * Public Interface: *
  603. * *
  604. * History: *
  605. * Sun 12-Apr-1992 08:35:52 by Kirk Olynyk [kirko] *
  606. * Wrote it. *
  607. \**************************************************************************/
  608. typedef struct _FONTHASH
  609. {
  610. UINT id; // 'HASH'
  611. FONTHASHTYPE fht; // table type
  612. UINT cBuckets; // total number of buckets
  613. UINT cUsed; // number of buckets in use
  614. UINT cCollisions;
  615. HASHBUCKET *pbktFirst; // first bucket of doubly linked list of hash
  616. // buckets maintained in order loaded into system
  617. HASHBUCKET *pbktLast; // last bucket of doubly linked list of hash
  618. // buckets maintained in order loaded into system
  619. HASHBUCKET *apbkt[1]; // array of bucket pointers.
  620. } FONTHASH;
  621. #define FONTHASH_ID 0x48534148
  622. class EFSOBJ;
  623. /*********************************Class************************************\
  624. * class FHOBJ
  625. *
  626. * Public Interface:
  627. *
  628. * History:
  629. * 06-Aug-1992 00:38:11 by Gilman Wong [gilmanw]
  630. * Added phpfeEnumNext(), bMapperGoNext(), bEnumGoNext(), bScanLists().
  631. *
  632. * Sun 19-Apr-1992 09:32:23 by Kirk Olynyk [kirko]
  633. * Wrote it.
  634. \**************************************************************************/
  635. class FHOBJ
  636. {
  637. public:
  638. FONTHASH **ppfh;
  639. FONTHASH *pfh;
  640. COUNT cLists() { return ((COUNT) pfh->cUsed); }
  641. // Search for the given string in the hash table, return the bucket
  642. // and index.
  643. HASHBUCKET *pbktSearch(const WCHAR * pwsz,UINT *pi,PUNIVERSAL_FONT_ID pufi = NULL, BOOL bIsEquiv = FALSE);
  644. // Initialize the FONTHASH.
  645. VOID vInit(FONTHASHTYPE,UINT);
  646. // Return the type.
  647. FONTHASHTYPE fht() {return(pfh->fht);}
  648. // Returns pointer to string that the PFEOBJ is hashed on.
  649. PWSZ pwszName(PFEOBJ& pfeo)
  650. {
  651. return((pfh->fht == FHT_FAMILY) ? pfeo.pwszFamilyName() : pfeo.pwszFaceName());
  652. }
  653. // Constructors and destructors.
  654. FHOBJ() {}
  655. FHOBJ(FONTHASH **ppfh_)
  656. {
  657. ppfh = ppfh_;
  658. pfh = *ppfh;
  659. }
  660. ~FHOBJ() {};
  661. // Insert and delete PFEs from the hash table.
  662. BOOL bInsert(PFEOBJ&);
  663. VOID vDelete(PFEOBJ&);
  664. // Add/Delete pfe link only from one hash bucket,
  665. // add/delete bucket itself when appropriate
  666. BOOL bAddPFELink(HASHBUCKET *, UINT, WCHAR *, PFEOBJ&, BOOL bEquiv);
  667. VOID vDeletePFELink(HASHBUCKET *, UINT, PFEOBJ&);
  668. // Delete the hash table.
  669. VOID vFree();
  670. // Validate the FHOBJ.
  671. BOOL bValid()
  672. {
  673. #if DBG
  674. if (ppfh && *ppfh)
  675. {
  676. ASSERTGDI(pfh->id == FONTHASH_ID,"GDISRV::FHOBJ bad id\n");
  677. return(TRUE);
  678. }
  679. else
  680. return(FALSE);
  681. #else
  682. return (ppfh && *ppfh);
  683. #endif
  684. }
  685. // Fill the EFOBJ with data from hash table.
  686. BOOL bScanLists(EFSOBJ *pefso, ULONG iEnumType, EFFILTER_INFO *peffi);
  687. BOOL bScanLists(EFSOBJ *pefso, PWSZ pwszName, ULONG iEnumType, EFFILTER_INFO *peffi);
  688. #if DBG
  689. VOID vPrint(VPRINT);
  690. #endif
  691. };
  692. /*********************************Class************************************\
  693. * class ENUMFHOBJ : public FHOBJ
  694. *
  695. * Identical to FHOBJ except that it contains methods for enumeration
  696. & of every single font on the list
  697. *
  698. * History:
  699. * Mon 08-Mar-1993 10:20:59 by Kirk Olynyk [kirko]
  700. * Wrote it.
  701. \**************************************************************************/
  702. class ENUMFHOBJ : public FHOBJ
  703. {
  704. public:
  705. PFELINK *ppfelCur; // current font link
  706. HASHBUCKET *pbktCur; // current hash bucket
  707. ENUMFHOBJ(FONTHASH **ppfh_) : FHOBJ(ppfh_)
  708. {
  709. ppfelCur = NULL;
  710. pbktCur = (HASHBUCKET*) NULL;
  711. }
  712. ENUMFHOBJ() {};
  713. PFE* ENUMFHOBJ::ppfeFirst()
  714. {
  715. PFE *ppfeRet = NULL;
  716. if (pbktCur = pfh->pbktFirst)
  717. {
  718. ppfelCur = pbktCur->ppfelEnumHead;
  719. }
  720. if (ppfelCur)
  721. ppfeRet = ppfelCur->ppfe;
  722. return ppfeRet;
  723. }
  724. PFE* ENUMFHOBJ::ppfeNext()
  725. {
  726. //
  727. // I know that all fonts are inserted into the FAMILY list
  728. //
  729. PFE *ppfeRet = NULL;
  730. if ((ppfelCur = ppfelCur->ppfelNext) == NULL)
  731. {
  732. if (pbktCur = pbktCur->pbktNext)
  733. {
  734. ppfelCur = pbktCur->ppfelEnumHead;
  735. }
  736. }
  737. if (ppfelCur)
  738. ppfeRet = ppfelCur->ppfe;
  739. return ppfeRet;
  740. }
  741. };
  742. #define ASSERTPFEO(pfeo) ASSERTGDI(pfeo.bValid(),"GDISRV!FONTHASH::iSearch -- invalid PFEOBJ\n")
  743. /*********************************Class************************************\
  744. * class FHMEMOBJ : public FHOBJ
  745. *
  746. * Public Interface:
  747. *
  748. * History:
  749. * Sun 19-Apr-1992 09:36:17 by Kirk Olynyk [kirko]
  750. * Wrote it.
  751. \**************************************************************************/
  752. class FHMEMOBJ : public FHOBJ
  753. {
  754. public:
  755. FHMEMOBJ
  756. (
  757. FONTHASH **ppfhNew,
  758. FONTHASHTYPE fht_,
  759. UINT count
  760. );
  761. };
  762. /*********************************Class************************************\
  763. * struct EFENTRY
  764. *
  765. * Used to form a list of PFEs to enumerate. We store the real handles
  766. * rather than pointers because PFEs can disappear while processing
  767. * the enumeration callbacks. So we need to use handles to validate that
  768. * the PFEs accumulated into the EFSTATE is still valid.
  769. *
  770. * History:
  771. * 07-Aug-1992 -by- Gilman Wong [gilmanw]
  772. * Wrote it.
  773. \**************************************************************************/
  774. #endif // GDIFLAGS_ONLY used for gdikdx
  775. #define FJ_FAMILYOVERRIDE 1
  776. #define FJ_CHARSETOVERRIDE 2
  777. #ifndef GDIFLAGS_ONLY // used for gdikdx
  778. typedef struct _EFENTRY /* efe */
  779. {
  780. HPFEC hpfec; // Handle to PFE to enumerate.
  781. ULONG iFont; // Index of PFE in
  782. ENUMFONTSTYLE efsty; // style classification (used only for EnumFonts())
  783. BYTE fjOverride; // override family and/or charset
  784. BYTE jCharSetOverride; // only used in case of EnumFontFamiliesEx
  785. USHORT iOverride;// index into substitution table
  786. } EFENTRY;
  787. /*********************************Class************************************\
  788. * class EFSTATE : public OBJECT
  789. *
  790. * Font enumeration state. This object is used to store a list of HPFE
  791. * handles that represent the set of fonts that will be enumerated. This
  792. * object also saves state information used to "chunk" or "batch" this data
  793. * across the client-server interface.
  794. *
  795. * It is a first class engine object so that if the client crashes, the
  796. * process termination cleanup code will automatically clean up any loose
  797. * EFSTATs lying around. This is necessary because the callback mechanism
  798. * of the EnumFonts() and EnumFontFamilies() doesn't not allow us to
  799. * guarantee that the EFSTATE will always be destroyed within the context
  800. * of the API call.
  801. *
  802. * History:
  803. * 07-Aug-1992 -by- Gilman Wong [gilmanw]
  804. * Wrote it.
  805. \**************************************************************************/
  806. class EFSTATE : public OBJECT /* efs */
  807. {
  808. public:
  809. // This pointer is normally NULL, but if an alternate name (facename
  810. // substitution via the [FontSubstitutions] section of WIN.INI) is
  811. // used then this pointer will reference the alternate name string.
  812. // That is, if there is a line
  813. // face1,charset1=face2,charset2
  814. // in [FontSubstitutions], font will be enumerated as face1,charset1
  815. // even though the metrics etc returned will correspond to face2,charset2
  816. FONTSUB * pfsubOverride;
  817. // enum type: EnumFonts, EnumFontFamilies or EnumFontFamiliesEx
  818. ULONG iEnumType;
  819. // Pointers that identify ranges of either engine font handles or
  820. // device font handles. (The handles in these ranges are actually
  821. // handles to the heads of linked lists of PFEs that are either
  822. // engine or device fonts).
  823. // [GilmanW] 07-Aug-1992 Please don't delete the comment below.
  824. //
  825. // The use of pointers here is a slight optimization. However, if the
  826. // handle manager is rewritten so that objects may move in the handle
  827. // manager's heap, then these should be replaced with either indices or
  828. // PTRDIFFS.
  829. EFENTRY *pefeDataEnd; // new EFENTRYs are inserted into ahpfe here
  830. EFENTRY *pefeBufferEnd; // end of aefe array
  831. EFENTRY *pefeEnumNext; // next EFENTRY in aefe array to be enumerated
  832. // size of all ENUMFONTDATA structures needed to enumerate all pfe's
  833. // associated with this EFSTATE
  834. ULONG cjEfdwTotal;
  835. // Array of EFENTRYs to enumerate.
  836. EFENTRY aefe[1];
  837. };
  838. typedef EFSTATE *PEFSTATE;
  839. #define PEFSTATENULL ((PEFSTATE) NULL)
  840. /*********************************Class************************************\
  841. * class EFSOBJ
  842. *
  843. * User object for the EFSTATE object.
  844. *
  845. * Public Interface:
  846. *
  847. * History:
  848. * 07-Aug-1992 -by- Gilman Wong [gilmanw]
  849. * Wrote it.
  850. \**************************************************************************/
  851. class EFSOBJ /* efo */
  852. {
  853. friend BOOL bSetEFSTATEOwner(HEFS hefs, // PFEOBJ.CXX
  854. ULONG lPid);
  855. protected:
  856. PEFSTATE pefs;
  857. public:
  858. // Constructor -- locks EFSTATE object.
  859. EFSOBJ(HEFS hefs) {pefs = (PEFSTATE) HmgLock((HOBJ)hefs,EFSTATE_TYPE);}
  860. EFSOBJ() {}
  861. // Destructor -- unlock EFSTATE object.
  862. ~EFSOBJ() {if (pefs != PEFSTATENULL) {DEC_EXCLUSIVE_REF_CNT(pefs);}}
  863. // bValid -- returns TRUE if lock successful.
  864. BOOL bValid() { return (pefs != PEFSTATENULL); }
  865. // bDelete -- deletes the EFSTATE object.
  866. VOID vDeleteEFSOBJ(); // PFEOBJ.CXX
  867. // get the enumeration type
  868. ULONG iEnumType() {return pefs->iEnumType;}
  869. // hefs -- return the handle to the EFSTATE object.
  870. HEFS hefs() { return((HEFS) pefs->hGet()); }
  871. // cefe -- return the number of EFENTRYs in the enumeration.
  872. // Sundown truncation
  873. ULONG cefe() { return (ULONG)(pefs->pefeDataEnd - pefs->aefe); }
  874. // cjEfdw -- total size of enumeration data needed
  875. ULONG cjEfdwTotal() { return pefs->cjEfdwTotal; }
  876. // bEmpty -- return TRUE if no EFENTRYs in the enumeration.
  877. BOOL bEmpty() { return (pefs->pefeDataEnd == pefs->aefe); }
  878. // pefeEnumNext -- return next EFENTRY to enumerate (NULL if no more).
  879. EFENTRY *pefeEnumNext()
  880. {
  881. EFENTRY *pefeRet = (pefs->pefeEnumNext < pefs->pefeDataEnd) ? pefs->pefeEnumNext : (EFENTRY *) NULL;
  882. pefs->pefeEnumNext++;
  883. return pefeRet;
  884. }
  885. // vUsedAltName -- tells EFSTATE that an alternate name was used to enumerate.
  886. VOID vUsedAltName(FONTSUB *pfsub_) {pefs->pfsubOverride = pfsub_;}
  887. // pwszFamilyOverride -- returns the alternate name (NULL if there is none).
  888. PWSZ pwszFamilyOverride()
  889. {
  890. return pefs->pfsubOverride ? (PWSZ)pefs->pfsubOverride->awchOriginal : NULL;
  891. }
  892. BYTE jCharSetOverride()
  893. {
  894. return pefs->pfsubOverride ? pefs->pfsubOverride->fcsFace.jCharSet : DEFAULT_CHARSET;
  895. }
  896. // this is false if no substitution or if charset is not specified
  897. BOOL bCharSetOverride()
  898. {
  899. if (pefs->pfsubOverride &&
  900. !(pefs->pfsubOverride->fcsFace.fjFlags & FJ_NOTSPECIFIED))
  901. return TRUE;
  902. else
  903. return FALSE;
  904. }
  905. // bGrow -- expand the EFSTATE object.
  906. BOOL bGrow(COUNT cefeMinIncrement); // PFEOBJ.CXX
  907. // bAdd -- add new entries to the font enumeration
  908. // few flags added to indicate which font need to be added in enumeration
  909. // FL_ENUMFAMILIES flag is set to indicate that all names from
  910. // [FontSubstitutes] section of the registry whose alternate name is equal
  911. // to the family name of this physical font should be added to enumeration.
  912. // This supports new multilingual behavior of EnumFontFamilies when no family
  913. // name is passed to the funciton
  914. #define FL_ENUMFAMILIES 1
  915. // added to support the new win95 api EnumFontFamiliesEx. If FL_ENUMFAMILIESEX
  916. // flag is set and lfCharSet == DEFAULT_CHARSET,
  917. // the same physical font should be added to enumeration
  918. // as many times as there are multiple charsets supported in this font.
  919. // However, if lfCharSet != DEFAULT_CHARSET, the font should be added
  920. // to enumeration iff it supports this particular charset.
  921. #define FL_ENUMFAMILIESEX 2
  922. BOOL bAdd ( // PFEOBJ.CXX
  923. PFE *ppfe,
  924. ENUMFONTSTYLE efsty,
  925. FLONG fl=0,
  926. ULONG lfCharSet = DEFAULT_CHARSET
  927. );
  928. };
  929. /*********************************Class************************************\
  930. * class EFSMEMOBJ : public EFSOBJ
  931. *
  932. * Memory object for physical font entries.
  933. *
  934. * Public Interface:
  935. *
  936. * EFSMEMOBJ (COUNT chpfe); // allocate EFSTATE
  937. * ~EFSMEMOBJ () // destructor
  938. *
  939. * BOOL bValid () // validator
  940. * VOID vKeepIt () // preserve memory object
  941. * VOID vInit () // initialize EFSTATE
  942. *
  943. * History:
  944. * 29-Oct-1990 -by- Gilman Wong [gilmanw]
  945. * Wrote it.
  946. \**************************************************************************/
  947. #define EFSMO_KEEPIT 0x0002
  948. class EFSMEMOBJ : public EFSOBJ /* efsmo */
  949. {
  950. public:
  951. // Contructors -- Allocate memory for the objects and lock.
  952. EFSMEMOBJ (COUNT cefe, ULONG iEnumType_); // PFEOBJ.CXX
  953. // Destructor -- Unlock object.
  954. ~EFSMEMOBJ (); // PFEOBJ.CXX
  955. // vKeepIt -- Prevent destructor from deleting PFT.
  956. VOID vKeepIt () { fs |= EFSMO_KEEPIT; }
  957. // vInit -- Initialize the EFSTATE.
  958. VOID vInit (COUNT cefe, ULONG iEnumType_); // PFEOBJ.CXX
  959. // vXerox -- copy the aefe table.
  960. VOID vXerox(EFSTATE *pefsSrc); // PFEOBJ.CXX
  961. private:
  962. FSHORT fs;
  963. };
  964. PFE *ppfeGetPFEFromUFI (
  965. PUNIVERSAL_FONT_ID pufi,
  966. BOOL bPrivate,
  967. BOOL bCheckProccess);
  968. #endif // GDIFLAGS_ONLY used for gdikdx
  969. #endif