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.

687 lines
15 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: ifiobj.hxx *
  3. * *
  4. * Created: 14-Apr-1992 13:09:20 *
  5. * Author: Gilman Wong [gilmanw] *
  6. * *
  7. * Copyright (c) 1992-1999 Microsoft Corporation *
  8. \**************************************************************************/
  9. #define INCLUDED_IFIOBJ_HXX
  10. //
  11. // The following 3 macros are needed in both ifiobj.hxx and rfntobj.hxx
  12. //
  13. #define BCONTINUOUSSCALING(x) \
  14. ((x) & ( \
  15. FM_INFO_ARB_XFORMS \
  16. | FM_INFO_ISOTROPIC_SCALING_ONLY \
  17. | FM_INFO_ANISOTROPIC_SCALING_ONLY))
  18. #define BARBXFORMS(x) ((x) & FM_INFO_ARB_XFORMS)
  19. #define BRETURNSOUTLINES(x) ((x) & FM_INFO_RETURNS_OUTLINES)
  20. /*********************************Class************************************\
  21. * class IFIOBJ *
  22. * *
  23. * Public Interface: *
  24. * *
  25. * History: *
  26. * Wed 16-Dec-1992 16:44:56 -by- Charles Whitmer [chuckwh] *
  27. * Cleaned out unnecesssary methods. *
  28. * *
  29. * Fri 30-Aug-1991 21:27:12 by Kirk Olynyk [kirko] *
  30. * Wrote it. *
  31. \**************************************************************************/
  32. class IFIOBJ
  33. {
  34. public:
  35. const IFIMETRICS *pifi;
  36. POINTL ptlPrinterHackDiesAfterTheBeta;
  37. IFIOBJ()
  38. {
  39. pifi = (IFIMETRICS*) NULL;
  40. }
  41. IFIOBJ(const IFIMETRICS *pifi_)
  42. {
  43. pifi = pifi_;
  44. }
  45. ~IFIOBJ()
  46. {
  47. }
  48. VOID vSet(const IFIMETRICS *pifi_)
  49. {
  50. pifi = pifi_;
  51. }
  52. // are all the DBCS characters fixed pitch?
  53. BOOL bDBCSFixedPitch()
  54. {
  55. return(pifi->flInfo & FM_INFO_DBCS_FIXED_PITCH);
  56. }
  57. // affected by simulation
  58. FWORD fwdMaxCharInc()
  59. {
  60. return (pifi->fwdMaxCharInc);
  61. }
  62. //
  63. // affected by simulation
  64. //
  65. FWORD fwdAveCharWidth()
  66. {
  67. return(pifi->fwdAveCharWidth);
  68. }
  69. //
  70. // affected by simulation
  71. //
  72. POINTL* pptlCaret()
  73. {
  74. return((POINTL *) &(pifi->ptlCaret));
  75. }
  76. //
  77. // affected by simulation
  78. //
  79. LONG lfWidth()
  80. {
  81. return((LONG) (pifi->fwdAveCharWidth));
  82. }
  83. //
  84. // affected by simulation
  85. //
  86. LONG lfWeight()
  87. {
  88. return((LONG) (pifi->usWinWeight));
  89. }
  90. //
  91. // affected by simulation
  92. //
  93. FSHORT fsSelection()
  94. {
  95. return(pifi->fsSelection);
  96. }
  97. FWORD fwdLowestPPEm()
  98. {
  99. return(pifi->fwdLowestPPEm);
  100. }
  101. BOOL bSimulateAnything()
  102. {
  103. return (pifi->dpFontSim!=0);
  104. }
  105. LONG lWeight(PVOID pv)
  106. {
  107. return(pv ? ((FONTDIFF*)pv)->usWinWeight : pifi->usWinWeight);
  108. }
  109. DWORD TypeOneID()
  110. {
  111. if (pifi->cjIfiExtra > offsetof(IFIEXTRA,ulIdentifier))
  112. {
  113. return (((IFIEXTRA *)(pifi + 1))->ulIdentifier);
  114. }
  115. else
  116. {
  117. return 0;
  118. }
  119. }
  120. PVOID pvSimBold()
  121. {
  122. PVOID pvR = 0;
  123. if (pifi->dpFontSim)
  124. {
  125. FONTSIM *pfs = (FONTSIM*) ((BYTE*)pifi + pifi->dpFontSim);
  126. register PTRDIFF dp =
  127. (pifi->fsSelection & FM_SEL_ITALIC) ?
  128. pfs->dpBoldItalic : pfs->dpBold;
  129. if (dp)
  130. {
  131. pvR = (PVOID) ((BYTE*)pfs + dp);
  132. }
  133. }
  134. return(pvR);
  135. }
  136. BOOL bSimItalic()
  137. {
  138. BOOL bRet = FALSE;
  139. if (pifi->dpFontSim)
  140. {
  141. FONTSIM *pfs = (FONTSIM*) ((BYTE*)pifi + pifi->dpFontSim);
  142. bRet =
  143. (pifi->fsSelection & FM_SEL_BOLD) ?
  144. (BOOL) pfs->dpBoldItalic : (BOOL) pfs->dpItalic;
  145. }
  146. return(bRet);
  147. }
  148. BOOL bSimulateBoldItalic()
  149. {
  150. register BOOL bRet = FALSE;
  151. if (pifi->dpFontSim)
  152. {
  153. if (((FONTSIM*)(((BYTE*)pifi) + pifi->dpFontSim))->dpBoldItalic)
  154. {
  155. bRet = TRUE;
  156. }
  157. }
  158. return(bRet);
  159. }
  160. BOOL bSimulateBothItalics()
  161. {
  162. return(
  163. pifi->dpFontSim &&
  164. (((FONTSIM*)(((BYTE*)pifi) + pifi->dpFontSim))->dpItalic) &&
  165. (((FONTSIM*)(((BYTE*)pifi) + pifi->dpFontSim))->dpBoldItalic)
  166. );
  167. }
  168. PWSZ pwszFamilyName()
  169. {
  170. return((PWSZ)(((BYTE*) pifi) + pifi->dpwszFamilyName));
  171. }
  172. PWSZ pwszStyleName()
  173. {
  174. return((PWSZ)(((BYTE*) pifi) + pifi->dpwszStyleName));
  175. }
  176. PWSZ pwszFaceName()
  177. {
  178. return((PWSZ)(((BYTE*) pifi) + pifi->dpwszFaceName));
  179. }
  180. PWSZ pwszUniqueName()
  181. {
  182. return((PWSZ)(((BYTE*) pifi) + pifi->dpwszUniqueName));
  183. }
  184. BOOL bValid()
  185. {
  186. ASSERTGDI(pifi,"bogus IFIMETRICS pointer\n");
  187. return(TRUE);
  188. }
  189. LONG lfHeight()
  190. {
  191. return((LONG) pifi->fwdWinAscender + (LONG) pifi->fwdWinDescender);
  192. }
  193. LONG lfOrientation();
  194. BYTE lfPitchAndFamily()
  195. {
  196. return(pifi->jWinPitchAndFamily);
  197. }
  198. //
  199. // tmPitchAndFamily - This is what Win 3.1 does
  200. // "Ours is not to question why ..."
  201. //
  202. BYTE tmPitchAndFamily()
  203. {
  204. BYTE j = pifi->jWinPitchAndFamily & 0xf0;
  205. j |= !bFixedPitch() ? TMPF_FIXED_PITCH : 0;
  206. j |= bTrueType() ? (TMPF_TRUETYPE | TMPF_VECTOR) : 0;
  207. j |= bStroke() ? TMPF_VECTOR : 0;
  208. return(j);
  209. }
  210. //
  211. // ptlBaseline -- contains a hack to temporarily prop up bad printer metrics until after beta
  212. //
  213. POINTL* pptlBaseline()
  214. {
  215. ptlPrinterHackDiesAfterTheBeta = pifi->ptlBaseline;
  216. if (!ptlPrinterHackDiesAfterTheBeta.x && !ptlPrinterHackDiesAfterTheBeta.y)
  217. {
  218. ptlPrinterHackDiesAfterTheBeta.x = 1;
  219. }
  220. return(&ptlPrinterHackDiesAfterTheBeta);
  221. }
  222. LONG lfEscapement()
  223. {
  224. return(lfOrientation());
  225. }
  226. FSHORT fsType()
  227. {
  228. return(pifi->fsType);
  229. }
  230. BYTE lfItalic()
  231. {
  232. return((BYTE) ((FM_SEL_ITALIC & pifi->fsSelection)?255:0));
  233. }
  234. BYTE lfUnderline()
  235. {
  236. return((BYTE) (FM_SEL_UNDERSCORE & pifi->fsSelection));
  237. }
  238. BYTE lfStrikeOut()
  239. {
  240. return((BYTE) (FM_SEL_STRIKEOUT & pifi->fsSelection));
  241. }
  242. BYTE lfCharSet()
  243. {
  244. return(pifi->jWinCharSet);
  245. }
  246. BOOL bTrueType()
  247. {
  248. return(pifi->flInfo & FM_INFO_TECH_TRUETYPE);
  249. }
  250. BOOL bBitmap()
  251. {
  252. return(pifi->flInfo & FM_INFO_TECH_BITMAP);
  253. }
  254. BOOL bStroke()
  255. {
  256. return(pifi->flInfo & FM_INFO_TECH_STROKE);
  257. }
  258. BOOL bGhostFont()
  259. {
  260. return(pifi->flInfo & FM_INFO_DO_NOT_ENUMERATE);
  261. }
  262. BOOL bType1()
  263. {
  264. return(pifi->flInfo & FM_INFO_TECH_TYPE1);
  265. }
  266. BOOL bIGNORE_TC_RA_ABLE()
  267. {
  268. return(pifi->flInfo & FM_INFO_IGNORE_TC_RA_ABLE);
  269. }
  270. BYTE lfOutPrecision()
  271. {
  272. if (pifi->flInfo & FM_INFO_TECH_TRUETYPE)
  273. {
  274. return(OUT_OUTLINE_PRECIS);
  275. }
  276. else if (pifi->flInfo & FM_INFO_TECH_BITMAP)
  277. {
  278. return(OUT_RASTER_PRECIS);
  279. }
  280. else if (pifi->flInfo & FM_INFO_TECH_STROKE)
  281. {
  282. return(OUT_STROKE_PRECIS);
  283. }
  284. else if (pifi->flInfo & FM_INFO_TECH_OUTLINE_NOT_TRUETYPE)
  285. {
  286. return(OUT_OUTLINE_PRECIS);
  287. }
  288. else
  289. return(OUT_DEFAULT_PRECIS);
  290. }
  291. BYTE lfClipPrecision()
  292. {
  293. return(CLIP_DEFAULT_PRECIS);
  294. }
  295. BYTE lfQuality()
  296. {
  297. return(PROOF_QUALITY);
  298. }
  299. BYTE lfOutPrecisionEnum()
  300. {
  301. // [Windows 3.1 compatibility]
  302. if (pifi->flInfo & FM_INFO_TECH_TRUETYPE)
  303. {
  304. return(OUT_STROKE_PRECIS);
  305. }
  306. else if (pifi->flInfo & FM_INFO_TECH_BITMAP)
  307. {
  308. return(OUT_STRING_PRECIS);
  309. }
  310. else if (pifi->flInfo & FM_INFO_TECH_STROKE)
  311. {
  312. return(OUT_STROKE_PRECIS);
  313. }
  314. else if (pifi->flInfo & FM_INFO_TECH_OUTLINE_NOT_TRUETYPE)
  315. {
  316. return(OUT_STROKE_PRECIS);
  317. }
  318. else
  319. return(OUT_DEFAULT_PRECIS);
  320. }
  321. BYTE lfClipPrecisionEnum()
  322. {
  323. // [Windows 3.1 compatibility]
  324. // Win 3.1 always returns Stroke Precision for enumeration.
  325. return(CLIP_STROKE_PRECIS);
  326. }
  327. BYTE lfQualityEnum()
  328. {
  329. // [Windows 3.1 compatibility]
  330. // Win 3.1 always returns Draft Quality for enumeration.
  331. return(DRAFT_QUALITY);
  332. }
  333. PANOSE *pPanose()
  334. {
  335. return((PANOSE *) &pifi->panose);
  336. }
  337. ULONG ulCulture()
  338. {
  339. return(pifi->ulPanoseCulture);
  340. }
  341. WORD wCharBias()
  342. {
  343. return((WORD) (pifi->lCharBias));
  344. }
  345. BYTE chFirstChar()
  346. {
  347. return(pifi->chFirstChar);
  348. }
  349. BYTE chLastChar()
  350. {
  351. return(pifi->chLastChar);
  352. }
  353. BYTE chDefaultChar()
  354. {
  355. return(pifi->chDefaultChar);
  356. }
  357. BYTE chBreakChar()
  358. {
  359. return(pifi->chBreakChar);
  360. }
  361. WCHAR wcFirstChar()
  362. {
  363. return(pifi->wcFirstChar);
  364. }
  365. WCHAR wcLastChar()
  366. {
  367. return(pifi->wcLastChar);
  368. }
  369. WCHAR wcBreakChar()
  370. {
  371. return(pifi->wcBreakChar);
  372. }
  373. WCHAR wcDefaultChar()
  374. {
  375. return(pifi->wcDefaultChar);
  376. }
  377. BOOL bFixedPitch()
  378. {
  379. return(pifi->flInfo & (FM_INFO_CONSTANT_WIDTH | FM_INFO_OPTICALLY_FIXED_PITCH));
  380. }
  381. BYTE* achVendId()
  382. {
  383. return((BYTE *) pifi->achVendId);
  384. }
  385. POINTL* pptlAspect()
  386. {
  387. return((POINTL *) &pifi->ptlAspect);
  388. }
  389. BOOL bRightHandAscender()
  390. {
  391. return(pifi->flInfo & FM_INFO_RIGHT_HANDED);
  392. }
  393. LONG lItalicAngle()
  394. {
  395. return(pifi->lItalicAngle);
  396. }
  397. FWORD fwdUnitsPerEm()
  398. {
  399. return(pifi->fwdUnitsPerEm);
  400. }
  401. BOOL bIsotropicScalingOnly()
  402. {
  403. return(pifi->flInfo & FM_INFO_ISOTROPIC_SCALING_ONLY);
  404. }
  405. BOOL bAnisotropicScalingOnly()
  406. {
  407. return(pifi->flInfo & FM_INFO_ANISOTROPIC_SCALING_ONLY);
  408. }
  409. #ifdef FE_SB
  410. BOOL b90DegreeRotations()
  411. {
  412. return(pifi->flInfo & FM_INFO_90DEGREE_ROTATIONS);
  413. }
  414. #endif
  415. BOOL bArbXforms()
  416. {
  417. return(BARBXFORMS(pifi->flInfo));
  418. }
  419. BOOL bReturnsOutlines()
  420. {
  421. return(BRETURNSOUTLINES(pifi->flInfo));
  422. }
  423. BOOL bContinuousScaling()
  424. {
  425. return(BCONTINUOUSSCALING(pifi->flInfo));
  426. }
  427. BOOL bIntegralScaling()
  428. {
  429. return(pifi->flInfo & FM_INFO_INTEGRAL_SCALING);
  430. }
  431. FWORD fwdInternalLeading()
  432. {
  433. return(pifi->fwdWinAscender + pifi->fwdWinDescender - pifi->fwdUnitsPerEm);
  434. }
  435. FWORD fwdExternalLeading()
  436. {
  437. register FWORD fwd;
  438. fwd = pifi->fwdMacLineGap
  439. + pifi->fwdMacAscender
  440. - pifi->fwdMacDescender
  441. - pifi->fwdWinAscender
  442. - pifi->fwdWinDescender;
  443. return((fwd > 0) ? fwd : 0);
  444. }
  445. FWORD fwdWinAscender()
  446. {
  447. return(pifi->fwdWinAscender);
  448. }
  449. FWORD fwdWinDescender()
  450. {
  451. return(pifi->fwdWinDescender);
  452. }
  453. FWORD fwdTypoAscender()
  454. {
  455. return(pifi->fwdTypoAscender);
  456. }
  457. FWORD fwdTypoDescender()
  458. {
  459. return(pifi->fwdTypoDescender);
  460. }
  461. FWORD fwdTypoLineGap()
  462. {
  463. return(pifi->fwdTypoLineGap);
  464. }
  465. FWORD fwdMacAscender()
  466. {
  467. return(pifi->fwdMacAscender);
  468. }
  469. FWORD fwdMacDescender()
  470. {
  471. return(pifi->fwdMacDescender);
  472. }
  473. FWORD fwdMacLineGap()
  474. {
  475. return(pifi->fwdMacLineGap);
  476. }
  477. int fwdSubscriptXSize()
  478. {
  479. return(pifi->fwdSubscriptXSize);
  480. }
  481. int fwdSubscriptYSize()
  482. {
  483. return(pifi->fwdSubscriptYSize);
  484. }
  485. int fwdSubscriptXOffset()
  486. {
  487. return(pifi->fwdSubscriptXOffset);
  488. }
  489. int fwdSubscriptYOffset()
  490. {
  491. return(pifi->fwdSubscriptYOffset);
  492. }
  493. int fwdSuperscriptXSize()
  494. {
  495. return(pifi->fwdSuperscriptXSize);
  496. }
  497. int fwdSuperscriptYSize()
  498. {
  499. return(pifi->fwdSuperscriptYSize);
  500. }
  501. int fwdSuperscriptXOffset()
  502. {
  503. return(pifi->fwdSuperscriptXOffset);
  504. }
  505. int fwdSuperscriptYOffset()
  506. {
  507. return(pifi->fwdSuperscriptYOffset);
  508. }
  509. int fwdUnderscoreSize()
  510. {
  511. return(pifi->fwdUnderscoreSize);
  512. }
  513. int fwdUnderscorePosition()
  514. {
  515. return(pifi->fwdUnderscorePosition);
  516. }
  517. int fwdStrikeoutSize()
  518. {
  519. return(pifi->fwdStrikeoutSize);
  520. }
  521. int fwdStrikeoutPosition()
  522. {
  523. return(pifi->fwdStrikeoutPosition);
  524. }
  525. RECTL* prclFontBox()
  526. {
  527. return((RECTL *) &(pifi->rclFontBox));
  528. }
  529. FWORD fwdXHeight()
  530. {
  531. return(pifi->fwdXHeight);
  532. }
  533. FWORD fwdCapHeight()
  534. {
  535. return(pifi->fwdCapHeight);
  536. }
  537. BOOL bBold()
  538. {
  539. return(fsSelection() & FM_SEL_BOLD);
  540. }
  541. BOOL bItalic()
  542. {
  543. return(fsSelection() & FM_SEL_ITALIC);
  544. }
  545. BOOL bNonSimItalic()
  546. {
  547. return(pifi->fsSelection & FM_SEL_ITALIC);
  548. }
  549. LONG lfNonSimWeight()
  550. {
  551. return((LONG) pifi->usWinWeight);
  552. }
  553. DESIGNVECTOR *pdvDesVect()
  554. {
  555. DESIGNVECTOR *pdv = NULL;
  556. PTRDIFF dpDesVec = 0;
  557. if (pifi->cjIfiExtra > offsetof(IFIEXTRA, dpDesignVector))
  558. {
  559. dpDesVec = ((IFIEXTRA *)(pifi + 1))->dpDesignVector;
  560. if (dpDesVec)
  561. {
  562. pdv = (DESIGNVECTOR *)((BYTE *)pifi + dpDesVec);
  563. }
  564. }
  565. return pdv;
  566. }
  567. };