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.

526 lines
12 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. font.c
  5. Abstract:
  6. Implementation of font related DDI entry points:
  7. DrvQueryFont
  8. DrvQueryFontTree
  9. DrvQueryFontData
  10. DrvGetGlyphMode
  11. DrvFontManagement
  12. DrvQueryAdvanceWidths
  13. Environment:
  14. Windows NT Unidrv driver
  15. Revision History:
  16. 10/14/96 -amandan-
  17. Initial framework.
  18. 03/31/97 -zhanw-
  19. Added OEM customization support
  20. --*/
  21. #include "unidrv.h"
  22. PIFIMETRICS
  23. DrvQueryFont(
  24. DHPDEV dhpdev,
  25. ULONG_PTR iFile,
  26. ULONG iFace,
  27. ULONG_PTR *pid
  28. )
  29. /*++
  30. Routine Description:
  31. Implementation of DDI entry point DrvQueryFont.
  32. Please refer to DDK documentation for more details.
  33. Arguments:
  34. dhpdev - Driver device handle
  35. iFile - Identifies the driver font file
  36. iFace - One-based index of the driver font
  37. pid - Points to a LONG variable for returning an identifier
  38. which GDI will pass to DrvFree
  39. Return Value:
  40. Pointer to an IFIMETRICS structure for the given font
  41. NULL if there is an error
  42. --*/
  43. {
  44. PDEV *pPDev = (PDEV *)dhpdev;
  45. PFMPROCS pFontProcs;
  46. UNREFERENCED_PARAMETER(iFile);
  47. VERBOSE(("Entering DrvQueryFont...\n"));
  48. ASSERT_VALID_PDEV(pPDev);
  49. //
  50. // Handle OEM hooks
  51. //
  52. HANDLE_OEMHOOKS(pPDev,
  53. EP_OEMQueryFont,
  54. PFN_OEMQueryFont,
  55. PIFIMETRICS,
  56. (dhpdev,
  57. iFile,
  58. iFace,
  59. pid));
  60. HANDLE_VECTORHOOKS(pPDev,
  61. EP_OEMQueryFont,
  62. VMQueryFont,
  63. PIFIMETRICS,
  64. (dhpdev,
  65. iFile,
  66. iFace,
  67. pid));
  68. pFontProcs = (PFMPROCS)(pPDev->pFontProcs);
  69. if (pFontProcs->FMQueryFont == NULL)
  70. return NULL;
  71. else
  72. return (pFontProcs->FMQueryFont(pPDev,
  73. iFile,
  74. iFace,
  75. pid) );
  76. }
  77. PVOID
  78. DrvQueryFontTree(
  79. DHPDEV dhpdev,
  80. ULONG_PTR iFile,
  81. ULONG iFace,
  82. ULONG iMode,
  83. ULONG_PTR *pid
  84. )
  85. /*++
  86. Routine Description:
  87. Implementation of DDI entry point DrvQueryFontTree.
  88. Please refer to DDK documentation for more details.
  89. Arguments:
  90. dhpdev - Driver device handle
  91. iFile - Identifies the driver font file
  92. iFace - One-based index of the driver font
  93. iMode - Specifies the type of information to be provided
  94. pid - Points to a LONG variable for returning an identifier
  95. which GDI will pass to DrvFree
  96. Return Value:
  97. Depends on iMode, NULL if there is an error
  98. --*/
  99. {
  100. PDEV *pPDev = (PDEV *)dhpdev;
  101. PFMPROCS pFontProcs;
  102. VERBOSE(("Entering DrvQueryFontTree...\n"));
  103. ASSERT_VALID_PDEV(pPDev);
  104. //
  105. // Handle OEM hooks
  106. //
  107. HANDLE_OEMHOOKS(pPDev,
  108. EP_OEMQueryFontTree,
  109. PFN_OEMQueryFontTree,
  110. PVOID,
  111. (dhpdev,
  112. iFile,
  113. iFace,
  114. iMode,
  115. pid));
  116. HANDLE_VECTORHOOKS(pPDev,
  117. EP_OEMQueryFontTree,
  118. VMQueryFontTree,
  119. PVOID,
  120. (dhpdev,
  121. iFile,
  122. iFace,
  123. iMode,
  124. pid));
  125. pFontProcs = (PFMPROCS)(pPDev->pFontProcs);
  126. if (pFontProcs->FMQueryFontTree == NULL)
  127. return NULL;
  128. else
  129. return ( pFontProcs->FMQueryFontTree(pPDev,
  130. iFile,
  131. iFace,
  132. iMode,
  133. pid) );
  134. }
  135. LONG
  136. DrvQueryFontData(
  137. DHPDEV dhpdev,
  138. FONTOBJ *pfo,
  139. ULONG iMode,
  140. HGLYPH hg,
  141. GLYPHDATA *pgd,
  142. PVOID pv,
  143. ULONG cjSize
  144. )
  145. /*++
  146. Routine Description:
  147. Implementation of DDI entry point DrvQueryFontData.
  148. Please refer to DDK documentation for more details.
  149. Arguments:
  150. dhpdev - Driver device handle
  151. pfo - Points to a FONTOBJ structure
  152. iMode - Type of information requested
  153. hg - A glyph handle
  154. pgd - Points to a GLYPHDATA structure
  155. pv - Points to output buffer
  156. cjSize - Size of output buffer
  157. Return Value:
  158. Depends on iMode. FD_ERROR if there is an error
  159. --*/
  160. {
  161. PDEV *pPDev = (PDEV *)dhpdev;
  162. PFMPROCS pFontProcs;
  163. VERBOSE(("Entering DrvQueryFontData...\n"));
  164. ASSERT(pfo && VALID_PDEV(pPDev));
  165. //
  166. // Handle OEM hooks
  167. //
  168. HANDLE_OEMHOOKS(pPDev,
  169. EP_OEMQueryFontData,
  170. PFN_OEMQueryFontData,
  171. LONG,
  172. (dhpdev,
  173. pfo,
  174. iMode,
  175. hg,
  176. pgd,
  177. pv,
  178. cjSize));
  179. HANDLE_VECTORHOOKS(pPDev,
  180. EP_OEMQueryFontData,
  181. VMQueryFontData,
  182. LONG,
  183. (dhpdev,
  184. pfo,
  185. iMode,
  186. hg,
  187. pgd,
  188. pv,
  189. cjSize));
  190. pFontProcs = (PFMPROCS)(pPDev->pFontProcs);
  191. if (pFontProcs->FMQueryFontData == NULL)
  192. return FD_ERROR;
  193. else
  194. return (pFontProcs->FMQueryFontData(pPDev,
  195. pfo,
  196. iMode,
  197. hg,
  198. pgd,
  199. pv,
  200. cjSize) );
  201. }
  202. ULONG
  203. DrvFontManagement(
  204. SURFOBJ *pso,
  205. FONTOBJ *pfo,
  206. ULONG iMode,
  207. ULONG cjIn,
  208. PVOID pvIn,
  209. ULONG cjOut,
  210. PVOID pvOut
  211. )
  212. /*++
  213. Routine Description:
  214. Implementation of DDI entry point DrvFontManagement.
  215. Please refer to DDK documentation for more details.
  216. Arguments:
  217. pso - Points to a SURFOBJ structure
  218. pfo - Points to a FONTOBJ structure
  219. iMode - Escape number
  220. cjIn - Size of input buffer
  221. pvIn - Points to input buffer
  222. cjOut - Size of output buffer
  223. pvOut - Points to output buffer
  224. Return Value:
  225. 0x00000001 to 0x7fffffff for success
  226. 0x80000000 to 0xffffffff for failure
  227. 0 if the specified escape number if not supported
  228. --*/
  229. {
  230. PDEV * pPDev;
  231. PFMPROCS pFontProcs;
  232. VERBOSE(("Entering DrvQueryFontManagement...\n"));
  233. //
  234. // pso could be NULL in case of QUERYESCSUPPORT
  235. //
  236. if (iMode == QUERYESCSUPPORT)
  237. {
  238. //
  239. // we don't allow OEM dll to overwrite our font management capability.
  240. // By not call OEM for this escape, we are also enforcing that the OEM
  241. // support the same set of font management escapes as Unidrv does.
  242. //
  243. return ( *((PULONG)pvIn) == GETEXTENDEDTEXTMETRICS ) ? 1 : 0;
  244. }
  245. ASSERT(pso);
  246. pPDev = (PDEV *) pso->dhpdev;
  247. ASSERT_VALID_PDEV(pPDev);
  248. //
  249. // use driver managed surface
  250. //
  251. if (pPDev->pso)
  252. pso = pPDev->pso;
  253. ASSERT(pfo);
  254. //
  255. // Handle OEM hooks
  256. //
  257. HANDLE_OEMHOOKS(pPDev,
  258. EP_OEMFontManagement,
  259. PFN_OEMFontManagement,
  260. ULONG,
  261. (pso,
  262. pfo,
  263. iMode,
  264. cjIn,
  265. pvIn,
  266. cjOut,
  267. pvOut));
  268. HANDLE_VECTORHOOKS(pPDev,
  269. EP_OEMFontManagement,
  270. VMFontManagement,
  271. ULONG,
  272. (pso,
  273. pfo,
  274. iMode,
  275. cjIn,
  276. pvIn,
  277. cjOut,
  278. pvOut));
  279. switch (iMode)
  280. {
  281. case GETEXTENDEDTEXTMETRICS:
  282. {
  283. pFontProcs = (PFMPROCS)(pPDev->pFontProcs);
  284. if (pFontProcs->FMFontManagement == NULL)
  285. return 0;
  286. else
  287. return ( pFontProcs->FMFontManagement(pso,
  288. pfo,
  289. iMode,
  290. cjIn,
  291. pvIn,
  292. cjOut,
  293. pvOut) );
  294. }
  295. default:
  296. return 0;
  297. }
  298. }
  299. BOOL
  300. DrvQueryAdvanceWidths(
  301. DHPDEV dhpdev,
  302. FONTOBJ *pfo,
  303. ULONG iMode,
  304. HGLYPH *phg,
  305. PVOID *pvWidths,
  306. ULONG cGlyphs
  307. )
  308. /*++
  309. Routine Description:
  310. Implementation of DDI entry point DrvQueryAdvanceWidths.
  311. Please refer to DDK documentation for more details.
  312. Arguments:
  313. dhpdev - Driver device handle
  314. pfo - Points to a FONTOBJ structure
  315. iMode - Type of information to be provided
  316. phg - Points to an array of HGLYPHs for which the driver will
  317. provide character advance widths
  318. pvWidths - Points to a buffer for returning width data
  319. cGlyphs - Number of glyphs in the phg array
  320. Return Value:
  321. Depends on iMode
  322. --*/
  323. {
  324. PDEV * pPDev = (PDEV *)dhpdev;
  325. PFMPROCS pFontProcs;
  326. VERBOSE(("Entering DrvQueryAdvanceWidths...\n"));
  327. ASSERT(pfo && VALID_PDEV(pPDev));
  328. //
  329. // Handle OEM hooks
  330. //
  331. HANDLE_OEMHOOKS(pPDev,
  332. EP_OEMQueryAdvanceWidths,
  333. PFN_OEMQueryAdvanceWidths,
  334. BOOL,
  335. (dhpdev,
  336. pfo,
  337. iMode,
  338. phg,
  339. pvWidths,
  340. cGlyphs));
  341. HANDLE_VECTORHOOKS(pPDev,
  342. EP_OEMQueryAdvanceWidths,
  343. VMQueryAdvanceWidths,
  344. BOOL,
  345. (dhpdev,
  346. pfo,
  347. iMode,
  348. phg,
  349. pvWidths,
  350. cGlyphs));
  351. pFontProcs = (PFMPROCS)(pPDev->pFontProcs);
  352. if (pFontProcs->FMQueryAdvanceWidths == NULL)
  353. return FALSE;
  354. else
  355. return ( pFontProcs->FMQueryAdvanceWidths(pPDev,
  356. pfo,
  357. iMode,
  358. phg,
  359. pvWidths,
  360. cGlyphs) );
  361. }
  362. ULONG
  363. DrvGetGlyphMode(
  364. DHPDEV dhpdev,
  365. FONTOBJ *pfo
  366. )
  367. /*++
  368. Routine Description:
  369. Implementation of DDI entry point DrvGetGlyphMode.
  370. Please refer to DDK documentation for more details.
  371. Arguments:
  372. dhpdev - Driver device handle
  373. pfo - Points to a FONTOBJ structure
  374. Return Value:
  375. The glyph mode or FO_GLYPHMODE, which is the default
  376. --*/
  377. {
  378. PDEV * pPDev = (PDEV *)dhpdev;
  379. PFMPROCS pFontProcs;
  380. VERBOSE(("Entering DrvGetGlyphMode...\n"));
  381. ASSERT(pfo && VALID_PDEV(pPDev));
  382. //
  383. // Handle OEM hooks
  384. //
  385. HANDLE_OEMHOOKS(pPDev,
  386. EP_OEMGetGlyphMode,
  387. PFN_OEMGetGlyphMode,
  388. ULONG,
  389. (dhpdev,
  390. pfo));
  391. HANDLE_VECTORHOOKS(pPDev,
  392. EP_OEMGetGlyphMode,
  393. VMGetGlyphMode,
  394. ULONG,
  395. (dhpdev,
  396. pfo));
  397. pFontProcs = (PFMPROCS)(pPDev->pFontProcs);
  398. if (pFontProcs->FMGetGlyphMode == NULL)
  399. return FO_GLYPHBITS;
  400. else
  401. return ( pFontProcs->FMGetGlyphMode(pPDev, pfo) );
  402. }