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.

395 lines
17 KiB

  1. /*++
  2. Copyright (c) 1996 - 1999 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. Routines For Font debugging support.This file should be the last in SOURCES.
  7. Environment:
  8. Windows NT Unidrv driver
  9. Revision History:
  10. 12/30/96 -ganeshp-
  11. Created
  12. --*/
  13. #if DBG
  14. #ifndef PUBLIC_GDWDEBUGFONT
  15. #define PUBLIC_GDWDEBUGFONT
  16. #endif //PUBLIC_GDWDEBUGFONT
  17. #include "font.h"
  18. BYTE *gcstrflInfo[] = {"FM_INFO_TECH_TRUETYPE",
  19. "FM_INFO_TECH_BITMAP",
  20. "FM_INFO_TECH_STROKE",
  21. "FM_INFO_TECH_OUTLINE_NOT_TRUETYPE",
  22. "FM_INFO_ARB_XFORMS",
  23. "FM_INFO_1BPP",
  24. "FM_INFO_4BPP",
  25. "FM_INFO_8BPP",
  26. "FM_INFO_16BPP",
  27. "FM_INFO_24BPP",
  28. "FM_INFO_32BPP",
  29. "FM_INFO_INTEGER_WIDTH",
  30. "FM_INFO_CONSTANT_WIDTH",
  31. "FM_INFO_NOT_CONTIGUOUS",
  32. "FM_INFO_TECH_MM",
  33. "FM_INFO_RETURNS_OUTLINES",
  34. "FM_INFO_RETURNS_STROKES",
  35. "FM_INFO_RETURNS_BITMAPS",
  36. "FM_INFO_UNICODE_COMPLIANT",
  37. "FM_INFO_RIGHT_HANDED",
  38. "FM_INFO_INTEGRAL_SCALING",
  39. "FM_INFO_90DEGREE_ROTATIONS",
  40. "FM_INFO_OPTICALLY_FIXED_PITCH",
  41. "FM_INFO_DO_NOT_ENUMERATE",
  42. "FM_INFO_ISOTROPIC_SCALING_ONLY",
  43. "FM_INFO_ANISOTROPIC_SCALING_ONLY",
  44. "FM_INFO_MM_INSTANCE",
  45. "FM_INFO_FAMILY_EQUIV",
  46. "FM_INFO_DBCS_FIXED_PITCH",
  47. "FM_INFO_NONNEGATIVE_AC",
  48. "FM_INFO_IGNORE_TC_RA_ABLE",
  49. "FM_INFO_TECH_TYPE1"};
  50. VOID
  51. VDbgDumpUCGlyphData(
  52. FONTMAP *pFM
  53. )
  54. /*++
  55. Routine Description:
  56. Dumps the Font's Glyph Data.
  57. Arguments:
  58. pFM FONTMAP struct of the Font about for which information is
  59. desired.
  60. Return Value:
  61. None
  62. Note:
  63. 12-30-96: Created it -ganeshp-
  64. --*/
  65. {
  66. /* Enable this code to print out your data array */
  67. HGLYPH *phg;
  68. ULONG cRuns;
  69. FD_GLYPHSET *pGLSet; /* Base of returned data */
  70. PWSTR pwszFaceName;
  71. IFIMETRICS *pIFI; /* For convenience */
  72. if ( gdwDebugFont & DBG_FD_GLYPHSET )
  73. {
  74. if (!pFM || !(pFM->pIFIMet) || !(((PFONTMAP_DEV)pFM->pSubFM)->pUCTree))
  75. {
  76. WARNING(("One of pFM/pFM->pIFIMet/pFM->pSubFM->pUCTree is NULL"));
  77. return;
  78. }
  79. pIFI = pFM->pIFIMet;
  80. pwszFaceName = (PWSTR)(((BYTE*) pIFI) + pIFI->dpwszFaceName );
  81. pGLSet = ((PFONTMAP_DEV)pFM->pSubFM)->pUCTree;
  82. DbgPrint( "UniFont!VDumpUCGlyphData: pwszFaceName = %ws: FD_GLYPHSET:\n", pwszFaceName );
  83. DbgPrint( " cjThis = %ld, flAccel = 0x%lx, Supp = %ld, cRuns = %ld\n",
  84. pGLSet->cjThis, pGLSet->flAccel, pGLSet->cGlyphsSupported,
  85. pGLSet->cRuns );
  86. /* Loop through the WCRUN structures */
  87. for( cRuns = 0; cRuns < pGLSet->cRuns; cRuns++ )
  88. {
  89. int i;
  90. DbgPrint( "+Run %d:\n", cRuns );
  91. DbgPrint( " wcLow = %d, cGlyphs = %d, phg = 0x%lx\n",
  92. pGLSet->awcrun[ cRuns ].wcLow, pGLSet->awcrun[ cRuns ].cGlyphs,
  93. pGLSet->awcrun[ cRuns ].phg );
  94. phg = pGLSet->awcrun[ cRuns ].phg;
  95. /* List the glyph handles for this run */
  96. for( i = 0; i < 256 && i < pGLSet->awcrun[ cRuns ].cGlyphs; i++ )
  97. {
  98. DbgPrint( "0x%4lx, ", *phg++ );
  99. if( ((i + 1) % 8) == 0 )
  100. DbgPrint( "\n" );
  101. }
  102. DbgPrint( "\n" );
  103. }
  104. }
  105. }
  106. VOID
  107. VDbgDumpGTT(
  108. PUNI_GLYPHSETDATA pGly)
  109. {
  110. if ( gdwDebugFont & DBG_UNI_GLYPHSETDATA )
  111. {
  112. PUNI_CODEPAGEINFO pCP;
  113. PGLYPHRUN pGlyphRun;
  114. PMAPTABLE pMapTable;
  115. TRANSDATA *pTrans;
  116. DWORD dwI;
  117. WORD wSize, wJ;
  118. PBYTE pCommand;
  119. pCP = (PUNI_CODEPAGEINFO)((PBYTE) pGly + pGly->loCodePageOffset);
  120. pGlyphRun = (PGLYPHRUN) ((PBYTE)pGly + pGly->loRunOffset);
  121. pMapTable = (PMAPTABLE) ((PBYTE)pGly + pGly->loMapTableOffset);
  122. pTrans = pMapTable->Trans;
  123. DbgPrint("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
  124. DbgPrint("G L Y P H S E T D A T A F I L E\n");
  125. DbgPrint("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
  126. DbgPrint("GLYPHSETDATA\n");
  127. DbgPrint("GLYPHSETDATA.dwSize : %d\n", pGly->dwSize);
  128. DbgPrint(" dwVersion : %d.%d\n", (pGly->dwVersion) >>16,
  129. 0x0000ffff&pGly->dwVersion);
  130. DbgPrint(" dwFlags : %d\n", pGly->dwFlags);
  131. DbgPrint(" lPredefinedID : %d\n", pGly->lPredefinedID);
  132. DbgPrint(" dwGlyphCount : %d\n", pGly->dwGlyphCount);
  133. DbgPrint(" dwRunCount : %d\n", pGly->dwRunCount);
  134. DbgPrint(" loRunOffset : 0x%x\n", pGly->loRunOffset);
  135. DbgPrint(" dwCodePageCount : %d\n", pGly->dwCodePageCount);
  136. DbgPrint(" loCodePageOffset : 0x%x\n", pGly->loCodePageOffset);
  137. DbgPrint(" loMapTableOffset : 0x%x\n", pGly->loMapTableOffset);
  138. DbgPrint("\n");
  139. DbgPrint("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
  140. DbgPrint("CODEPAGEINFO\n");
  141. for (dwI = 0; dwI < pGly->dwCodePageCount; dwI ++)
  142. {
  143. DbgPrint ("UNI_CODEPAGEINFO[%d].dwCodePage = %d\n",
  144. dwI, pCP->dwCodePage);
  145. DbgPrint ("UNI_CODEPAGEINFO[%d].SelectSymbolSet.dwCount = %d\n",
  146. dwI, pCP->SelectSymbolSet.dwCount);
  147. if (pCP->SelectSymbolSet.dwCount &&
  148. pCP->SelectSymbolSet.loOffset )
  149. DbgPrint ("UNI_CODEPAGEINFO[%d].SelectSymbolSet:Command = %s\n", dwI, (PBYTE)pCP+pCP->SelectSymbolSet.loOffset);
  150. DbgPrint ("UNI_CODEPAGEINFO[%d].UnSelectSymbolSet.dwCount = %d\n",
  151. dwI, pCP->UnSelectSymbolSet.dwCount);
  152. if (pCP->UnSelectSymbolSet.dwCount &&
  153. pCP->UnSelectSymbolSet.loOffset )
  154. DbgPrint ("UNI_CODEPAGEINFO[%d].UnSelectSymbolSet:Command = %s\n", dwI, (PBYTE)pCP+pCP->UnSelectSymbolSet.loOffset);
  155. pCP++;
  156. }
  157. pGlyphRun =
  158. (PGLYPHRUN) ((PBYTE)pGly + pGly->loRunOffset);
  159. DbgPrint("\n");
  160. DbgPrint("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
  161. DbgPrint("GLYPHRUN\n");
  162. for (dwI = 0; dwI < pGly->dwRunCount; dwI ++)
  163. {
  164. DbgPrint("GLYPHRUN[%2d].wcLow = 0x%-4x ",
  165. dwI, pGlyphRun->wcLow);
  166. DbgPrint("GLYPHRUN[%2d].wGlyphCount = %d\n",
  167. dwI, pGlyphRun->wGlyphCount);
  168. pGlyphRun++;
  169. }
  170. pMapTable = (PMAPTABLE) ((PBYTE)pGly + pGly->loMapTableOffset);
  171. pTrans = pMapTable->Trans;
  172. DbgPrint("\n");
  173. DbgPrint("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
  174. DbgPrint("MAPTABLE\n");
  175. DbgPrint("MAPTABLE.dwSize = %d\n", pMapTable->dwSize);
  176. DbgPrint("MAPTABLE.dwGlyphNum = %d\n", pMapTable->dwGlyphNum);
  177. #if 0
  178. for (dwI = 0; dwI < pMapTable->dwGlyphNum; dwI ++)
  179. {
  180. DbgPrint("MAPTABLE.pTrans[%5d].ubCodePageID = %d ",
  181. dwI, pTrans[dwI].ubCodePageID);
  182. DbgPrint("MAPTABLE.pTrans[%5d].ubType = %d ",
  183. dwI, pTrans[dwI].ubType);
  184. switch(pTrans[dwI].ubType)
  185. {
  186. case MTYPE_DIRECT:
  187. DbgPrint("MAPTABLE.pTrans[%5d].ubCode = 0x%02x\n",
  188. dwI, pTrans[dwI].uCode.ubCode);
  189. break;
  190. case MTYPE_PAIRED:
  191. DbgPrint("MAPTABLE.pTrans[%5d].ubPairs[0] = 0x%02x ",
  192. dwI, pTrans[dwI].uCode.ubPairs[0]);
  193. DbgPrint("MAPTABLE.pTrans[%5d].ubPairs[1] = 0x%02x ",
  194. dwI, pTrans[dwI].uCode.ubPairs[1]);
  195. break;
  196. case MTYPE_COMPOSE:
  197. DbgPrint("MAPTABLE.pTrans[%5d].sCode = 0x%02x ",
  198. dwI, pTrans[dwI].uCode.sCode);
  199. pCommand = (PBYTE)pMapTable + pTrans[dwI].uCode.sCode;
  200. wSize = *(WORD*)pCommand;
  201. pCommand += 2;
  202. DbgPrint("Size = 0x%d ", wSize);
  203. DbgPrint("Command = 0x");
  204. for (wJ = 0; wJ < wSize; wJ ++)
  205. {
  206. DbgPrint("%02x",pCommand[wJ]);
  207. }
  208. DbgPrint("\n");
  209. break;
  210. }
  211. }
  212. #endif
  213. }
  214. }
  215. VOID
  216. VDbgDumpFONTMAP(
  217. FONTMAP *pFM)
  218. {
  219. }
  220. VOID
  221. VDbgDumpIFIMETRICS(
  222. IFIMETRICS *pIFI)
  223. {
  224. PWSTR pwszFamilyName;
  225. PWSTR pwszStyleName;
  226. PWSTR pwszFaceName;
  227. PWSTR pwszUniqueName;
  228. DWORD dwI;
  229. if ( gdwDebugFont & DBG_IFIMETRICS )
  230. {
  231. pwszFamilyName = (PWSTR)(((BYTE*) pIFI) + pIFI->dpwszFamilyName);
  232. pwszStyleName = (PWSTR)(((BYTE*) pIFI) + pIFI->dpwszStyleName) ;
  233. pwszFaceName = (PWSTR)(((BYTE*) pIFI) + pIFI->dpwszFaceName) ;
  234. pwszUniqueName = (PWSTR)(((BYTE*) pIFI) + pIFI->dpwszUniqueName);
  235. DbgPrint("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
  236. DbgPrint("IFIMETRICS\n");
  237. DbgPrint("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
  238. DbgPrint("IFIMETIRCS.cjThis = %-#8lx\n" , pIFI->cjThis );
  239. DbgPrint("IFIMETIRCS.cjIfiExtra = %-#8lx\n" , pIFI->cjIfiExtra);
  240. DbgPrint("IFIMETIRCS.pwszFamilyName = \"%ws\"\n", pwszFamilyName );
  241. if( pIFI->flInfo & FM_INFO_FAMILY_EQUIV )
  242. {
  243. while( *(pwszFamilyName += wcslen( pwszFamilyName ) + 1) )
  244. {
  245. DbgPrint(" \"%ws\"\n", pwszFamilyName );
  246. }
  247. }
  248. DbgPrint("IFIMETRICS.pwszStyleName = \"%ws\"\n", pwszStyleName);
  249. DbgPrint("IFIMETRICS.pwszFaceName = \"%ws\"\n", pwszFaceName);
  250. DbgPrint("IFIMETRICS.pwszUniqueName = \"%ws\"\n", pwszUniqueName);
  251. DbgPrint("IFIMETRICS.dpFontSim = %-#8lx\n" , pIFI->dpFontSim);
  252. DbgPrint("IFIMETRICS.lEmbedId = %d\n", pIFI->lEmbedId);
  253. DbgPrint("IFIMETRICS.lItalicAngle = %d\n", pIFI->lItalicAngle);
  254. DbgPrint("IFIMETRICS.lCharBias = %d\n", pIFI->lCharBias);
  255. DbgPrint("IFIMETRICS.dpCharSets = %d\n", pIFI->dpCharSets);
  256. DbgPrint("IFIMETRICS.jWinCharSet = %04x\n", pIFI->jWinCharSet);
  257. DbgPrint("IFIMETRICS.jWinPitchAndFamily = %04x\n", pIFI->jWinPitchAndFamily);
  258. DbgPrint("IFIMETRICS.usWinWeight = %d\n", pIFI->usWinWeight);
  259. DbgPrint("IFIMETRICS.flInfo = %-#8lx\n", pIFI->flInfo);
  260. for( dwI = 0; dwI < 32; dwI ++ )
  261. {
  262. if (pIFI->flInfo & (0x00000001 << dwI))
  263. {
  264. DbgPrint(" %s\n", gcstrflInfo[dwI]);
  265. }
  266. }
  267. DbgPrint("IFIMETRICS.fsSelection = %-#6lx\n", pIFI->fsSelection);
  268. DbgPrint("IFIMETRICS.fsType = %-#6lx\n", pIFI->fsType);
  269. DbgPrint("IFIMETRICS.fwdUnitsPerEm = %d\n", pIFI->fwdUnitsPerEm);
  270. DbgPrint("IFIMETRICS.fwdLowestPPEm = %d\n", pIFI->fwdLowestPPEm);
  271. DbgPrint("IFIMETRICS.fwdWinAscender = %d\n", pIFI->fwdWinAscender);
  272. DbgPrint("IFIMETRICS.fwdWinDescender = %d\n", pIFI->fwdWinDescender);
  273. DbgPrint("IFIMETRICS.fwdMacAscender = %d\n", pIFI->fwdMacAscender);
  274. DbgPrint("IFIMETRICS.fwdMacDescender = %d\n", pIFI->fwdMacDescender);
  275. DbgPrint("IFIMETRICS.fwdMacLineGap = %d\n", pIFI->fwdMacLineGap);
  276. DbgPrint("IFIMETRICS.fwdTypoAscender = %d\n", pIFI->fwdTypoAscender);
  277. DbgPrint("IFIMETRICS.fwdTypoDescender = %d\n", pIFI->fwdTypoDescender);
  278. DbgPrint("IFIMETRICS.fwdTypoLineGap = %d\n", pIFI->fwdTypoLineGap);
  279. DbgPrint("IFIMETRICS.fwdAveCharWidth = %d\n", pIFI->fwdAveCharWidth);
  280. DbgPrint("IFIMETRICS.fwdMaxCharInc = %d\n", pIFI->fwdMaxCharInc);
  281. DbgPrint("IFIMETRICS.fwdCapHeight = %d\n", pIFI->fwdCapHeight);
  282. DbgPrint("IFIMETRICS.fwdXHeight = %d\n", pIFI->fwdXHeight);
  283. DbgPrint("IFIMETRICS.fwdSubscriptXSize = %d\n", pIFI->fwdSubscriptXSize);
  284. DbgPrint("IFIMETRICS.fwdSubscriptYSize = %d\n", pIFI->fwdSubscriptYSize);
  285. DbgPrint("IFIMETRICS.fwdSubscriptXOffset = %d\n", pIFI->fwdSubscriptXOffset);
  286. DbgPrint("IFIMETRICS.fwdSubscriptYOffset = %d\n", pIFI->fwdSubscriptYOffset);
  287. DbgPrint("IFIMETRICS.fwdSuperscriptXSize = %d\n", pIFI->fwdSuperscriptXSize);
  288. DbgPrint("IFIMETRICS.fwdSuperscriptYSize = %d\n", pIFI->fwdSuperscriptYSize);
  289. DbgPrint("IFIMETRICS.fwdSuperscriptXOffset= %d\n", pIFI->fwdSuperscriptXOffset);
  290. DbgPrint("IFIMETRICS.fwdSuperscriptYOffset= %d\n", pIFI->fwdSuperscriptYOffset);
  291. DbgPrint("IFIMETRICS.fwdUnderscoreSize = %d\n", pIFI->fwdUnderscoreSize);
  292. DbgPrint("IFIMETRICS.fwdUnderscorePosition= %d\n", pIFI->fwdUnderscorePosition);
  293. DbgPrint("IFIMETRICS.fwdStrikeoutSize = %d\n", pIFI->fwdStrikeoutSize);
  294. DbgPrint("IFIMETRICS.fwdStrikeoutPosition = %d\n", pIFI->fwdStrikeoutPosition);
  295. DbgPrint("IFIMETRICS.chFirstChar = %-#4x\n", (int) (BYTE) pIFI->chFirstChar);
  296. DbgPrint("IFIMETRICS.chLastChar = %-#4x\n", (int) (BYTE) pIFI->chLastChar);
  297. DbgPrint("IFIMETRICS.chDefaultChar = %-#4x\n", (int) (BYTE) pIFI->chDefaultChar);
  298. DbgPrint("IFIMETRICS.chBreakChar = %-#4x\n", (int) (BYTE) pIFI->chBreakChar);
  299. DbgPrint("IFIMETRICS.wcFirsChar = %-#6x\n", pIFI->wcFirstChar);
  300. DbgPrint("IFIMETRICS.wcLastChar = %-#6x\n", pIFI->wcLastChar);
  301. DbgPrint("IFIMETRICS.wcDefaultChar = %-#6x\n", pIFI->wcDefaultChar);
  302. DbgPrint("IFIMETRICS.wcBreakChar = %-#6x\n", pIFI->wcBreakChar);
  303. DbgPrint("IFIMETRICS.ptlBaseline = {%d,%d}\n", pIFI->ptlBaseline.x, pIFI->ptlBaseline.y);
  304. DbgPrint("IFIMETRICS.ptlAspect = {%d,%d}\n", pIFI->ptlAspect.x,pIFI->ptlAspect.y );
  305. DbgPrint("IFIMETRICS.ptlCaret = {%d,%d}\n", pIFI->ptlCaret.x,pIFI->ptlCaret.y );
  306. DbgPrint("IFIMETRICS.rclFontBox = {%d,%d,%d,%d}\n",
  307. pIFI->rclFontBox.left,
  308. pIFI->rclFontBox.top,
  309. pIFI->rclFontBox.right,
  310. pIFI->rclFontBox.bottom);
  311. DbgPrint("IFIMETRICS.achVendId = \"%c%c%c%c\"\n",
  312. pIFI->achVendId[0] ,
  313. pIFI->achVendId[1],
  314. pIFI->achVendId[2],
  315. pIFI->achVendId[3] );
  316. DbgPrint("IFIMETRICS.cKerningPairs = %d\n", pIFI->cKerningPairs);
  317. DbgPrint("IFIMETRICS.ulPanoseCulture = %-#8lx\n", pIFI->ulPanoseCulture);
  318. DbgPrint("\n");
  319. }
  320. }
  321. VOID
  322. VPrintString(
  323. STROBJ *pstro
  324. )
  325. {
  326. if ( gdwDebugFont & DBG_TEXTSTRING )
  327. {
  328. #define MAXTXTBUFSIZE 81
  329. WCHAR awchBuf[MAXTXTBUFSIZE];
  330. ULONG cGlyphsPrinted;
  331. cGlyphsPrinted = min(pstro->cGlyphs,MAXTXTBUFSIZE-1);
  332. wcsncpy( awchBuf, pstro->pwszOrg,cGlyphsPrinted);
  333. awchBuf[cGlyphsPrinted] = NUL;
  334. DbgPrint("\nTextOut cGlyphs = %d. First %d chars are:\n",
  335. pstro->cGlyphs,cGlyphsPrinted);
  336. DbgPrint("%ws\n",awchBuf);
  337. #undef MAXTXTBUFSIZE
  338. }
  339. }
  340. #undef PUBLIC_GDWDEBUGFONT //Only in this file.
  341. #endif //DBG