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.

310 lines
9.5 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: fontddi.cxx
  3. *
  4. * Text and font DDI callback routines.
  5. *
  6. * Tue 06-Jun-1995 -by- Andre Vachon [andreva]
  7. * update: removed a whole bunch of dead stubs.
  8. *
  9. * Fri 25-Jan-1991 -by- Bodin Dresevic [BodinD]
  10. * update: filled out all stubs
  11. *
  12. * Copyright (c) 1991-1999 Microsoft Corporation
  13. \**************************************************************************/
  14. #include "precomp.hxx"
  15. /******************************Public*Routine******************************\
  16. * ULONG FONTOBJ_cGetAllGlyphHandles (pfo,phgly) *
  17. * *
  18. * phgly Buffer for glyph handles. *
  19. * *
  20. * Used by the driver to download the whole font from the graphics engine. *
  21. * *
  22. * Warning: The device driver must ensure that the buffer is big enough *
  23. * to receive all glyph handles for a particular realized font. *
  24. * *
  25. * History: *
  26. * 25-Jan-1991 -by- Bodin Dresevic [BodinD] *
  27. * Wrote it. *
  28. \**************************************************************************/
  29. ULONG
  30. FONTOBJ_cGetAllGlyphHandles(
  31. FONTOBJ *pfo,
  32. PHGLYPH phg)
  33. {
  34. RFONTTMPOBJ rfto(PFO_TO_PRF(pfo));
  35. ASSERTGDI(rfto.bValid(), "gdisrv!FONTOBJ_cGetAllGlyphHandles(): bad pfo\n");
  36. return(rfto.chglyGetAllHandles(phg));
  37. }
  38. /******************************Public*Routine******************************\
  39. * VOID FONTOBJ_vGetInfo (pfo,cjSize,pfoi) *
  40. * *
  41. * cjSize Don't write more than this many bytes to the buffer. *
  42. * pfoi Buffer with FO_INFO structure provided by the driver. *
  43. * *
  44. * Returns the info about the font to the driver's buffer. *
  45. * *
  46. * History: *
  47. * 25-Jan-1991 -by- Bodin Dresevic [BodinD] *
  48. * Wrote it. *
  49. \**************************************************************************/
  50. VOID
  51. FONTOBJ_vGetInfo(
  52. FONTOBJ *pfo,
  53. ULONG cjSize,
  54. PFONTINFO pfi)
  55. {
  56. RFONTTMPOBJ rfto(PFO_TO_PRF(pfo));
  57. ASSERTGDI(rfto.bValid(), "gdisrv!FONTOBJ_vGetInfo(): bad pfo\n");
  58. FONTINFO fi; // RFONTOBJ will write into this buffer
  59. rfto.vGetInfo(&fi);
  60. RtlCopyMemory((PVOID) pfi, (PVOID) &fi, (UINT) cjSize);
  61. }
  62. /******************************Public*Routine******************************\
  63. * PXFORMOBJ FONTOBJ_pxoGetXform (pfo) *
  64. * *
  65. * History: *
  66. * 25-Mar-1991 -by- Bodin Dresevic [BodinD] *
  67. * Wrote it. *
  68. \**************************************************************************/
  69. XFORMOBJ
  70. *FONTOBJ_pxoGetXform(
  71. FONTOBJ *pfo)
  72. {
  73. return ((XFORMOBJ *) (PVOID) &(PFO_TO_PRF(pfo))->xoForDDI);
  74. }
  75. /******************************Public*Routine******************************\
  76. * FONTOBJ_pifi *
  77. * *
  78. * Returns pointer to associated font metrics. *
  79. * *
  80. * History: *
  81. * Wed 04-Mar-1992 10:49:53 by Kirk Olynyk [kirko] *
  82. * Wrote it. *
  83. \**************************************************************************/
  84. IFIMETRICS* FONTOBJ_pifi(FONTOBJ *pfo)
  85. {
  86. RFONTTMPOBJ rfto(PFO_TO_PRF(pfo));
  87. ASSERTGDI(rfto.bValid(), "gdisrv!FONTOBJ_pifi(): bad pfo\n");
  88. PFEOBJ pfeo(rfto.ppfe());
  89. return(pfeo.bValid() ? pfeo.pifi() : (IFIMETRICS*) NULL);
  90. }
  91. /******************************Public*Routine******************************\
  92. *
  93. * APIENTRY FONTOBJ_pfdg
  94. *
  95. * returns pointer to pfdg
  96. *
  97. * History:
  98. * 09-Jun-1997 -by- Bodin Dresevic [BodinD]
  99. * Wrote it.
  100. \**************************************************************************/
  101. FD_GLYPHSET * APIENTRY FONTOBJ_pfdg(FONTOBJ *pfo)
  102. {
  103. return (PFO_TO_PRF(pfo)->pfdg);
  104. }
  105. /******************************Public*Routine******************************\
  106. * FONTOBJ_cGetGlyphs
  107. *
  108. *
  109. * History:
  110. * 05-Jan-1993 -by- Gilman Wong [gilmanw]
  111. * Wrote it.
  112. \**************************************************************************/
  113. ULONG FONTOBJ_cGetGlyphs (
  114. FONTOBJ *pfo,
  115. ULONG iMode,
  116. ULONG cGlyph, // requested # of hglyphs to be converted to ptrs
  117. PHGLYPH phg, // array of hglyphs to be converted
  118. PVOID *ppvGlyph // driver's buffer receiving the pointers
  119. )
  120. {
  121. DONTUSE(cGlyph);
  122. GLYPHPOS gp;
  123. if(phg)
  124. gp.hg = *phg;
  125. else
  126. return 0;
  127. RFONTTMPOBJ rfto(PFO_TO_PRF(pfo));
  128. ASSERTGDI(rfto.bValid(), "gdisrv!FONTOBJ_cGetGlyphs(): bad pfo\n");
  129. if ( !rfto.bInsertGlyphbitsLookaside(&gp, iMode))
  130. return 0;
  131. *ppvGlyph = (VOID *)(gp.pgdf);
  132. return 1;
  133. }
  134. /******************************Public*Routine******************************\
  135. *
  136. * Routine Name:
  137. *
  138. * FONTOBJ_pvTrueTypeFontFile
  139. *
  140. * Routine Description:
  141. *
  142. * This routine returns a kernel mode pointer to the start of a
  143. * font file. Despite the name of the routine, the font need not be
  144. * in the TrueType format.
  145. *
  146. * GDI passes this call onto the font driver to do the detailed work.
  147. * The reason for this is that the file image can have the font file
  148. * image embedded in it in a non trivial way. An example of this would
  149. * be the *.ttc format for Far East Fonts. It is not reasonable to
  150. * expect this routine to be able to parse all file formats so that
  151. * resposibility is left to the font drivers.
  152. *
  153. * Arguments:
  154. *
  155. * pfo - a 32-bit pointer to a FONTOBJ structure associated with a font
  156. * file.
  157. *
  158. * pcjFile - the address of a 32-bit unsigend number that receives the
  159. * size of the view of the font file.
  160. *
  161. * Called by:
  162. *
  163. * Printer Drivers in the context of a call to DrvTextOut
  164. *
  165. * Return Value:
  166. *
  167. * If successful, this routine will return a kernel mode view of
  168. * a TrueType font file. If unsuccessful this routine returns NULL.
  169. *
  170. \**************************************************************************/
  171. PVOID FONTOBJ_pvTrueTypeFontFile(
  172. FONTOBJ *pfo,
  173. ULONG *pcjFile
  174. )
  175. {
  176. void *pvRet = 0;
  177. *pcjFile = 0;
  178. RFONTTMPOBJ rfo(PFO_TO_PRF(pfo));
  179. if ( rfo.bValid() )
  180. {
  181. pvRet = rfo.pvFile( pcjFile );
  182. }
  183. return( pvRet );
  184. }
  185. PVOID
  186. FONTOBJ_pvTrueTypeFontFileUMPD(
  187. FONTOBJ *pfo,
  188. ULONG *pcjFile,
  189. PVOID *ppBase
  190. )
  191. {
  192. *ppBase = NULL;
  193. *pcjFile = 0;
  194. RFONTTMPOBJ rfo(PFO_TO_PRF(pfo));
  195. return rfo.bValid() ? rfo.pvFileUMPD(pcjFile, ppBase) : NULL;
  196. }
  197. /******************************Public*Routine******************************\
  198. *
  199. * Routine Name:
  200. *
  201. * FONTOBJ_pjOpenTypeTablePointer
  202. *
  203. * Routine Description:
  204. *
  205. * Arguments:
  206. *
  207. * Called by:
  208. *
  209. * Return Value:
  210. *
  211. * A pointer to a view of the table.
  212. *
  213. \**************************************************************************/
  214. PBYTE FONTOBJ_pjOpenTypeTablePointer (
  215. FONTOBJ *pfo,
  216. ULONG ulTag,
  217. ULONG *pcjTable
  218. )
  219. {
  220. PBYTE pjTable = 0;
  221. RFONTTMPOBJ rfo(PFO_TO_PRF(pfo));
  222. if ( rfo.bValid() )
  223. {
  224. pjTable = rfo.pjTable( ulTag, pcjTable );
  225. }
  226. return( pjTable );
  227. }
  228. LPWSTR FONTOBJ_pwszFontFilePaths (FONTOBJ *pfo, ULONG *pcwc)
  229. {
  230. LPWSTR pwsz = NULL;
  231. *pcwc = 0;
  232. RFONTTMPOBJ rfo(PFO_TO_PRF(pfo));
  233. if ( rfo.bValid() )
  234. {
  235. // return 0 for memory fonts and temporary fonts added to dc's for printing
  236. if (!(rfo.prfnt->ppfe->pPFF->flState & (PFF_STATE_MEMORY_FONT | PFF_STATE_DCREMOTE_FONT)))
  237. {
  238. pwsz = rfo.prfnt->ppfe->pPFF->pwszPathname_;
  239. *pcwc = rfo.prfnt->ppfe->pPFF->cwc;
  240. }
  241. }
  242. return pwsz;
  243. }
  244. /******************************Public*Routine******************************\
  245. * FONTOBJ_bQueryGlyphAttrs
  246. *
  247. * History:
  248. * Thu 21-May-1998 by Yung-Jen Tony Tsai [YungT]
  249. * Wrote it.
  250. \**************************************************************************/
  251. PFD_GLYPHATTR APIENTRY FONTOBJ_pQueryGlyphAttrs(
  252. FONTOBJ *pfo,
  253. ULONG iMode
  254. )
  255. {
  256. RFONTTMPOBJ rfo(PFO_TO_PRF(pfo));
  257. if ( rfo.bValid() )
  258. {
  259. PDEVOBJ pdo( rfo.hdevProducer() );
  260. if (pdo.bValid() && PPFNVALID(pdo, QueryGlyphAttrs) )
  261. {
  262. return pdo.QueryGlyphAttrs(pfo, iMode);
  263. }
  264. }
  265. return( NULL );
  266. }