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.

646 lines
28 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: fontmap.hxx *
  3. * *
  4. * For the exclusive use by "fontmap.cxx" *
  5. * *
  6. * Created: 30-Jan-1992 08:05:15 *
  7. * Author: Kirk Olynyk [kirko] *
  8. * *
  9. * Copyright (c) 1991-1999 Microsoft Corporation *
  10. * *
  11. \**************************************************************************/
  12. extern LONG lDevFontThresh;
  13. #define U_NULL 0x00
  14. #define U_SPACE 0x20
  15. #define U_LATIN_CAPITAL_LETTER_A 0x41
  16. #define U_LATIN_CAPITAL_LETTER_B 0x42
  17. #define U_LATIN_CAPITAL_LETTER_C 0x43
  18. #define U_LATIN_CAPITAL_LETTER_D 0x44
  19. #define U_LATIN_CAPITAL_LETTER_E 0x45
  20. #define U_LATIN_CAPITAL_LETTER_F 0x46
  21. #define U_LATIN_CAPITAL_LETTER_G 0x47
  22. #define U_LATIN_CAPITAL_LETTER_H 0x48
  23. #define U_LATIN_CAPITAL_LETTER_I 0x49
  24. #define U_LATIN_CAPITAL_LETTER_J 0x4A
  25. #define U_LATIN_CAPITAL_LETTER_K 0x4B
  26. #define U_LATIN_CAPITAL_LETTER_L 0x4C
  27. #define U_LATIN_CAPITAL_LETTER_M 0x4D
  28. #define U_LATIN_CAPITAL_LETTER_N 0x4E
  29. #define U_LATIN_CAPITAL_LETTER_O 0x4F
  30. #define U_LATIN_CAPITAL_LETTER_P 0x50
  31. #define U_LATIN_CAPITAL_LETTER_Q 0x51
  32. #define U_LATIN_CAPITAL_LETTER_R 0x52
  33. #define U_LATIN_CAPITAL_LETTER_S 0x53
  34. #define U_LATIN_CAPITAL_LETTER_T 0x54
  35. #define U_LATIN_CAPITAL_LETTER_U 0x55
  36. #define U_LATIN_CAPITAL_LETTER_V 0x56
  37. #define U_LATIN_CAPITAL_LETTER_W 0x57
  38. #define U_LATIN_CAPITAL_LETTER_X 0x58
  39. #define U_LATIN_CAPITAL_LETTER_Y 0x59
  40. #define U_LATIN_CAPITAL_LETTER_Z 0x5A
  41. #define U_COMMERCIAL_AT 0x40
  42. /**************************************************************************\
  43. * Win 3.1 Font Mapper Weights *
  44. * *
  45. * public BigWeightTable *
  46. * BigWeightTable label word *
  47. * dw 65000 ;PCharSet 0 *
  48. * dw 19000 ;POutPrecisMismatch 1 *
  49. * dw 15000 ;PPitchFixed 2 ; = 350 for JAPAN *
  50. * dw 10000 ;PFaceName 3 *
  51. * dw 500 ;PFaceNameSubst 4 *
  52. * dw 9000 ;PFamily 5 *
  53. * dw 8000 ;PFamilyUnknown 6 *
  54. * dw 50 ;PFamilyUnlikely 7 *
  55. * dw 600 ;PHeightBigger 8 *
  56. * dw 350 ;PPitchVariable 9 *
  57. * dw 150 ;PFHeightSmaller 10 *
  58. * dw 150 ;PFHeightBigger 11 *
  59. * dw 50 ;PFWidth 12 *
  60. * dw 50 ;PSizeSynth 13 *
  61. * dw 4 ;PFUnevenSizeSynth 14 *
  62. * dw 20 ;PFIntSizeSynth 15 *
  63. * dw 30 ;PFAspect 16 *
  64. * dw 4 ;PItalic 17 *
  65. * dw 1 ;PItalicSim 18 *
  66. * dw 3 ;PFWeight 19 *
  67. * dw 3 ;PUnderline 20 *
  68. * dw 3 ;PStrikeOut 21 *
  69. * dw 1 ;PDefaultPitchFixed 22 *
  70. * dw 1 ;PSmallPenalty 23 *
  71. * dw 2 ;PFVHeightSmaller 24 *
  72. * dw 1 ;PFVHeightBigger 25 *
  73. * dw 2 ;DeviceFavor 26 *
  74. * dw 1 ;PFVertical 27 *
  75. * dw 1 ;PFWeightNumer 28 *
  76. * dw 10 ;PFWeightDenom 29 *
  77. * *
  78. \**************************************************************************/
  79. #define FM_WEIGHT_HEIGHT 150
  80. #define FM_WEIGHT_SIMULATED_WEIGHT ((FW_BOLD-FW_NORMAL)*2/5)
  81. #define FM_WEIGHT_UNEVEN_SIZE_SYNTH 400
  82. #define FM_WEIGHT_INT_SIZE_SYNTH 20
  83. #define FM_WEIGHT_CHARSET 65000
  84. #define FM_WEIGHT_OUTPRECISMISMATCH 19000
  85. #define FM_WEIGHT_PITCHFIXED 15000
  86. #define FM_WEIGHT_FACENAME 10000
  87. #define FM_WEIGHT_FACENAMESUBST 500
  88. #define FM_WEIGHT_FAMILY 9000
  89. #define FM_WEIGHT_FAMILYUNKNOWN 8000
  90. #define FM_WEIGHT_FAMILYUNLIKELY 50
  91. #define FM_WEIGHT_HEIGHTBIGGER 600
  92. #define FM_WEIGHT_PITCHVARIABLE 350
  93. #define FM_WEIGHT_FHEIGHTSMALLER 150
  94. #define FM_WEIGHT_FHEIGHTBIGGER 150
  95. #define FM_WEIGHT_FWIDTH 50
  96. #define FM_WEIGHT_SIZESYNTH 50
  97. #define FM_WEIGHT_FUNEVENSIZESYNTH 4
  98. #define FM_WEIGHT_FINTSIZESYNTH 20
  99. #define FM_WEIGHT_FASPECT 30
  100. #define FM_WEIGHT_ITALIC 4
  101. #define FM_WEIGHT_ITALICSIM 1
  102. #define FM_WEIGHT_FWEIGHT 3
  103. #define FM_WEIGHT_UNDERLINE 3
  104. #define FM_WEIGHT_STRIKEOUT 3
  105. #define FM_WEIGHT_DEFAULTPITCHFIXED 1
  106. #define FM_WEIGHT_SMALLPENALTY 1
  107. #define FM_WEIGHT_FVHEIGHTSMALLER 2
  108. #define FM_WEIGHT_FVHEIGHTBIGGER 1
  109. #define FM_WEIGHT_DEVICEFAVOR 2
  110. #define FM_WEIGHT_FVERTICAL 1
  111. #define FM_WEIGHT_FWEIGHTNUMER 1
  112. #define FM_WEIGHT_FWEIGHTDENOM 10
  113. #define FM_WEIGHT_DEVICE_ALIAS 1
  114. #define FM_WEIGHT_FAVOR_TT 2
  115. #define WIN31_BITMAP_HEIGHT_SCALING_CRITERIA(ask,cand) ((ask) > (7*(cand))/4)
  116. #define WIN31_BITMAP_HEIGHT_SCALING(ask,cand) (((ask) + (cand)/4)/(cand))
  117. #define WIN31_BITMAP_HEIGHT_SCALING_BAD(scale,cand) ((scale)+2>=(cand))
  118. #define WIN31_BITMAP_HEIGHT_SCALING_MAX 8
  119. // NT_FAST_DONTCARE_WEIGHT_PENALTY(x) = FM_WEIGHT_FWEIGHT*x/2*FM_WEIGHT_FWEIGHTDENOM
  120. #define NT_FAST_DONTCARE_WEIGHT_PENALTY(x) ((((((x)<<3)+(x))<<1)+(x))>>7)
  121. // NT_FAST_WEIGHT_PENALTY(x) = FM_WEIGHT_FWEIGHT*x/FM_WEIGHT_FWEIGHTDENOM
  122. #define NT_FAST_WEIGHT_PENALTY(x) (((((((x)<<3)+(x))<<3))+(x))>>8)
  123. #define WIN31_BITMAP_WIDTH_SCALING_CRITERIA(ask,cand) ((ask) > (cand))
  124. // The following code will cause an overflow if ask is too big
  125. // #define WIN31_BITMAP_WIDTH_SCALING(ask,cand) ((2*(ask) + (cand))/(2*(cand)))
  126. // In the new code below, we assume the variables involved are signed integers
  127. // and that cand > 0 and ask > cand.
  128. #define WIN31_BITMAP_WIDTH_SCALING(ask,cand) ( ( ((ask) - (((cand)+1)/2) ) / (cand) ) + 1)
  129. #define WIN31_BITMAP_WIDTH_SCALING_MAX 5
  130. // WIN31_BITMAP_WIDTH_SCALING_PENALTY(x) = FM_WEIGHT_FINTSIZESYNTH*x
  131. #define WIN31_BITMAP_WIDTH_SCALING_PENALTY(x) (((x)<<4)+((x)<<2))
  132. // WIN31_BITMAP_ASPECT_MISHMATCH_PENALTY(x) is x*FM_WEIGHT_FASPECT
  133. #define WIN31_BITMAP_ASPECT_MISMATCH_PENALTY(x) ((((x)<<4)-(x))<<1)
  134. #define WIN31_BITMAP_EMBOLDEN_CRITERIA(lPen) (lPen>(FW_BOLD-FW_NORMAL)/2)
  135. #define WIN31_BITMAP_ASPECT_BASED_SCALING(dev,font) ((dev) > (3*font/2))
  136. #define PITCH_MASK 0x0F
  137. #define FAMILY_MASK 0xF0
  138. /**************************************************************************\
  139. * Allowed Bit fields for MAPPER::fl *
  140. \**************************************************************************/
  141. #define FM_BIT_STILL_ALIVE 0x00000001 // indicates status after construction
  142. #define FM_BIT_USE_EMHEIGHT 0x00000002
  143. #define FM_BIT_CELL 0x00000004
  144. #define FM_BIT_HEIGHT 0x00000008
  145. #define FM_BIT_WIDTH 0x00000010
  146. #define FM_BIT_BAD_WISH_CELL 0x00000020 // Crummy transform for raster font.
  147. #define FM_BIT_PIXEL_COORD 0x00000040 // See Note below
  148. #define FM_BIT_DEVICE_FONT 0x00000080 // current font is a device font
  149. #define FM_BIT_DEVICE_RA_ABLE 0x00000100 // device can use raster fonts
  150. #define FM_BIT_DEVICE_HAS_FONTS 0x00000200 // there are some device fonts
  151. #define FM_BIT_DEVICE_CR_90_ALL 0x00000400 // device fonts support n*90 rotations
  152. #define FM_BIT_NO_MAX_HEIGHT 0x00000800 // per font information
  153. #define FM_BIT_GM_COMPATIBLE 0x00001000 // Win 3.1 compatible mapping
  154. #define FM_BIT_SYSTEM_REQUEST 0x00002000 // App requested system
  155. #define FM_BIT_SYSTEM_FONT 0x00004000 // per-font information
  156. #define FM_BIT_PROOF_QUALITY 0x00008000 // App requested proof quality
  157. #define FM_BIT_DEVICE_PLOTTER 0x00010000 // never never feed this bitmaps
  158. #define FM_BIT_CALLED_BGETFACENAME 0x00020000 // don't bother calling again
  159. #define FM_BIT_DISPLAY_DC 0x00040000 // device is a monitor
  160. #define FM_BIT_ORIENTATION 0x00080000 // iOrientationDevice is good.
  161. #define FM_BIT_DISABLE_TT_NAMES 0x00100000 // do not use a TT name in bGetFaceName
  162. #define FM_BIT_FW_DONTCARE 0x00200000 // specified FW_DONT_CARE in lf
  163. #define FM_BIT_EQUIV_NAME 0x00400000 // current bucket is an alias
  164. #define FM_BIT_TMS_RMN_REQUEST 0x00800000 // app asked for "tms rmn"
  165. #define FM_BIT_BEST_IS_DEVICE 0x01000000 // ppfeBest points to a device font
  166. #define FM_BIT_VERT_FACE_REQUEST 0x02000000 // app asked for "@******"
  167. #define FM_BIT_CHARSET_ACCEPT 0x04000000 // accept regardless of charset
  168. #define FM_BIT_MS_SHELL_DLG 0x08000000 // The apps asked for Ms Shell Dlg
  169. #define FM_BIT_WEIGHT_NOT_FAST_BM 0x10000000 // FindBitmapFont should fail for this weight
  170. #define FM_BIT_DEVICE_ONLY 0x20000000 // Map to device fonts only
  171. #define FM_BIT_FACENAME_MATCHED 0x40000000 // The facename request was found
  172. #define FM_BIT_BASENAME_MATCHED 0x80000000 // The base mm name matched
  173. /**************************************************************************\
  174. *
  175. * FM_BIT_PIXEL_COORD
  176. *
  177. * If set then the incomming logical font has heigths and
  178. * widths in pixel coordinates. This usually happens when
  179. * the logical font corresponds to a stock font.
  180. *
  181. * FM_BIT_NO_MAX_HEIGHT
  182. *
  183. * This should be read as "no maximum height penalty"
  184. * If this bit is set then this font face cannot be rejected because the
  185. * maximal font height penalty is exceeded.
  186. *
  187. * FM_BIT_GM_COMPATIBLE
  188. *
  189. * If set, then the mapping of fonts must be compatible with Win 3.1
  190. *
  191. * FM_BIT_SYSTEM_REQUEST
  192. *
  193. * If set then the incomming logical font corresponds to the system font.
  194. *
  195. * FM_BIT_SYSTEM_FONT
  196. *
  197. * If set, then the current physical font under consideration is the
  198. * system font. This bit applies to the current physical font only.
  199. *
  200. * FM_BIT_PROOF_QUALITY
  201. *
  202. * If set then the incomming logical font has lfQuality = PROOF_QUALITY.
  203. * This means that no bitmap fonts can be scaled.
  204. *
  205. * FM_BIT_DISABLE_TT_NAMES
  206. *
  207. * The bGetFaceName method implements the Win3.1 short circuit mapper
  208. * and substitutes a facename based on character set, size, and
  209. * family. Setting this flag prevents the method from substituting
  210. * a TrueType name (necessary when we already have a TT face but may
  211. * substitute a small bitmap font--if no appropriate bitmap font is
  212. * found, we want to keep the old facename rather than change to a
  213. * DIFFERENT TrueType font).
  214. *
  215. * FM_BIT_EQUIV_NAME
  216. *
  217. * If set, then the mapper is searching through a hash bucket that
  218. * represents a font family in a device font family equivalence
  219. * class. Another way of stating this is that the bucket represents
  220. * and aliased device font name and is not really the base name
  221. * (base name meaning the name of the non-aliased device font).
  222. * A font that is mapped to an aliased name should not be regarded
  223. * as an exact match, so the mapper will impose a penalty if this bit
  224. * is set.
  225. *
  226. \**************************************************************************/
  227. /***************************************************************************
  228. * These flags are used by bGetNtoD_Win31
  229. ***************************************************************************/
  230. #define ND_IGNORE_ESC_AND_ORIENT 0x00000001 // Ingore the lfEscapment and lfOrientation
  231. #define ND_IGNORE_MAP_MODE 0x00000002 // Ignore the map mode
  232. #define FM_ALLOWED_OPTIONS (FM_BIT_PIXEL_COORD)
  233. #define ORIENTATION_90_DEG 900
  234. #define FM_REJECT (ULONG) (ULONG_MAX - 1)
  235. #define FM_FIXED_PITCH_REQUEST_FAILURE_FACTOR 0x20
  236. #define FM_VARIABLE_PITCH_REQUEST_FAILURE_FACTOR 0x1
  237. #define FM_PHYS_FONT_TOO_LARGE_FACTOR 4
  238. #define FM_EMERGENCY_DEFAULT_HEIGHT 24
  239. #define FM_DEVICE_FONTS_ARE_BETTER_BELOW_THIS_SIZE 50
  240. #define FM_SMALLFONTS_BETTER_BELOW_THIS_HEIGHT 12
  241. #define FM_SMALLFONTS_BETTER_BELOW_THIS_EMHEIGHT 10
  242. #define FM_SMALL_FONT_EMBOLDEN_EXCEPTION_EM 9
  243. #define FM_SMALL_FONT_EMBOLDEN_EXCEPTION 11
  244. #define FM_SMALLTT_BETTER_BELOW_THIS_HEIGHT 2
  245. // MM flags
  246. #define FLMM_DV_FROM_NAME 0x00000001
  247. /*********************************Class************************************\
  248. * class MAPPER *
  249. * *
  250. * A class to map fonts for GDI *
  251. * *
  252. * Public Interface: *
  253. * *
  254. * History: *
  255. * Tue 10-Dec-1991 08:36:52 by Kirk Olynyk [kirko] *
  256. * Wrote it. *
  257. \**************************************************************************/
  258. class MAPPER
  259. {
  260. friend PFE *ppfeGetAMatch
  261. (
  262. XDCOBJ& dco ,
  263. ENUMLOGFONTEXDVW *pelfwWishSrc ,
  264. const WCHAR * pwszFaceName ,
  265. ULONG ulMaxPenalty ,
  266. FLONG fl ,
  267. FLONG *pflSim ,
  268. POINTL *pptlSim ,
  269. FLONG *pflAboutMatch,
  270. BOOL bIndexFont_
  271. );
  272. private:
  273. XDCOBJ *pdco; // gives access to DC
  274. const ENUMLOGFONTEXDVW *pelfwWish; // defines wish font in world coordinates
  275. const WCHAR * pwszFaceName;
  276. WCHAR awcBaseName[LF_FACESIZE]; // name of the base mm instance
  277. FLONG flMM; // mm flags
  278. DESIGNVECTOR dvWish; // extracted from pwszFaceName
  279. LONG lDevWishHeight; // wish height in device pixels
  280. LONG lDevWishWidth; // wish width in device pixels
  281. LONG lWishWeight; // wish weight
  282. LONG iOrientationDevice;
  283. // wish angle in device
  284. // space in 10'ths of degrees
  285. ULONG ulMaxPenalty; // max penalty allowed
  286. ULONG ulPenaltyTotal; // Total penalty accum for phys font
  287. FLONG flSimulations; // simulations for current phys font
  288. POINTL ptlSimulations; // destination to pl
  289. PFE *ppfeBest; // best guess so far
  290. ULONG ulBestTime;
  291. FLONG *pflSimBest; // best guess so far
  292. POINTL *pptlSimBest; // best guess so far
  293. FLONG *pflAboutMatch;
  294. LONG lEmHeightPhys; // em-height of phys font in device units
  295. ULONG ulLogPixelsX;
  296. ULONG ulLogPixelsY;
  297. FLONG fl; // status bit field
  298. IFIOBJ ifio;
  299. const IFIMETRICS *pifi; // pointer to IFIMETRICS of phys font
  300. BOOL bIndexFont; // make sure the index font
  301. BYTE jMapCharSet; // the charset value from logfont or from font sub table
  302. PFE *ppfeMMInst; // nonnull if there is another mm instance which
  303. // matches logfont exactly except for dv
  304. // private in-line methods
  305. BOOL MAPPER::bCalculateWishCell();
  306. BOOL MAPPER::bGetFaceName();
  307. public:
  308. static PDWORD SignatureTable; // base of the signature table
  309. static PWCHAR FaceNameTable; // base of the face name table
  310. static BYTE DefaultCharset; // default charset is equivilent to this
  311. // public in-line methods
  312. // we are resetting charset in the mapper if we are going to use the alternate
  313. // values of family name and charset
  314. // specified in [font substitutes] section of win.ini
  315. VOID vResetCharSet(BYTE jCharSet) {jMapCharSet = jCharSet;}
  316. BOOL MAPPER::bFindBitmapFont(PWSZ pwszFindFace);
  317. //
  318. // BOOL MAPPER::bNoMatch
  319. //
  320. // The current font will NOT BE A MATCH to the request if
  321. // 1) the current penalty is greater than the lowest (best)
  322. // match found so far; OR
  323. // 2) the current penalty is equal to the lowest penalty
  324. // the current font was loaded after the best font so far.
  325. // The early bird wins the tie breaker.
  326. //
  327. BOOL bNoMatch(PFE *ppfeNew)
  328. {
  329. // default is no match
  330. BOOL b = 1;
  331. if (ulPenaltyTotal < ulMaxPenalty)
  332. {
  333. b = 0;
  334. }
  335. else if (ulPenaltyTotal == ulMaxPenalty)
  336. {
  337. // time stamps are used as tie breakers for engine fonts only
  338. // in that case the font that is loaded first wins
  339. if (!(fl & (FM_BIT_DEVICE_FONT | FM_BIT_BEST_IS_DEVICE)))
  340. {
  341. if (ppfeNew->ulTimeStamp < ulBestTime)
  342. {
  343. b = 0;
  344. }
  345. }
  346. }
  347. return(b);
  348. }
  349. PFE *ppfeRet()
  350. {
  351. return(ppfeBest);
  352. }
  353. BOOL bDeviceOnly()
  354. {
  355. return( fl & FM_BIT_DEVICE_ONLY );
  356. }
  357. VOID vAttemptDeviceMatch();
  358. BOOL MAPPER::bValid()
  359. {
  360. return(fl & FM_BIT_STILL_ALIVE);
  361. }
  362. BOOL MAPPER::bDeviceFontsExist()
  363. {
  364. return(fl & FM_BIT_DEVICE_HAS_FONTS);
  365. }
  366. VOID MAPPER::vDeviceFonts()
  367. {
  368. fl |= FM_BIT_DEVICE_FONT;
  369. }
  370. VOID MAPPER::vSetBest(PFE *ppfe_, BOOL bDeviceFont, BYTE jCharSet)
  371. {
  372. *pflSimBest = flSimulations;
  373. *pptlSimBest = ptlSimulations;
  374. // win95 functionality: we store charset of the font chosen by the
  375. // mapper's jMapCharSet function into upper byte of the flags.
  376. // This is little bit of a hack, but that is ok.
  377. *pflAboutMatch = (*pflAboutMatch & 0x00ffffff) | (((FLONG)jCharSet) << 24);
  378. ppfeBest = ppfe_;
  379. if (bDeviceFont)
  380. {
  381. fl |= FM_BIT_BEST_IS_DEVICE;
  382. }
  383. else
  384. {
  385. ulBestTime = ppfe_->ulTimeStamp;
  386. fl &= ~FM_BIT_BEST_IS_DEVICE;
  387. }
  388. }
  389. VOID MAPPER::vNotDeviceFonts()
  390. {
  391. fl &= ~FM_BIT_DEVICE_FONT;
  392. }
  393. VOID vReset(ULONG ul_ = 0xFFFFFFFE)
  394. {
  395. *pflAboutMatch = 0;
  396. ppfeBest = (PFE*) NULL;
  397. ulBestTime = ULONG_MAX;
  398. *pflSimBest = 0;
  399. pptlSimBest->x = 1;
  400. pptlSimBest->y = 1;
  401. ulMaxPenalty = ul_;
  402. }
  403. BOOL MAPPER::bCalled_bGetFaceName()
  404. {
  405. return(fl & FM_BIT_CALLED_BGETFACENAME);
  406. }
  407. BOOL MAPPER::bCalcOrientation();
  408. VOID MAPPER::vAcceptDiffCharset()
  409. {
  410. fl |= FM_BIT_CHARSET_ACCEPT;
  411. }
  412. //
  413. // public out of line methods
  414. //
  415. MAPPER
  416. (
  417. XDCOBJ *pdcoSrc, // current DC
  418. FLONG *pflSim_,
  419. POINTL *pptlSim_,
  420. FLONG *pflAboutMatch_,
  421. const ENUMLOGFONTEXDVW *pelfwWishSrc, // wish list in World Coordinates
  422. const WCHAR * pwszFaceName,
  423. ULONG ulMaxPenaltySrc, // pruning criteria
  424. BOOL bIndexFont_,
  425. FLONG flOptions // Mapping options
  426. );
  427. int MAPPER::bNearMatch(PFEOBJ &pfeo, BYTE * pjCharSet, BOOL bEmergency = FALSE);
  428. BOOL bFoundExactMatch(FONTHASH **);
  429. BOOL bFoundForcedMatch(PUNIVERSAL_FONT_ID pufi );
  430. VOID vEmergency();
  431. PFE * ppfeSynthesizeAMatch (FLONG *pflSim, FLONG *pflAboutMatch, POINTL *pptlSim);
  432. };
  433. #define LOGFONT_PITCH_SET (DEFAULT_PITCH | FIXED_PITCH | VARIABLE_PITCH)
  434. #define FF_SET (FF_DONTCARE | FF_ROMAN | FF_SWISS | FF_MODERN | FF_SCRIPT | FF_DECORATIVE)
  435. /**************************************************************************\
  436. * Debugging Macros for ppfeGetAMatch()
  437. *
  438. *
  439. \**************************************************************************/
  440. #if DBG
  441. #define PPFEGETAMATCH_DEBUG_RETURN(xxx) \
  442. ASSERTGDI( \
  443. xxx,"GDISRV!ppfeGetAMatch" \
  444. " -- could not find a match" \
  445. ); \
  446. if (gflFontDebug & DEBUG_MAPPER) \
  447. { \
  448. PSZ pszT; \
  449. PFEOBJ pfeoT(xxx); \
  450. IFIOBJ ifioT(pfeoT.pifi()); \
  451. switch (*pflSim & (FO_SIM_BOLD | FO_SIM_ITALIC)) \
  452. { \
  453. case 0: pszT = "NONE"; break; \
  454. case FO_SIM_BOLD: pszT = "BOLD"; break; \
  455. case FO_SIM_ITALIC: pszT = "ITALIC"; break; \
  456. default: pszT = "BOLD ITALIC"; break; \
  457. } \
  458. DbgPrint( \
  459. "\n\n RETURNING \"%ws\" (%d) pifi = %-#8lx\n\n\t\tSIM = %s\t[%d,%d]\n\n\n\n", \
  460. ifioT.pwszFaceName(),ifioT.lfHeight(),pfeoT.pifi(), pszT,pptlSim->x,pptlSim->y); \
  461. } \
  462. return((xxx))
  463. #define PPFEGETAMATCH_DEBUG_MACRO_1 \
  464. if (gflFontDebug & DEBUG_MAPPER) \
  465. { \
  466. { \
  467. DbgPrint( \
  468. "\n\nGDISRV!ppfeGetaMatch -- " \
  469. "the requested font is described by\n\n" \
  470. ); \
  471. DbgPrint(" FaceName = %ws\n",pwszFaceName); \
  472. vPrintENUMLOGFONTEXDVW( \
  473. (ENUMLOGFONTEXDVW *) pelfwWishSrc); \
  474. } \
  475. DbgPrint("\n\n"); \
  476. DbgBreakPoint(); \
  477. }
  478. #else
  479. #define PPFEGETAMATCH_DEBUG_RETURN(xxx) return((xxx))
  480. #define PPFEGETAMATCH_DEBUG_MACRO_1
  481. #endif
  482. #if DBG
  483. #define DUMP_CHOSEN_FONT(pfeo) \
  484. if (gflFontDebug & DEBUG_MAPPER) \
  485. { \
  486. DbgPrint \
  487. ( \
  488. "YEAH .. ACCEPTING ppfe = %-#8lx \"%ws\" [%d,%d] {%x} ***\n", \
  489. pfeo.ppfeGet(), \
  490. pfeo.pwszFaceName(), \
  491. this->ptlSimulations.x, \
  492. this->ptlSimulations.y, \
  493. this->ulPenaltyTotal \
  494. ); \
  495. DbgPrint("\n"); \
  496. }
  497. #define DUMP_REJECTED_FONT(pfeo) \
  498. if (gflFontDebug & DEBUG_MAPPER) \
  499. { \
  500. DbgPrint \
  501. ( \
  502. "BOO ... REJECTING ppfe = %-#8lx \"%ws\" [%d,%d] {%x} ***\n\n", \
  503. pfeo.ppfeGet(), \
  504. pfeo.pwszFaceName(), \
  505. this->ptlSimulations.x, \
  506. this->ptlSimulations.y, \
  507. this->ulPenaltyTotal \
  508. ); \
  509. }
  510. #else
  511. #define DUMP_CHOSEN_FONT(pfeo) {}
  512. #define DUMP_REJECTED_FONT(pfeo) {}
  513. #endif
  514. #if DBG
  515. #define CHECKPRINT(xx,yy) if ((gflFontDebug & DEBUG_MAPPER) && yy > 0) DbgPrint(" msCheck%s = %x\n", (xx), (yy))
  516. #define MSBREAKPOINT(psz) if (gflFontDebug & DEBUG_MAPPER_MSCHECK) RIP(psz)
  517. #else
  518. #define CHECKPRINT(x,y)
  519. #define MSBREAKPOINT(psz)
  520. #endif
  521. #define MULDIV(a,b,c) ((c) == 1 ? ((a) * (b)) : ((((a)*(b)) + ((c)/2)) / (c)))
  522. // MULDIV works for small positive #'s only
  523. //
  524. // This structure maintains all state during the calls to the enumeration routine
  525. // used to read the default font face names from the registry.
  526. //
  527. typedef struct tagREGREAD {
  528. UINT NumEntries; //Num entries read so far
  529. UINT TableSize; //Total size of face name string
  530. PDWORD NextValue; //Pointer to next font "signature"
  531. PWCHAR FaceNameBase; //Pointer to base of the face name buffer
  532. PWCHAR NextFaceName; //Pointer to next free entry in face name buffer
  533. BYTE DefaultCharset; //The default charset is equivilent to this
  534. } REGREADER, *PREGREADER;
  535. //
  536. // These bits are used to create a font "signature" based on charset, family,
  537. // pitch, etc. This signature is then compared against that of default face
  538. // names in the registry to find which default face name to use for the
  539. // requested font.
  540. //
  541. #define DFS_FIXED_PITCH 0x00008000 // fixed pitch is requested
  542. #define DFS_FF_ROMAN 0x00004000 // roman font family is requested
  543. #define DFS_VERTICAL 0x00002000 // a vertical face name is requested
  544. #define DFS_BITMAP_A 0x00001000 // looking for a bitmap font
  545. #define DFS_BITMAP_B 0x00000800 // second choice face name for bitmap font
  546. // win95 function used in mapping and elsewhere
  547. BYTE jMapCharset(BYTE lfCharSet, PFEOBJ &pfeo);
  548. extern "C" ULONG ulCharsetToCodePage(UINT uiCharSet);