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.

3118 lines
93 KiB

  1. //-----------------------------------------------------------------------------
  2. // This files contains the module name for this mini driver. Each mini driver
  3. // must have a unique module name. The module name is used to obtain the
  4. // module handle of this Mini Driver. The module handle is used by the
  5. // generic library to load in tables from the Mini Driver.
  6. //-----------------------------------------------------------------------------
  7. /*++
  8. Copyright (c) 1996-1999 Microsoft Corporation
  9. Module Name:
  10. cmdcb.c
  11. Abstract:
  12. Implementation of GPD command callback for "test.gpd":
  13. OEMCommandCallback
  14. Environment:
  15. Windows NT Unidrv driver
  16. Revision History:
  17. 04/07/97 -zhanw-
  18. Created it.
  19. --*/
  20. // NTRAID#NTBUG9-550215-2002/02/21-yasuho-: Use strsafe.h
  21. // NTRAID#NTBUG9-568204-2002/03/07-yasuho-: Should change much safer function.
  22. // NTRAID#NTBUG9-568217-2002/03/07-yasuho-: Check divide by zero
  23. // NTRAID#NTBUG9-568220-2002/03/07-yasuho-: Remove the dead code
  24. #define LIPS4_DRIVER
  25. #include "pdev.h"
  26. #define CCHMAXCMDLEN 256
  27. #define SWAPW(x) (((WORD)(x)<<8) | ((WORD)(x)>>8))
  28. #define ABS(x) (x > 0?x:-x)
  29. #define WRITESPOOLBUF(pdevobj, cmd, len) \
  30. (pdevobj)->pDrvProcs->DrvWriteSpoolBuf(pdevobj, cmd, len)
  31. // NTRAID#NTBUG9-289908-2002/03/07-yasuho-: pOEMDM -> pdevOEM
  32. PDEVOEM APIENTRY
  33. OEMEnablePDEV(
  34. PDEVOBJ pdevobj,
  35. PWSTR pPrinterName,
  36. ULONG cPatterns,
  37. HSURF *phsurfPatterns,
  38. ULONG cjGdiInfo,
  39. GDIINFO *pGdiInfo,
  40. ULONG cjDevInfo,
  41. DEVINFO *pDevInfo,
  42. DRVENABLEDATA *pded)
  43. {
  44. PLIPSPDEV pOEM;
  45. if(!pdevobj->pdevOEM)
  46. {
  47. if(!(pdevobj->pdevOEM = MemAllocZ(sizeof(LIPSPDEV))))
  48. {
  49. return NULL;
  50. }
  51. }
  52. pOEM = (PLIPSPDEV)pdevobj->pdevOEM;
  53. // Flags
  54. pOEM->fbold = FALSE; // uses Ornamented Character
  55. pOEM->fitalic = FALSE; // uses Char Orientatoin
  56. pOEM->fwhitetext = FALSE; // White Text mode
  57. pOEM->fdoublebyte = FALSE; // DBCS char mode
  58. pOEM->fvertical = FALSE; // Vertical writing mode
  59. pOEM->funderline = FALSE;
  60. pOEM->fstrikesthu = FALSE;
  61. pOEM->fpitch = FIXED;
  62. pOEM->flpdx = FALSE;
  63. pOEM->fcompress = 0x30; // default is non compress
  64. // Lips4 features
  65. pOEM->fduplex = FALSE;
  66. pOEM->fduplextype = VERT;
  67. pOEM->nxpages = DEVICESETTING;
  68. pOEM->fsmoothing = DEVICESETTING;
  69. pOEM->fecono = DEVICESETTING;
  70. pOEM->fdithering = DEVICESETTING;
  71. // Variables
  72. pOEM->ptCurrent.x = pOEM->ptCurrent.y = 0;
  73. pOEM->ptInLine.x = pOEM->ptInLine.y = 0;
  74. pOEM->bLogicStyle = INIT;
  75. pOEM->savechar = -1;
  76. pOEM->printedchars = 0;
  77. pOEM->firstchar = 0;
  78. pOEM->lastchar = 0;
  79. pOEM->stringwidth = 0;
  80. pOEM->curFontGrxIds[0] = pOEM->curFontGrxIds[1] = 0xff;
  81. pOEM->curFontGrxIds[2] = pOEM->curFontGrxIds[3] = 0xff;
  82. pOEM->curFontGrxIds[4] = pOEM->curFontGrxIds[5] = 0xff;
  83. pOEM->curFontGrxIds[6] = pOEM->curFontGrxIds[7] = 0xff;
  84. pOEM->tblPreviousFont.FontHeight = INIT;
  85. pOEM->tblPreviousFont.FontWidth = INIT;
  86. pOEM->tblPreviousFont.MaxWidth = INIT;
  87. pOEM->tblPreviousFont.AvgWidth = INIT;
  88. pOEM->tblPreviousFont.Ascent = INIT;
  89. pOEM->tblPreviousFont.Stretch = INIT;
  90. pOEM->tblCurrentFont.FontHeight = 50;
  91. pOEM->tblCurrentFont.FontWidth = 25;
  92. pOEM->tblPreviousFont.MaxWidth = 50;
  93. pOEM->tblPreviousFont.AvgWidth = 25;
  94. pOEM->tblPreviousFont.Ascent = 45;
  95. pOEM->OrnamentedChar[0] = pOEM->OrnamentedChar[1] = INIT;
  96. pOEM->OrnamentedChar[2] = pOEM->OrnamentedChar[3] = INIT;
  97. pOEM->OrnamentedChar[4] = INIT;
  98. pOEM->TextPath = INIT;
  99. pOEM->CharOrientation[0] = pOEM->CharOrientation[1] = INIT;
  100. pOEM->CharOrientation[2] = pOEM->CharOrientation[3] = INIT;
  101. pOEM->GLTable = INIT;
  102. pOEM->GRTable = INIT;
  103. pOEM->cachedfont = 0; // We have no id 0 font.
  104. pOEM->papersize = PAPER_DEFAULT; // A4
  105. pOEM->Escapement = 0;
  106. pOEM->resolution = 300;
  107. pOEM->unitdiv = 2;
  108. // Vector command
  109. pOEM->wCurrentImage = 0;
  110. #ifdef LIPS4C
  111. pOEM->flips4C = FALSE;
  112. #endif // LIPS4C
  113. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  114. pOEM->masterunit = 600;
  115. // NTRAID#NTBUG9-228625-2002/03/07-yasuho-: Stacker support
  116. pOEM->tray = INIT;
  117. pOEM->method = INIT;
  118. pOEM->staple = INIT;
  119. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: Sorter support
  120. pOEM->sorttype = INIT;
  121. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: CPCA support
  122. pOEM->fCPCA = FALSE;
  123. pOEM->fCPCA2 = FALSE;
  124. CPCAInit(pOEM);
  125. // NTRAID#NTBUG9-293002-2002/03/07-yasuho-:
  126. // Features are different from H/W options.
  127. pOEM->startbin = INIT;
  128. // NTRAID#NTBUG9-501162-2002/03/07-yasuho-: Collate does not work
  129. pOEM->collate = INIT;
  130. return pdevobj->pdevOEM;
  131. }
  132. VOID APIENTRY
  133. OEMDisablePDEV(
  134. PDEVOBJ pdevobj)
  135. {
  136. if(pdevobj->pdevOEM)
  137. {
  138. MemFree(pdevobj->pdevOEM);
  139. pdevobj->pdevOEM = NULL;
  140. }
  141. }
  142. BOOL APIENTRY OEMResetPDEV(
  143. PDEVOBJ pdevobjOld,
  144. PDEVOBJ pdevobjNew)
  145. {
  146. PLIPSPDEV pOEMOld, pOEMNew;
  147. pOEMOld = (PLIPSPDEV)pdevobjOld->pdevOEM;
  148. pOEMNew = (PLIPSPDEV)pdevobjNew->pdevOEM;
  149. if (pOEMOld != NULL && pOEMNew != NULL)
  150. *pOEMNew = *pOEMOld;
  151. return TRUE;
  152. }
  153. // BInitOEMExtraData() and BMergeOEMExtraData() has moved to common.c
  154. // NTRAID#NTBUG9-568217-2002/03/07-yasuho-: iDwtoa(): Replace safer function.
  155. // Support DRC
  156. static BOOL
  157. ToVFormat(long v, PBYTE *pbp, PBYTE pend, int bits)
  158. {
  159. long max, l;
  160. int sign;
  161. sign = (v < 0);
  162. v = sign ? -v : v;
  163. max = 1 << bits;
  164. if (v >= max) {
  165. if (!ToVFormat(v >> bits, pbp, pend, 6))
  166. return FALSE;
  167. }
  168. l = (v & (max-1));
  169. if (bits == 4)
  170. l += sign ? ' ' : '0';
  171. else
  172. l += '@';
  173. if (*pbp >= pend)
  174. return FALSE;
  175. *(*pbp)++ = (char)l;
  176. return TRUE;
  177. }
  178. BOOL VFormat(long sParam, PBYTE *pbp, PBYTE pend)
  179. {
  180. return ToVFormat(sParam, pbp, pend, 4);
  181. }
  182. //*****************************************************************
  183. // Send current Font ID and Graphic set ID to printer anyway.
  184. //*****************************************************************
  185. BOOL SendFontGrxID(pdevobj)
  186. PDEVOBJ pdevobj;
  187. {
  188. PLIPSPDEV pOEM;
  189. BYTE ch[CCHMAXCMDLEN];
  190. PBYTE pch, pend;
  191. BYTE tid;
  192. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  193. pch = ch;
  194. pend = &ch[CCHMAXCMDLEN];
  195. // Send font, grx ids x 4 x 2
  196. if(pOEM->curFontGrxIds[0] != 0xff) {
  197. tid = pOEM->curFontGrxIds[0];
  198. // Font ID G0
  199. if (pch >= pend)
  200. return FALSE;
  201. *pch++ = 'T';
  202. if (VFormat(tid, &pch, pend))
  203. return FALSE;
  204. }
  205. if(pOEM->curFontGrxIds[1] != 0xff) {
  206. tid = pOEM->curFontGrxIds[1];
  207. // Font ID G1
  208. if (pch >= pend)
  209. return FALSE;
  210. *pch++ = 'm';
  211. if (VFormat(tid, &pch, pend))
  212. return FALSE;
  213. }
  214. if(pOEM->curFontGrxIds[2] != 0xff) {
  215. tid = pOEM->curFontGrxIds[2];
  216. // Font ID G2
  217. if (pch >= pend)
  218. return FALSE;
  219. *pch++ = 'n';
  220. if (VFormat(tid, &pch, pend))
  221. return FALSE;
  222. }
  223. if(pOEM->curFontGrxIds[3] != 0xff) {
  224. tid = pOEM->curFontGrxIds[3];
  225. // Font ID G3
  226. if (pch >= pend)
  227. return FALSE;
  228. *pch++ = 'o';
  229. if (VFormat(tid, &pch, pend))
  230. return FALSE;
  231. }
  232. if(pOEM->curFontGrxIds[4] != 0xff) {
  233. tid = pOEM->curFontGrxIds[4];
  234. // Grx ID G0
  235. if (pch >= pend)
  236. return FALSE;
  237. *pch++ = ']';
  238. if (VFormat(tid, &pch, pend))
  239. return FALSE;
  240. }
  241. if(pOEM->curFontGrxIds[5] != 0xff) {
  242. tid = pOEM->curFontGrxIds[5];
  243. // Grx ID G1
  244. if (pch >= pend)
  245. return FALSE;
  246. *pch++ = 0x60; // '`'
  247. if (VFormat(tid, &pch, pend))
  248. return FALSE;
  249. }
  250. if(pOEM->curFontGrxIds[6] != 0xff) {
  251. tid = pOEM->curFontGrxIds[6];
  252. // Grx ID G2
  253. if (pch >= pend)
  254. return FALSE;
  255. *pch++ = 'a';
  256. if (VFormat(tid, &pch, pend))
  257. return FALSE;
  258. }
  259. if(pOEM->curFontGrxIds[7] != 0xff) {
  260. tid = pOEM->curFontGrxIds[7];
  261. // Grx ID G3
  262. if (pch >= pend)
  263. return FALSE;
  264. *pch++ = 'b';
  265. if (VFormat(tid, &pch, pend))
  266. return FALSE;
  267. }
  268. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  269. return TRUE;
  270. }
  271. // **** Put PaperSize Select command
  272. BOOL SelectPaperSize(pdevobj, paperid)
  273. PDEVOBJ pdevobj;
  274. char paperid;
  275. {
  276. char i;
  277. PLIPSPDEV pOEM;
  278. DWORD x, y;
  279. PBYTE pch;
  280. size_t rem;
  281. BYTE ch[CCHMAXCMDLEN];
  282. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  283. // if papersize was set already, it's skipped
  284. if(pOEM->currentpapersize == paperid)
  285. return TRUE;
  286. // NTRAID#NTBUG9-254925-2002/03/07-yasuho-: CUSTOM papers.
  287. i = paperid - PAPER_FIRST;
  288. if ((paperid != PAPER_PORT && paperid != PAPER_LAND) ||
  289. !pOEM->dwPaperWidth || !pOEM->dwPaperHeight) {
  290. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, NULL, 0,
  291. cmdSelectPaper, PaperIDs[i])))
  292. return FALSE;
  293. } else {
  294. // Custom forms
  295. // NTRAID#NTBUG9-309695-2002/03/07-yasuho-:
  296. // top margin incorrect on custom:landscape:LIPS4c
  297. if (pOEM->flips4 || pOEM->flips4C) {
  298. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, &rem, 0,
  299. cmdSelectUnit4, pOEM->resolution)))
  300. return FALSE;
  301. } else {
  302. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, &rem, 0,
  303. cmdSelectUnit3)))
  304. return FALSE;
  305. }
  306. i = (paperid == PAPER_PORT) ? 80 : 81;
  307. if (!pOEM->unitdiv)
  308. return FALSE;
  309. x = pOEM->dwPaperWidth / (DWORD)pOEM->unitdiv;
  310. y = pOEM->dwPaperHeight / (DWORD)pOEM->unitdiv;
  311. if (FAILED(StringCchPrintfExA(pch, rem, &pch, NULL, 0,
  312. cmdSelectCustom, i, y, x)))
  313. return FALSE;
  314. }
  315. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  316. // save papersize
  317. pOEM->currentpapersize = paperid;
  318. return TRUE;
  319. }
  320. BOOL NEAR PASCAL SetPenAndBrush(PDEVOBJ pdevobj, WORD wType)
  321. {
  322. BYTE ch[CCHMAXCMDLEN];
  323. PBYTE pch, pend;
  324. PLIPSPDEV pOEM;
  325. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  326. pch = ch;
  327. pend = &ch[CCHMAXCMDLEN];
  328. if (SET_BRUSH == wType) {
  329. short sBrush;
  330. if (pOEM->sBrushStyle == INIT)
  331. pOEM->sBrushStyle = 0;
  332. if (pOEM->sBrushStyle & 0x20)
  333. sBrush = pOEM->sBrushStyle;
  334. else
  335. sBrush = BrushType[pOEM->sBrushStyle];
  336. if (&pch[4] > pend)
  337. return FALSE;
  338. *pch++ = 'I';
  339. *pch++ = (BYTE)sBrush;
  340. *pch++ = (pOEM->fVectCmd & VFLAG_PEN_NULL) ? '0' : '1';
  341. *pch++ = 0x1E;
  342. }
  343. if (SET_PEN == wType) {
  344. if (!(pOEM->fVectCmd & VFLAG_PEN_NULL)) {
  345. if (FAILED(StringCchPrintfExA(pch, (INT)(pch - ch), &pch, NULL, 0,
  346. "E1%d\x1E\x7DG%d1\x1E",
  347. pOEM->sPenStyle,
  348. pOEM->sPenColor)))
  349. return FALSE;
  350. if (&pch[3] > pend)
  351. return FALSE;
  352. *pch++ = 'F';
  353. *pch++ = '1';
  354. if (!VFormat(pOEM->sPenWidth, &pch, pend))
  355. return FALSE;
  356. *pch++ = 0x1E;
  357. } else {
  358. if (FAILED(StringCchPrintfExA(pch, (INT)(pch - ch), &pch, NULL, 0,
  359. "\x7DG20\x1E")))
  360. return FALSE;
  361. }
  362. }
  363. if ((DWORD)(pch - ch) > 0)
  364. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  365. return TRUE;
  366. }
  367. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: CPCA support
  368. /*
  369. * PJLStart
  370. */
  371. static BOOL
  372. PJLStart(PDEVOBJ pdevobj)
  373. {
  374. PLIPSPDEV pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  375. LPLIPSCmd lp;
  376. short res;
  377. INT i;
  378. WORD wlen;
  379. PBYTE pch;
  380. BYTE ch[CCHMAXCMDLEN];
  381. WRITESPOOLBUF(pdevobj, cmdPJLTOP1.pCmdStr, cmdPJLTOP1.cbSize);
  382. WRITESPOOLBUF(pdevobj, cmdPJLTOP2.pCmdStr, cmdPJLTOP2.cbSize);
  383. // NTRAID#NTBUG9-293002-2002/03/07-yasuho-:
  384. // Features are different from H/W options.
  385. switch (pOEM->tray) {
  386. default:
  387. break;
  388. case 0: // AUTO
  389. i = 0;
  390. goto traycommon;
  391. case 100: // DEFAULT
  392. i = 1;
  393. goto traycommon;
  394. case 101: // SUBTRAY
  395. i = 2;
  396. goto traycommon;
  397. case 1: // BIN1
  398. case 2: // BIN2
  399. case 3: // BIN3
  400. i = pOEM->tray + 2;
  401. // FALL THRU
  402. traycommon:
  403. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, NULL, 0,
  404. cmdPJLBinSelect, cmdBinType[i])))
  405. return FALSE;
  406. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  407. break;
  408. }
  409. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  410. res = pOEM->resolution;
  411. if(res == 1200)
  412. WRITESPOOLBUF(pdevobj, cmdPJLTOP3SUPERFINE.pCmdStr, cmdPJLTOP3SUPERFINE.cbSize);
  413. else if(res == 600)
  414. WRITESPOOLBUF(pdevobj, cmdPJLTOP3FINE.pCmdStr, cmdPJLTOP3FINE.cbSize);
  415. else
  416. WRITESPOOLBUF(pdevobj, cmdPJLTOP3QUICK.pCmdStr,cmdPJLTOP3QUICK.cbSize);
  417. // NTRAID#NTBUG9-228625-2002/03/07-yasuho-: Stacker support
  418. switch (pOEM->method) {
  419. case METHOD_JOBOFFSET:
  420. WRITESPOOLBUF(pdevobj, cmdPJLTOP31JOBOFF.pCmdStr, cmdPJLTOP31JOBOFF.cbSize);
  421. break;
  422. case METHOD_STAPLE:
  423. if (pOEM->staple < 0 || pOEM->staple >= sizeof(cmdStapleModes) /
  424. sizeof(cmdStapleModes[0]))
  425. break;
  426. lp = &cmdStapleModes[pOEM->staple];
  427. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, NULL, 0,
  428. "%s%s\r\n",
  429. cmdPJLTOP31STAPLE.pCmdStr,
  430. lp->pCmdStr)))
  431. return FALSE;
  432. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  433. break;
  434. }
  435. // NTRAID#NTBUG9-293002-2002/03/07-yasuho-:
  436. // Features are different from H/W options.
  437. switch (pOEM->sorttype) {
  438. case SORTTYPE_SORT:
  439. i = 0;
  440. goto sortcommon;
  441. case SORTTYPE_GROUP:
  442. i = 1;
  443. goto sortcommon;
  444. case SORTTYPE_STAPLE:
  445. i = 2;
  446. goto sortcommon;
  447. // NTRAID#NTBUG9-501162-2002/03/07-yasuho-: Collate does not work
  448. default:
  449. if (pOEM->collate != COLLATE_ON)
  450. break;
  451. i = 0;
  452. // FALL THRU
  453. sortcommon:
  454. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, NULL, 0,
  455. cmdPJLSorting, cmdSortType[i])))
  456. return FALSE;
  457. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  458. break;
  459. }
  460. if (pOEM->startbin != INIT) {
  461. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, NULL, 0,
  462. cmdPJLStartBin, pOEM->startbin)))
  463. return FALSE;
  464. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  465. }
  466. WRITESPOOLBUF(pdevobj, cmdPJLTOP4.pCmdStr, cmdPJLTOP4.cbSize);
  467. WRITESPOOLBUF(pdevobj, cmdPJLTOP5.pCmdStr, cmdPJLTOP5.cbSize);
  468. return TRUE;
  469. }
  470. /*
  471. * PJLEnd
  472. */
  473. static void
  474. PJLEnd(PDEVOBJ pdevobj)
  475. {
  476. WRITESPOOLBUF(pdevobj, cmdPJLBOTTOM1.pCmdStr, cmdPJLBOTTOM1.cbSize);
  477. WRITESPOOLBUF(pdevobj, cmdPJLBOTTOM2.pCmdStr, cmdPJLBOTTOM2.cbSize);
  478. }
  479. /*
  480. * OEMCommandCallback
  481. */
  482. INT APIENTRY OEMCommandCallback(
  483. PDEVOBJ pdevobj,
  484. DWORD dwCmdCbID,
  485. DWORD dwCount,
  486. PDWORD pdwParams
  487. )
  488. {
  489. INT i, j, k;
  490. BYTE *bp;
  491. BYTE ch[CCHMAXCMDLEN];
  492. PLIPSPDEV pOEM;
  493. LPGrxSetNo pGS;
  494. DWORD r, g, b;
  495. PBYTE pch;
  496. PBYTE pend = &ch[CCHMAXCMDLEN];
  497. // DbgPrint(DLLTEXT("OEMCommandCallback() entry.\r\n"));
  498. //
  499. // verify pdevobj okay
  500. //
  501. // ASSERT(VALID_PDEVOBJ(pdevobj));
  502. //
  503. // fill in printer commands
  504. //
  505. i = 0;
  506. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  507. // Register PaperSize 40 - 65
  508. if(dwCmdCbID >= PAPER_FIRST && dwCmdCbID <= PAPER_LAST) {
  509. // NTRAID#NTBUG9-254925-2002/03/07-yasuho-: CUSTOM papers.
  510. pOEM->papersize = (char)dwCmdCbID;
  511. if (dwCount < 2 || !pdwParams)
  512. return 0;
  513. pOEM->dwPaperWidth = pdwParams[0];
  514. pOEM->dwPaperHeight = pdwParams[1];
  515. return 0;
  516. }
  517. switch(dwCmdCbID)
  518. {
  519. long cx,cy;
  520. short res;
  521. case RES_SENDBLOCK:
  522. if (dwCount < 3 || !pdwParams)
  523. break;
  524. cx = pOEM->ptCurrent.x;
  525. cy = pOEM->ptCurrent.y;
  526. #ifdef LIPS4C
  527. // NOTE!: \x7DH cmd is not accepted when full color printing for
  528. // \x7DQ cmd.
  529. // Rasdd works as the following order when the model is not MD_SERIAL.
  530. // 1. Puts no white character.
  531. // 2. Puts graphics.
  532. // 3. Puts white character.
  533. // Therefore, black character is deleted when rasdd puts graphics due
  534. // to the design describing at NOTE!.
  535. // I have changed the type of printer model to MD_SERIAL.
  536. // Following \x7DH cmd is for grayscale printing.
  537. // NTRAID#NTBUG9-185744-2002/03/07-yasuho-: White font isn't printed
  538. // These 'hack' code doesn't necessary on NT5.
  539. if(pOEM->flips4C) {
  540. if(pOEM->bLogicStyle != OR_MODE) {
  541. // "\x7DH1\x1E"
  542. pch = ch;
  543. if (&pch[4] > pend) return -1;
  544. *pch++ = '\x7D';
  545. *pch++ = 'H';
  546. *pch++ = '1';
  547. *pch++ = 0x1E;
  548. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  549. pOEM->bLogicStyle = OR_MODE;
  550. }
  551. } else { // !flips4C
  552. #endif // LIPS4C
  553. if (pOEM->fcolor) {
  554. if(pOEM->bLogicStyle != OVER_MODE) {
  555. pOEM->bLogicStyle = OVER_MODE;
  556. pch = ch;
  557. if (&pch[4] > pend) return -1;
  558. *pch++ = 0x7D;
  559. *pch++ = 'H';
  560. *pch++ = '0';
  561. *pch++ = 0x1E;
  562. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  563. }
  564. } else {
  565. if(pOEM->bLogicStyle != OR_MODE) {
  566. pOEM->bLogicStyle = OR_MODE;
  567. pch = ch;
  568. if (&pch[4] > pend) return -1;
  569. *pch++ = 0x7D;
  570. *pch++ = 'H';
  571. *pch++ = '1';
  572. *pch++ = 0x1E;
  573. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  574. }
  575. } // fcolor
  576. #ifdef LIPS4C
  577. } // flips4C
  578. #endif // LIPS4C
  579. #ifdef LBP_2030
  580. if( pOEM->fcolor ) {
  581. if( pOEM->fplane == 0 ) {
  582. // "\x7DP{pt.X}{pt.Y}{36000}{36000}{Height}{Width}{1}{0}{1}{0}{0}{1}\x1E"
  583. pch = ch;
  584. if (&pch[2] > pend) return -1;
  585. *pch++ = 0x7D;
  586. *pch++ = 'P';
  587. if (!VFormat(cx, &pch, pend)) return -1;
  588. if (!VFormat(cy, &pch, pend)) return -1;
  589. res = pOEM->resolution;
  590. if (!VFormat(res * 100, &pch, pend)) return -1; // (x res)
  591. if (!VFormat(res * 100, &pch, pend)) return -1; // (y res)
  592. if (!VFormat(*(pdwParams+1), &pch, pend)) return -1; // height
  593. if(pOEM->fcolor == COLOR) {
  594. // On 2030, specifying "RGB per line" data format did not
  595. // work well (yellow ink was not printed.) it seems that
  596. // the same data can be printed out correctly if you
  597. // specify "RGB per plane".
  598. // (In this case we are sending out scan lines as planes
  599. // with height 1.)
  600. if (!VFormat(8*(*(pdwParams+2)), &pch, pend)) return -1;
  601. if (&pch[2] > pend) return -1;
  602. *pch++ = 0x31; // bits per color: 1
  603. *pch++ = 0x3C; // data format: RGB per plane
  604. } else if (pOEM->fcolor == COLOR_8BPP) {
  605. if (!VFormat(*(pdwParams+2), &pch, pend))
  606. return -1;
  607. if (&pch[2] > pend) return -1;
  608. *pch++ = 0x38; // bits per color: 8
  609. *pch++ = 0x31; // data format: color index
  610. } else { // COLOR_24BPP
  611. if (!VFormat(*(pdwParams+2)/3, &pch, pend)) return -1;
  612. if (&pch[2] > pend) return -1;
  613. *pch++ = 0x38; // bits per color: 8
  614. *pch++ = 0x3A; // data format: RGB per point
  615. }
  616. if (&pch[5] > pend) return -1;
  617. *pch++ = 0x30; // Height Vector
  618. *pch++ = 0x31;
  619. *pch++ = 0x31; // Width Vector
  620. *pch++ = 0x30;
  621. *pch++ = 0x1E;
  622. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  623. }
  624. // "\x7DQ{1}{1}{0}{size of byte}\x1E"
  625. pch = ch;
  626. if (&pch[6] > pend) return -1;
  627. *pch++ = 0x7D;
  628. *pch++ = 'Q';
  629. *pch++ = 0x31;
  630. *pch++ = (pOEM->fplane < pOEM->fplaneMax) ? 0x30 : 0x31;
  631. *pch++ = pOEM->fcompress;
  632. if (!VFormat(*pdwParams, &pch, pend)) return -1;
  633. *pch++ = 0x1E;
  634. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  635. if (pOEM->fcolor == COLOR) {
  636. if (pOEM->fplane >= pOEM->fplaneMax)
  637. pOEM->fplane = 0;
  638. else
  639. pOEM->fplane++;
  640. }
  641. break;
  642. } // fcolor
  643. #endif //LBP_2030
  644. // "\x7DP{pt.X}{pt.Y}{30000}{30000}{Height}{Width}{1}{0}{1}{0}{0}{1}\x1E"
  645. pch = ch;
  646. if (&pch[2] > pend) return -1;
  647. *pch++ = 0x7D;
  648. *pch++ = 'P';
  649. if (!VFormat(cx, &pch, pend)) return -1;
  650. if (!VFormat(cy, &pch, pend)) return -1;
  651. res = pOEM->resolution;
  652. if (!VFormat(res * 100, &pch, pend)) return -1; // (x res)
  653. if (!VFormat(res * 100, &pch, pend)) return -1; // (y res)
  654. if (!VFormat((short)*(pdwParams+1), &pch, pend)) return -1; // height
  655. if (!VFormat((short)(8*(*(pdwParams+2))), &pch, pend)) // width
  656. return -1;
  657. if (&pch[7] > pend) return -1;
  658. *pch++ = 0x31;
  659. *pch++ = 0x30;
  660. *pch++ = 0x30;
  661. *pch++ = 0x31;
  662. *pch++ = 0x31;
  663. *pch++ = 0x30;
  664. // LIPS4 feature
  665. if(pOEM->flips4 == TRUE) {
  666. if (&pch[2] > pend) return -1;
  667. *pch++ = 0x30;
  668. *pch++ = 0x31; // batch image transfer
  669. }
  670. *pch++ = 0x1E;
  671. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  672. // "\x7DQ{1}{1}{0}{size of byte}\x1E"
  673. pch = ch;
  674. if (&pch[7] > pend) return -1;
  675. *pch++ = 0x7D;
  676. *pch++ = 'Q';
  677. *pch++ = 0x31;
  678. *pch++ = 0x31;
  679. *pch++ = pOEM->fcompress;
  680. if (!VFormat(*pdwParams, &pch, pend)) return -1;
  681. *pch++ = 0x1E;
  682. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  683. break;
  684. case BEGIN_COMPRESS:
  685. pOEM->fcompress = 0x37; // Method 1
  686. break;
  687. case BEGIN_COMPRESS_TIFF:
  688. pOEM->fcompress = 0x3b; // TIFF
  689. break;
  690. // Support DRC
  691. case BEGIN_COMPRESS_DRC:
  692. pOEM->fcompress = 0x3c; // DRC
  693. break;
  694. case END_COMPRESS:
  695. pOEM->fcompress = 0x30; // No compression
  696. break;
  697. // Select Resolution
  698. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  699. case SELECT_RES_1200:
  700. pOEM->resolution = 1200;
  701. pOEM->unitdiv = 1;
  702. break;
  703. case SELECT_RES_600:
  704. #ifdef LBP_2030
  705. pOEM->fcolor = MONOCHROME; // Initialize, defalut is monochrome
  706. #endif
  707. pOEM->resolution = 600;
  708. pOEM->unitdiv = 1;
  709. break;
  710. #ifdef LIPS4C
  711. case SELECT_RES4C_360:
  712. pOEM->resolution = 360;
  713. pOEM->unitdiv = 1;
  714. if (pOEM->fcolor)
  715. WRITESPOOLBUF(pdevobj, cmdColorMode4C.pCmdStr, cmdColorMode4C.cbSize);
  716. else
  717. WRITESPOOLBUF(pdevobj, cmdMonochrome4C.pCmdStr, cmdMonochrome4C.cbSize);
  718. break;
  719. #endif // LIPS4C
  720. case SELECT_RES_300:
  721. #ifdef LBP_2030
  722. pOEM->fcolor = MONOCHROME; // Initialize, defalut is monochrome
  723. #endif
  724. pOEM->resolution = 300;
  725. pOEM->unitdiv = 2;
  726. break;
  727. case SELECT_RES_150:
  728. #ifdef LBP_2030
  729. pOEM->fcolor = MONOCHROME; // Initialize, defalut is monochrome
  730. #endif
  731. pOEM->resolution = 150;
  732. pOEM->unitdiv = 2;
  733. // 150 dpi mode means only image data is 150dpi
  734. break;
  735. case OCD_BEGINDOC:
  736. pOEM->flips4 = FALSE;
  737. res = pOEM->resolution;
  738. if(res == 600)
  739. WRITESPOOLBUF(pdevobj, cmdBeginDoc600.pCmdStr, cmdBeginDoc600.cbSize);
  740. else if(res == 300)
  741. WRITESPOOLBUF(pdevobj, cmdBeginDoc300.pCmdStr, cmdBeginDoc300.cbSize);
  742. else if(res == 150) // 150dpi means only image data is 150dpi
  743. WRITESPOOLBUF(pdevobj, cmdBeginDoc300.pCmdStr, cmdBeginDoc300.cbSize);
  744. else
  745. WRITESPOOLBUF(pdevobj, cmdBeginDoc300.pCmdStr, cmdBeginDoc300.cbSize);
  746. WRITESPOOLBUF(pdevobj, cmdSoftReset.pCmdStr, cmdSoftReset.cbSize);
  747. pOEM->f1stpage = TRUE;
  748. pOEM->fvertical = FALSE;
  749. pOEM->currentpapersize = -1;
  750. break;
  751. // NTRAID#NTBUG9-278671-2002/03/07-yasuho-: Finisher !work
  752. case OCD_BEGINDOC4_1200_CPCA2:
  753. pOEM->fCPCA2 = TRUE;
  754. /* FALL THRU */
  755. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: CPCA support
  756. case OCD_BEGINDOC4_1200_CPCA:
  757. pOEM->fCPCA = TRUE;
  758. /* FALL THRU */
  759. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  760. case OCD_BEGINDOC4_1200:
  761. pOEM->masterunit = 1200;
  762. // Adjust unitdiv
  763. pOEM->unitdiv = (SHORT)(pOEM->masterunit / pOEM->resolution);
  764. /* FALL THRU */
  765. case OCD_BEGINDOC4:
  766. pOEM->flips4 = TRUE;
  767. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: CPCA support
  768. if (pOEM->fCPCA)
  769. CPCAStart(pdevobj);
  770. else {
  771. if (!PJLStart(pdevobj))
  772. return -1;
  773. }
  774. goto setres;
  775. #ifdef LBP_2030
  776. case OCD_BEGINDOC4_2030_CPCA:
  777. pOEM->fCPCA = TRUE;
  778. /* FALL THRU */
  779. case OCD_BEGINDOC4_2030:
  780. pOEM->flips4 = TRUE;
  781. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: CPCA support
  782. if (pOEM->fCPCA)
  783. CPCAStart(pdevobj);
  784. #endif
  785. setres:
  786. res = pOEM->resolution;
  787. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  788. if(res == 1200)
  789. WRITESPOOLBUF(pdevobj, cmdBeginDoc1200.pCmdStr, cmdBeginDoc1200.cbSize);
  790. else if(res == 600)
  791. WRITESPOOLBUF(pdevobj, cmdBeginDoc600.pCmdStr, cmdBeginDoc600.cbSize);
  792. else if(res == 300){
  793. #ifdef LBP_2030
  794. // NTRAID#NTBUG9-195725-2002/03/07-yasuho-: !printed on 300dpi
  795. if( dwCmdCbID == OCD_BEGINDOC4_2030 || dwCmdCbID == OCD_BEGINDOC4_2030_CPCA){
  796. WRITESPOOLBUF(pdevobj, cmdBeginDoc4_2030.pCmdStr,cmdBeginDoc4_2030.cbSize);
  797. }else{
  798. #endif
  799. WRITESPOOLBUF(pdevobj, cmdBeginDoc3004.pCmdStr,cmdBeginDoc3004.cbSize);
  800. #ifdef LBP_2030
  801. }
  802. #endif
  803. } else {
  804. WRITESPOOLBUF(pdevobj, cmdBeginDoc600.pCmdStr, cmdBeginDoc600.cbSize);
  805. }
  806. // LIPS4 features for only 730
  807. // Set Smoothing, Dithering and Econo mode
  808. i = pOEM->fsmoothing;
  809. j = pOEM->fecono;
  810. k = pOEM->fdithering;
  811. if(i==DEVICESETTING && j==DEVICESETTING && k==DEVICESETTING)
  812. ; // do nothing
  813. else { // send \x1B[n;n;n'v
  814. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, NULL, 0,
  815. "\x1B[%d;%d;%d\'v", i, j, k)))
  816. return -1;
  817. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  818. }
  819. #ifndef LBP_2030
  820. WRITESPOOLBUF(pdevobj, cmdSoftReset.pCmdStr, cmdSoftReset.cbSize);
  821. #endif
  822. pOEM->f1stpage = TRUE;
  823. pOEM->fvertical = FALSE;
  824. pOEM->currentpapersize = -1;
  825. #ifdef LBP_2030
  826. // Send Color mode command
  827. if(pOEM->fcolor) // COLOR or COLOR_24BPP or COLOR_8BPP
  828. {
  829. WRITESPOOLBUF(pdevobj, cmdColorMode.pCmdStr, cmdColorMode.cbSize);
  830. }
  831. else
  832. { // Send Monochrome mode command
  833. WRITESPOOLBUF(pdevobj, cmdMonochrome.pCmdStr, cmdMonochrome.cbSize);
  834. }
  835. WRITESPOOLBUF(pdevobj, cmdSoftReset.pCmdStr, cmdSoftReset.cbSize);
  836. #endif
  837. break;
  838. #ifdef LIPS4C
  839. case OCD_BEGINDOC4C:
  840. pOEM->flips4C = TRUE;
  841. pOEM->f1stpage = TRUE;
  842. pOEM->fvertical = FALSE;
  843. pOEM->currentpapersize = -1;
  844. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  845. pOEM->masterunit = 360;
  846. WRITESPOOLBUF(pdevobj, cmdBeginDoc4C.pCmdStr, cmdBeginDoc4C.cbSize);
  847. break;
  848. #endif // LIPS4C
  849. // NTRAID#NTBUG9-304284-2002/03/07-yasuho-: Duplex isn't effective
  850. // Actually, BEGINDOC means StartJob.
  851. case OCD_STARTDOC:
  852. // pOEM->f1stpage = TRUE; // 1stpage means 1stdoc
  853. pOEM->fvertical = FALSE;
  854. pOEM->currentpapersize = -1;
  855. break;
  856. #ifdef LBP_2030
  857. case OCD_SETCOLORMODE:
  858. pOEM->fcolor = COLOR; // if not color mode, system doesn't path
  859. // here.
  860. pOEM->fplane = 0;
  861. pOEM->fplaneMax = 2;
  862. break;
  863. case OCD_SETCOLORMODE_24BPP:
  864. pOEM->fcolor = COLOR_24BPP;
  865. pOEM->fplane = 0;
  866. pOEM->fplaneMax = 0;
  867. break;
  868. case OCD_SETCOLORMODE_8BPP:
  869. pOEM->fcolor = COLOR_8BPP;
  870. pOEM->fplane = 0;
  871. pOEM->fplaneMax = 0;
  872. break;
  873. case OCD_ENDDOC4_2030:
  874. WRITESPOOLBUF(pdevobj, cmdEndDoc4.pCmdStr, cmdEndDoc4.cbSize);
  875. break;
  876. #endif
  877. case OCD_ENDDOC4:
  878. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: CPCA support
  879. if (pOEM->fCPCA)
  880. CPCAEnd(pdevobj, FALSE);
  881. else {
  882. WRITESPOOLBUF(pdevobj, cmdEndDoc4.pCmdStr, cmdEndDoc4.cbSize);
  883. PJLEnd(pdevobj);
  884. }
  885. break;
  886. case OCD_ENDPAGE:
  887. WRITESPOOLBUF(pdevobj, cmdEndPage.pCmdStr, cmdEndPage.cbSize);
  888. break;
  889. #if defined(LIPS4C) || defined(LBP_2030)
  890. // NTRAID#NTBUG-137462-2002/03/07-yasuho-: 'X000' is printed.
  891. case OCD_ENDDOC4C:
  892. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: CPCA support
  893. if (pOEM->fCPCA)
  894. CPCAEnd(pdevobj, TRUE);
  895. else
  896. WRITESPOOLBUF(pdevobj, cmdEndDoc4C.pCmdStr, cmdEndDoc4C.cbSize);
  897. break;
  898. // NTRAID#NTBUG9-398861-2002/03/07-yasuho-: Orientation does not changed.
  899. case OCD_SOURCE_AUTO:
  900. pOEM->source = 0;
  901. break;
  902. case OCD_SOURCE_MANUAL:
  903. pOEM->source = 1;
  904. break;
  905. // NTRAID#NTBUG9-293002-2002/03/07-yasuho-:
  906. // Features are different from H/W options.
  907. case OCD_SOURCE_CASSETTE1:
  908. case OCD_SOURCE_CASSETTE2:
  909. case OCD_SOURCE_CASSETTE3:
  910. case OCD_SOURCE_CASSETTE4:
  911. pOEM->source = (char)(dwCmdCbID - OCD_SOURCE_CASSETTE1 + 11);
  912. break;
  913. case OCD_SOURCE_ENVELOPE:
  914. pOEM->source = 5;
  915. break;
  916. case OCD_BEGINPAGE4C:
  917. if (pOEM->f1stpage == FALSE)
  918. WRITESPOOLBUF(pdevobj, cmdEndPicture.pCmdStr, cmdEndPicture.cbSize);
  919. // NTRAID#NTBUG9-399861-2002/03/07-yasuho-: Orientation does not changed.
  920. // NTRAID#NTBUG9-293002-2002/03/07-yasuho-:
  921. // Features are different from H/W options.
  922. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, NULL, 0,
  923. cmdPaperSource, pOEM->source)))
  924. return -1;
  925. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  926. // Thru away
  927. #endif
  928. case OCD_BEGINPAGE:
  929. // Do Nothing
  930. if (!(pOEM->fVectCmd & VFLAG_INIT_DONE))
  931. {
  932. pOEM->fVectCmd |= VFLAG_PEN_NULL| VFLAG_BRUSH_NULL | VFLAG_INIT_DONE;
  933. pOEM->sBrushStyle = 0;
  934. pOEM->sPenStyle = 0;
  935. }
  936. pOEM->bLogicStyle = INIT;
  937. // NTRAID#NTBUG-120638-2002/03/07-yasuho-: image shift to right
  938. pOEM->ptCurrent.x = pOEM->ptInLine.x = 0;
  939. pOEM->ptCurrent.y = pOEM->ptInLine.y = 0;
  940. pOEM->stringwidth = 0;
  941. // NTRAID#NTBUG-289488-2002/03/07-yasuho-:
  942. // Vertical font doesn't rotated on 2nd page.
  943. pOEM->fvertical = FALSE;
  944. pOEM->CharOrientation[0] = pOEM->CharOrientation[1] = INIT;
  945. pOEM->CharOrientation[2] = pOEM->CharOrientation[3] = INIT;
  946. break;
  947. case OCD_PORTRAIT:
  948. case OCD_LANDSCAPE:
  949. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: CPCA support
  950. if (pOEM->fCPCA) {
  951. // NTRAID#NTBUG9-501162-2002/03/07-yasuho-: Collate does not work
  952. // Set number of copies
  953. if (pOEM->sorttype != SORTTYPE_SORT && pOEM->collate != COLLATE_ON)
  954. i = pOEM->copies;
  955. else
  956. i = 1;
  957. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, NULL, 0,
  958. "\x1B[%dv", i)))
  959. return -1;
  960. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  961. }
  962. // Select Paper Size
  963. if (!SelectPaperSize(pdevobj, pOEM->papersize))
  964. return -1;
  965. // NTRAID#NTBUG-185762-2002/03/07-yasuho-: Tilde isn't printed
  966. // #ifndef LIPS4
  967. // If first page, the registration data would be downloaded
  968. // It doesn't need on LIPS4
  969. if(pOEM->f1stpage == TRUE && pOEM->flips4 == FALSE)
  970. // if(pOEM->f1stpage == TRUE)
  971. {
  972. // Download Graphic Set Registration to keep the conpatibility
  973. // against Canon's 3.1 driver
  974. // "\x1b[743;1796;30;0;32;127;.\x7dIBM819"
  975. // It means to register Windows character set for SBCS Device
  976. // fonts.
  977. #ifdef LIPS4C
  978. if (pOEM->flips4C)
  979. WRITESPOOLBUF(pdevobj, cmdGSETREGST4C.pCmdStr, cmdGSETREGST4C.cbSize);
  980. else
  981. WRITESPOOLBUF(pdevobj, cmdGSETREGST.pCmdStr, cmdGSETREGST.cbSize);
  982. #else
  983. WRITESPOOLBUF(pdevobj, cmdGSETREGST.pCmdStr, cmdGSETREGST.cbSize);
  984. #endif // LIPS4C
  985. // Download SBCS physical device fontface from Dutch-Roman(7)
  986. // ZapfCalligraphic-BoldItalic(41)
  987. // Between the fontfaces, put \x00, and at the end of face,
  988. // put \x00 x 2
  989. for(i=0; i<MaxSBCSNumber; ++i)
  990. { // download all SBCS (ANSI) facename
  991. // (without Symbol, Dingbats, DBCS)
  992. WRITESPOOLBUF(pdevobj, "\x00", 1); // put 0 at top of facename
  993. WRITESPOOLBUF(pdevobj, PSBCSList[i].facename, PSBCSList[i].len);
  994. }
  995. // and Graphic set registration command(REGDataSize = 193)
  996. #ifdef LIPS4C
  997. if(pOEM->flips4C)
  998. WRITESPOOLBUF(pdevobj, GrxData4C, REGDataSize4C);
  999. else
  1000. WRITESPOOLBUF(pdevobj, GrxData, REGDataSize);
  1001. #else
  1002. WRITESPOOLBUF(pdevobj, GrxData, REGDataSize);
  1003. #endif // LIPS4C
  1004. }
  1005. // #endif // !LIPS4
  1006. // LIPS4 features
  1007. if(pOEM->f1stpage == TRUE && pOEM->flips4 == TRUE)
  1008. {
  1009. // NTRAID#NTBUG9-254925-2002/03/07-yasuho-: CUSTOM papers.
  1010. // N x Pages support
  1011. switch (pOEM->nxpages) {
  1012. default:
  1013. WRITESPOOLBUF(pdevobj, cmdx1Page.pCmdStr, cmdx1Page.cbSize);
  1014. break;
  1015. case OCD_PAPERQUALITY_2XL:
  1016. k = 21;
  1017. goto xnpagecom;
  1018. case OCD_PAPERQUALITY_2XR:
  1019. k = 22;
  1020. goto xnpagecom;
  1021. case OCD_PAPERQUALITY_4XL:
  1022. k = 41;
  1023. goto xnpagecom;
  1024. case OCD_PAPERQUALITY_4XR:
  1025. k = 42;
  1026. goto xnpagecom;
  1027. xnpagecom:
  1028. i = pOEM->papersize - PAPER_FIRST;
  1029. if (FAILED(StringCchPrintfExA(ch, sizeof ch, &pch, NULL, 0,
  1030. cmdxnPageX, k, PaperIDs[i])))
  1031. return -1;
  1032. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  1033. break;
  1034. }
  1035. // Duplexing support
  1036. if(pOEM->fduplex == FALSE)
  1037. {
  1038. WRITESPOOLBUF(pdevobj, cmdDuplexOff.pCmdStr, cmdDuplexOff.cbSize);
  1039. }
  1040. else
  1041. {
  1042. WRITESPOOLBUF(pdevobj, cmdDuplexOn.pCmdStr, cmdDuplexOn.cbSize);
  1043. if(pOEM->fduplextype == VERT) // Long edge
  1044. WRITESPOOLBUF(pdevobj, cmdDupLong.pCmdStr, cmdDupLong.cbSize);
  1045. else
  1046. WRITESPOOLBUF(pdevobj, cmdDupShort.pCmdStr,cmdDupShort.cbSize);
  1047. }
  1048. }
  1049. // NTRAID#NTBUG-228625-2002/03/07-yasuho-: Stacker support
  1050. // NTRAID#NTBUG9-293002-2002/03/07-yasuho-:
  1051. // Features are different from H/W options.
  1052. // These command does no longer used.
  1053. // "\x1B[12;{tray#};{faceup}~"
  1054. // We use PJL command instead.
  1055. // Start Font & Graphic list
  1056. // Send "\x1B[0&\x7D" : Enter Vector Mode (VDM)
  1057. WRITESPOOLBUF(pdevobj, cmdBeginVDM.pCmdStr, cmdBeginVDM.cbSize);
  1058. // Download phisical font list and graphic set list
  1059. // Send "\x20<" : Start Font List
  1060. WRITESPOOLBUF(pdevobj, cmdFontList.pCmdStr, cmdFontList.cbSize);
  1061. // All Physical fonts which can be supported in LIPS are downloaded
  1062. // <p facename><separater><p facename2><separater>....
  1063. // ...<p facenameN><\x1e (end of font list)>
  1064. for(i=0; i<MaxFontNumber-1; ++i)
  1065. { // download all fonts which can be supported in LIPS
  1066. WRITESPOOLBUF(pdevobj, PFontList[i].facename, PFontList[i].len);
  1067. WRITESPOOLBUF(pdevobj, cmdListSeparater.pCmdStr, cmdListSeparater.cbSize);
  1068. }
  1069. WRITESPOOLBUF(pdevobj, PFontList[i].facename, PFontList[i].len);
  1070. // End of font list, send \x1e
  1071. WRITESPOOLBUF(pdevobj, "\x1E", 1); // put 0x1e at end of facename
  1072. // Initialize font height
  1073. // When downloading font list, character heigh will be initialized.
  1074. pOEM->tblPreviousFont.FontHeight = INIT;
  1075. // All graphic set are downloaded
  1076. // Send "\x20;" : Start Graphics set List
  1077. WRITESPOOLBUF(pdevobj, cmdGrxList.pCmdStr, cmdGrxList.cbSize);
  1078. // All Graphics sets which can be supported in LIPS are downloaded
  1079. // <graphics set1><separater><graphics set2><separater>....
  1080. // ...<graphics setN><\x1e (end of font list)>
  1081. // NTRAID#NTBUG-185762-2002/03/07-yasuho-: Tilde isn't print
  1082. #ifdef LIPS4C
  1083. if (pOEM->flips4C)
  1084. pGS = GrxSetL4C;
  1085. else
  1086. #endif
  1087. #ifdef LIPS4
  1088. if (pOEM->flips4)
  1089. pGS = GrxSetL4;
  1090. else
  1091. #endif
  1092. pGS = GrxSetL3;
  1093. for(i=0; i<MaxGrxSetNumber-1; ++i, ++pGS)
  1094. { // All Graphics sets which can be supported in LIPS are downloaded
  1095. WRITESPOOLBUF(pdevobj, pGS->grxsetname, pGS->len);
  1096. WRITESPOOLBUF(pdevobj, cmdListSeparater.pCmdStr, cmdListSeparater.cbSize);
  1097. }
  1098. WRITESPOOLBUF(pdevobj, pGS->grxsetname, pGS->len);
  1099. res = pOEM->resolution;
  1100. // Begin picture, set Scaling mode (in dots), Begin picture body
  1101. // Send "\x1E#\x1E!0#\x1E$"
  1102. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  1103. if(res == 1200)
  1104. {
  1105. WRITESPOOLBUF(pdevobj, cmdBeginPicture1200.pCmdStr
  1106. , cmdBeginPicture1200.cbSize);
  1107. }
  1108. else if(res == 600)
  1109. {
  1110. WRITESPOOLBUF(pdevobj, cmdBeginPicture600.pCmdStr
  1111. , cmdBeginPicture600.cbSize);
  1112. }
  1113. #ifdef LIPS4C
  1114. else if(res == 360)
  1115. {
  1116. WRITESPOOLBUF(pdevobj, cmdBeginPicture4C.pCmdStr
  1117. , cmdBeginPicture4C.cbSize);
  1118. }
  1119. #endif // LIPS4C
  1120. else
  1121. {
  1122. WRITESPOOLBUF(pdevobj, cmdBeginPicture.pCmdStr
  1123. , cmdBeginPicture.cbSize);
  1124. }
  1125. #ifdef LBP_2030
  1126. // Send Color Selection Mode command
  1127. if(pOEM->fcolor)
  1128. {
  1129. if (pOEM->fcolor == COLOR_8BPP)
  1130. {
  1131. // We use Color Index for a text color [sueyas]
  1132. // Send "\x1E!10"
  1133. WRITESPOOLBUF(pdevobj, cmdColorIndex.pCmdStr, cmdColorIndex.cbSize);
  1134. }
  1135. else
  1136. {
  1137. // We use RGB presentation
  1138. // Send "\x1E!11"
  1139. WRITESPOOLBUF(pdevobj, cmdColorRGB.pCmdStr, cmdColorRGB.cbSize);
  1140. }
  1141. }
  1142. // Start VDM mode (in dots), Begin picture body
  1143. // Send "\x1E$"
  1144. WRITESPOOLBUF(pdevobj, cmdEnterPicture.pCmdStr, cmdEnterPicture.cbSize);
  1145. #endif
  1146. // If needed, Send VDC Extent
  1147. // Specify a unit of text height (in dots), text clip mode (stroke)
  1148. // Send "\x1E"\x7D#1\x1EU2\x1E"
  1149. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  1150. if(res == 1200)
  1151. {
  1152. WRITESPOOLBUF(pdevobj, cmdTextClip1200.pCmdStr, cmdTextClip1200.cbSize);
  1153. }
  1154. else if(res == 600)
  1155. {
  1156. WRITESPOOLBUF(pdevobj, cmdTextClip600.pCmdStr, cmdTextClip600.cbSize);
  1157. }
  1158. #ifdef LIPS4C
  1159. else if (res == 360)
  1160. {
  1161. WRITESPOOLBUF(pdevobj, cmdTextClip4C.pCmdStr, cmdTextClip4C.cbSize);
  1162. }
  1163. #endif // LIPS4C
  1164. else
  1165. {
  1166. WRITESPOOLBUF(pdevobj, cmdTextClip.pCmdStr, cmdTextClip.cbSize);
  1167. }
  1168. // LIPS4 features
  1169. // Send Poly line
  1170. if(pOEM->flips4 == TRUE) {
  1171. // send DMe80\x1E or DMe81\x1E
  1172. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  1173. pch = ch;
  1174. if (&pch[4] > pend) return -1;
  1175. *pch++ = 'D';
  1176. *pch++ = 'M';
  1177. if (!VFormat(res, &pch, pend)) return -1; // res
  1178. *pch++ = (pOEM->nxpages == DEVICESETTING) ? '0' : '1';
  1179. *pch++ = 0x1E;
  1180. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  1181. }
  1182. // As downloading font list and graphics list, font and graphics
  1183. // table is initilized. We have to specifiy font and graphics table
  1184. // each page except 1st page.
  1185. if (pOEM->f1stpage == TRUE) {
  1186. pOEM->f1stpage = FALSE;
  1187. }
  1188. else {
  1189. if (!SendFontGrxID(pdevobj))
  1190. return -1;
  1191. }
  1192. if (!SetPenAndBrush(pdevobj, SET_PEN))
  1193. return -1;
  1194. // end of orientation and begin doc
  1195. break;
  1196. case OCD_PRN_DIRECTION:
  1197. if (dwCount < 1 || !pdwParams)
  1198. break;
  1199. pOEM->Escapement = (short)*pdwParams % 360;
  1200. break;
  1201. case OCD_BOLD_ON:
  1202. pOEM->fbold = TRUE;
  1203. break;
  1204. case OCD_BOLD_OFF:
  1205. pOEM->fbold = FALSE;
  1206. break;
  1207. case OCD_ITALIC_ON:
  1208. pOEM->fitalic = TRUE;
  1209. break;
  1210. case OCD_ITALIC_OFF:
  1211. pOEM->fitalic = FALSE;
  1212. break;
  1213. // case OCD_UNDERLINE_ON:
  1214. // case OCD_UNDERLINE_OFF:
  1215. // case OCD_DOUBLEUNDERLINE_ON:
  1216. // case OCD_DOUBLEUNDERLINE_OFF:
  1217. // case OCD_STRIKETHRU_ON:
  1218. // case OCD_STRIKETHRU_OFF:
  1219. case OCD_WHITE_TEXT_ON:
  1220. pOEM->fwhitetext = TRUE;
  1221. break;
  1222. case OCD_WHITE_TEXT_OFF:
  1223. pOEM->fwhitetext = FALSE;
  1224. break;
  1225. case OCD_SINGLE_BYTE:
  1226. pOEM->fdoublebyte = FALSE;
  1227. break;
  1228. case OCD_DOUBLE_BYTE:
  1229. pOEM->fdoublebyte = TRUE;
  1230. break;
  1231. case OCD_VERT_ON:
  1232. pOEM->fvertical = TRUE;
  1233. break;
  1234. case OCD_VERT_OFF:
  1235. pOEM->fvertical = FALSE;
  1236. break;
  1237. case CUR_XM_ABS:
  1238. if (dwCount < 1 || !pdwParams)
  1239. break;
  1240. if (!pOEM->unitdiv) return -1;
  1241. pOEM->ptCurrent.x = pOEM->ptInLine.x = (short)*pdwParams
  1242. / (pOEM->unitdiv);
  1243. pOEM->printedchars = 0;
  1244. pOEM->stringwidth = 0;
  1245. return (INT)(*pdwParams); // for NT5
  1246. case CUR_YM_ABS:
  1247. if (dwCount < 1 || !pdwParams)
  1248. break;
  1249. if (!pOEM->unitdiv) return -1;
  1250. pOEM->ptCurrent.y = pOEM->ptInLine.y = (short)*pdwParams
  1251. / (pOEM->unitdiv);
  1252. // NTRAID#NTBUG9-120640-2002/03/07-yasuho-:
  1253. // Some characters shifted to right
  1254. // Because this driver was set AT_GRXDATA_ORIGIN on CursorXAfterSend-
  1255. // BlockData. Some of cases unidrv will only sent YMove command.
  1256. // So it should be clear when any cursor move command was sent.
  1257. // NTRAID#NTBUG-150061-2002/03/08-yasuho-:
  1258. // Subscript fonts are overlapped.
  1259. // Revised for NTBUG9-120640. NTBUG9-120640 was fixed by GDI and
  1260. // this fix has some side effects. Therefore, should be removed.
  1261. // pOEM->stringwidth = 0;
  1262. return (INT)(*pdwParams); // for NT5
  1263. case CUR_XM_REL:
  1264. if (dwCount < 1 || !pdwParams)
  1265. break;
  1266. if (!pOEM->unitdiv) return -1;
  1267. pOEM->ptCurrent.x = pOEM->ptInLine.x += ((short)*pdwParams
  1268. / (pOEM->unitdiv));
  1269. // NTRAID#NTBUG9-120640-2002/03/07-yasuho-:
  1270. // Some characters shifted to right
  1271. pOEM->stringwidth = 0;
  1272. return (INT)(*pdwParams); // for NT5
  1273. case CUR_YM_REL:
  1274. if (dwCount < 1 || !pdwParams)
  1275. break;
  1276. if (!pOEM->unitdiv) return -1;
  1277. pOEM->ptCurrent.y = pOEM->ptInLine.y += ((short)*pdwParams
  1278. / (pOEM->unitdiv));
  1279. // NTRAID#NTBUG9-120640-2002/03/07-yasuho-:
  1280. // Some characters shifted to right
  1281. pOEM->stringwidth = 0;
  1282. return (INT)(*pdwParams); // for NT5
  1283. // NTRAID#NTBUG9-568220-2002/03/07-yasuho-: XY_ABS: Remove the dead code
  1284. case CUR_CR:
  1285. // Unidrv needs to send CR in order to set x dimension to 0.
  1286. pOEM->ptCurrent.x = pOEM->ptInLine.x = 0;
  1287. pOEM->printedchars = 0;
  1288. pOEM->stringwidth = 0;
  1289. break;
  1290. // LIPS4 Features
  1291. // Duplexing support
  1292. case OCD_DUPLEX_ON:
  1293. pOEM->fduplex = TRUE;
  1294. break;
  1295. case OCD_DUPLEX_VERT:
  1296. pOEM->fduplex = TRUE;
  1297. pOEM->fduplextype = VERT;
  1298. break;
  1299. case OCD_DUPLEX_HORZ:
  1300. pOEM->fduplex = TRUE;
  1301. pOEM->fduplextype = HORZ;
  1302. break;
  1303. // N Pages Support (2x, 4x), orders
  1304. case OCD_PAPERQUALITY_2XL:
  1305. pOEM->nxpages = OCD_PAPERQUALITY_2XL;
  1306. break;
  1307. case OCD_PAPERQUALITY_2XR:
  1308. pOEM->nxpages = OCD_PAPERQUALITY_2XR;
  1309. break;
  1310. case OCD_PAPERQUALITY_4XL:
  1311. pOEM->nxpages = OCD_PAPERQUALITY_4XL;
  1312. break;
  1313. case OCD_PAPERQUALITY_4XR:
  1314. pOEM->nxpages = OCD_PAPERQUALITY_4XR;
  1315. break;
  1316. // Smoothing support
  1317. case OCD_TEXTQUALITY_ON:
  1318. pOEM->fsmoothing = 2; // ON should be 2
  1319. break;
  1320. case OCD_TEXTQUALITY_OFF:
  1321. pOEM->fsmoothing = 1; // OFF should be 1
  1322. break;
  1323. // Toner economy mode
  1324. case OCD_PRINTDENSITY_ON:
  1325. pOEM->fecono = 2; // ON should be 2
  1326. break;
  1327. case OCD_PRINTDENSITY_OFF:
  1328. pOEM->fecono = 1; // OFF should be 1
  1329. break;
  1330. // Dithering mode
  1331. case OCD_IMAGECONTROL_ON:
  1332. pOEM->fdithering = 2; // ON should be 2
  1333. break;
  1334. case OCD_IMAGECONTROL_OFF:
  1335. pOEM->fdithering = 1; // OFF should be 1
  1336. break;
  1337. // NTRAID#NTBUG9-568220-2002/03/07-yasuho-: Remove the dead code
  1338. // Vector command.
  1339. // NTRAID#NTBUG9-568220-2002/03/07-yasuho-: Remove the dead code
  1340. // Support Color Bold
  1341. // NTRAID#NTBUG9-98276-2002/03/08-yasuho-: Support Color Bold
  1342. // Select 8 colors directly.
  1343. case OCD_SELECTBLACK:
  1344. r = 0;
  1345. g = 0;
  1346. b = 0;
  1347. goto selcolor;
  1348. case OCD_SELECTBLUE:
  1349. r = 0;
  1350. g = 0;
  1351. b = 1000;
  1352. goto selcolor;
  1353. case OCD_SELECTGREEN:
  1354. r = 0;
  1355. g = 1000;
  1356. b = 0;
  1357. goto selcolor;
  1358. case OCD_SELECTCYAN:
  1359. r = 0;
  1360. g = 1000;
  1361. b = 1000;
  1362. goto selcolor;
  1363. case OCD_SELECTRED:
  1364. r = 1000;
  1365. g = 0;
  1366. b = 0;
  1367. goto selcolor;
  1368. case OCD_SELECTMAGENTA:
  1369. r = 1000;
  1370. g = 0;
  1371. b = 1000;
  1372. goto selcolor;
  1373. case OCD_SELECTYELLOW:
  1374. r = 1000;
  1375. g = 1000;
  1376. b = 0;
  1377. goto selcolor;
  1378. case OCD_SELECTWHITE:
  1379. r = 1000;
  1380. g = 1000;
  1381. b = 1000;
  1382. goto selcolor;
  1383. // Select full color.
  1384. case OCD_SELECTCOLOR:
  1385. if (dwCount < 3 || !pdwParams)
  1386. break;
  1387. r = (pdwParams[0] * 200L) / 51L;
  1388. g = (pdwParams[1] * 200L) / 51L;
  1389. b = (pdwParams[2] * 200L) / 51L;
  1390. selcolor:
  1391. pch = ch;
  1392. if (&pch[2] > pend) return -1;
  1393. *pch++ = 'X'; // Select font color
  1394. if (!VFormat(r, &pch, pend)) return -1;
  1395. if (!VFormat(g, &pch, pend)) return -1;
  1396. if (!VFormat(b, &pch, pend)) return -1;
  1397. *pch++ = '\x1E';
  1398. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  1399. // Remember the current color
  1400. pOEM->CurColor.dwRed = r;
  1401. pOEM->CurColor.dwGreen = g;
  1402. pOEM->CurColor.dwBlue = b;
  1403. break;
  1404. // Select 256 color.
  1405. case OCD_SELECTPALETTE:
  1406. if (dwCount < 1 || !pdwParams)
  1407. break;
  1408. pch = ch;
  1409. if (&pch[2] > pend) return -1;
  1410. *pch++ = 'X'; // Select font color
  1411. if (!VFormat(pdwParams[0], &pch, pend)) return -1; // Palette index
  1412. *pch++ = '\x1E';
  1413. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  1414. // Remember the current palette index
  1415. pOEM->dwCurIndex = pdwParams[0];
  1416. break;
  1417. // NTRAID#NTBUG-185185-2002/03/07-yasuho-: Support RectFill
  1418. case OCD_SETRECTWIDTH:
  1419. if (dwCount < 1 || !pdwParams)
  1420. break;
  1421. if (!pOEM->unitdiv) return -1;
  1422. pOEM->RectWidth = *pdwParams / pOEM->unitdiv;
  1423. break;
  1424. case OCD_SETRECTHEIGHT:
  1425. if (dwCount < 1 || !pdwParams)
  1426. break;
  1427. if (!pOEM->unitdiv) return -1;
  1428. pOEM->RectHeight = *pdwParams / pOEM->unitdiv;
  1429. break;
  1430. case OCD_RECTWHITEFILL:
  1431. i = 0x29;
  1432. goto fill;
  1433. case OCD_RECTBLACKFILL:
  1434. i = 0x31;
  1435. goto fill;
  1436. fill:
  1437. {
  1438. long x, y;
  1439. pch = ch;
  1440. if (pOEM->bLogicStyle != OVER_MODE) {
  1441. if (&pch[4] > pend) return -1;
  1442. *pch++ = '\x7D';
  1443. *pch++ = 'H';
  1444. *pch++ = '0';
  1445. *pch++ = '\x1E';
  1446. pOEM->bLogicStyle = OVER_MODE;
  1447. }
  1448. if (&pch[7] > pend) return -1;
  1449. *pch++ = 'I'; // specify fill pattern
  1450. *pch++ = (BYTE)i;
  1451. *pch++ = 0x30;
  1452. *pch++ = '\x1E';
  1453. *pch++ = '\x7D';
  1454. *pch++ = ':'; // fill rectangle
  1455. x = pOEM->ptCurrent.x;
  1456. if (!VFormat(x, &pch, pend)) return -1;
  1457. x += pOEM->RectWidth;
  1458. if (!VFormat(x, &pch, pend)) return -1;
  1459. y = pOEM->ptCurrent.y;
  1460. if (!VFormat(y, &pch, pend)) return -1;
  1461. y += pOEM->RectHeight;
  1462. if (!VFormat(y, &pch, pend)) return -1;
  1463. *pch++ = '\x1E';
  1464. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  1465. }
  1466. break;
  1467. // NTRAID#NTBUG-228625-2002/03/07-yasuho-: Stacker support
  1468. // NTRAID#NTBUG9-293002-2002/03/07-yasuho-:
  1469. // Features are different from H/W options.
  1470. case OCD_TRAY_AUTO:
  1471. pOEM->tray = 0;
  1472. break;
  1473. case OCD_TRAY_DEFAULT:
  1474. pOEM->tray = 100;
  1475. break;
  1476. case OCD_TRAY_SUBTRAY:
  1477. pOEM->tray = 101;
  1478. break;
  1479. case OCD_TRAY_BIN1:
  1480. case OCD_TRAY_BIN2:
  1481. case OCD_TRAY_BIN3:
  1482. case OCD_TRAY_BIN4:
  1483. case OCD_TRAY_BIN5:
  1484. case OCD_TRAY_BIN6:
  1485. case OCD_TRAY_BIN7:
  1486. case OCD_TRAY_BIN8:
  1487. case OCD_TRAY_BIN9:
  1488. case OCD_TRAY_BIN10:
  1489. pOEM->tray = (char)(dwCmdCbID - OCD_TRAY_BIN1 + 1);
  1490. break;
  1491. case OCD_JOBOFFSET:
  1492. pOEM->method = METHOD_JOBOFFSET;
  1493. break;
  1494. case OCD_STAPLE:
  1495. pOEM->method = METHOD_STAPLE;
  1496. break;
  1497. case OCD_FACEUP:
  1498. pOEM->method = METHOD_FACEUP;
  1499. break;
  1500. case OCD_TOPLEFT:
  1501. case OCD_TOPCENTER:
  1502. case OCD_TOPRIGHT:
  1503. case OCD_MIDLEFT:
  1504. case OCD_MIDCENTER:
  1505. case OCD_MIDRIGHT:
  1506. case OCD_BOTLEFT:
  1507. case OCD_BOTCENTER:
  1508. case OCD_BOTRIGHT:
  1509. pOEM->staple = (char)(dwCmdCbID - OCD_TOPLEFT);
  1510. break;
  1511. // Support DRC
  1512. case OCD_SETBMPWIDTH:
  1513. if (dwCount < 1 || !pdwParams)
  1514. break;
  1515. pOEM->dwBmpWidth = *pdwParams;
  1516. break;
  1517. case OCD_SETBMPHEIGHT:
  1518. if (dwCount < 1 || !pdwParams)
  1519. break;
  1520. pOEM->dwBmpHeight = *pdwParams;
  1521. break;
  1522. // NTRAID#NTBUG9-172276-2002/03/07-yasuho-: Sorter support
  1523. case OCD_SORT:
  1524. pOEM->sorttype = SORTTYPE_SORT;
  1525. break;
  1526. case OCD_STACK:
  1527. pOEM->sorttype = SORTTYPE_STACK;
  1528. break;
  1529. // NTRAID#NTBUG9-293002-2002/03/07-yasuho-:
  1530. // Features are different from H/W options.
  1531. case OCD_GROUP:
  1532. pOEM->sorttype = SORTTYPE_GROUP;
  1533. break;
  1534. case OCD_SORT_STAPLE:
  1535. pOEM->sorttype = SORTTYPE_STAPLE;
  1536. break;
  1537. case OCD_COPIES:
  1538. if (dwCount < 1 || !pdwParams)
  1539. break;
  1540. pOEM->copies = (WORD)pdwParams[0];
  1541. break;
  1542. // NTRAID#NTBUG9-293002-2002/03/07-yasuho-:
  1543. // Features are different from H/W options.
  1544. case OCD_STARTBIN0:
  1545. case OCD_STARTBIN1:
  1546. case OCD_STARTBIN2:
  1547. case OCD_STARTBIN3:
  1548. case OCD_STARTBIN4:
  1549. case OCD_STARTBIN5:
  1550. case OCD_STARTBIN6:
  1551. case OCD_STARTBIN7:
  1552. case OCD_STARTBIN8:
  1553. case OCD_STARTBIN9:
  1554. case OCD_STARTBIN10:
  1555. pOEM->startbin = (char)(dwCmdCbID - OCD_STARTBIN0);
  1556. break;
  1557. // NTRAID#NTBUG9-501162-2002/03/07-yasuho-: Collate does not work
  1558. case OCD_COLLATE_ON:
  1559. pOEM->collate = COLLATE_ON;
  1560. break;
  1561. case OCD_COLLATE_OFF:
  1562. pOEM->collate = COLLATE_OFF;
  1563. break;
  1564. }
  1565. return 0;
  1566. }
  1567. /*
  1568. * OEMSendFontCmd
  1569. */
  1570. VOID APIENTRY
  1571. OEMSendFontCmd(
  1572. PDEVOBJ pdevobj,
  1573. PUNIFONTOBJ pUFObj,
  1574. PFINVOCATION pFInv)
  1575. {
  1576. PGETINFO_STDVAR pSV;
  1577. #define FI_HEIGHT (pSV->StdVar[0].lStdVariable)
  1578. #define FI_WIDTH (pSV->StdVar[1].lStdVariable)
  1579. #define FI_TEXTYRES (pSV->StdVar[2].lStdVariable)
  1580. #define FI_TEXTXRES (pSV->StdVar[3].lStdVariable)
  1581. PBYTE pubCmd;
  1582. PIFIMETRICS pIFI;
  1583. DWORD lres, lheight, lvert, dwGetInfo;
  1584. PLIPSPDEV pOEM;
  1585. BYTE fontid, tid;
  1586. WORD firstchar, lastchar, unitdiv;
  1587. WORD i, ii;
  1588. DWORD adwStdVariable[2+2*4];
  1589. BYTE ch[CCHMAXCMDLEN];
  1590. PBYTE pch;
  1591. PBYTE pend = &ch[CCHMAXCMDLEN];
  1592. // DbgPrint(DLLTEXT("OEMSendFontCmd() entry.\r\n"));
  1593. pubCmd = pFInv->pubCommand;
  1594. if (pubCmd == NULL) {
  1595. // DbgPrint(DLLTEXT("Invalid SelectFont command.\r\n"));
  1596. return;
  1597. }
  1598. pIFI = pUFObj->pIFIMetrics;
  1599. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  1600. // NTRAID#NTBUG9-568220-2002/03/07-yasuho-: Remove the dead code
  1601. // 2/5/98 takashim (FONTOBJ not always available)
  1602. //
  1603. // Get standard variables.
  1604. //
  1605. pSV = (PGETINFO_STDVAR)adwStdVariable;
  1606. pSV->dwSize = sizeof(GETINFO_STDVAR) + 2 * sizeof(DWORD) * (4 - 1);
  1607. pSV->dwNumOfVariable = 4;
  1608. pSV->StdVar[0].dwStdVarID = FNT_INFO_FONTHEIGHT;
  1609. pSV->StdVar[1].dwStdVarID = FNT_INFO_FONTWIDTH;
  1610. pSV->StdVar[2].dwStdVarID = FNT_INFO_TEXTYRES;
  1611. pSV->StdVar[3].dwStdVarID = FNT_INFO_TEXTXRES;
  1612. dwGetInfo = pSV->dwSize;
  1613. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_STDVARIABLE, pSV,
  1614. dwGetInfo, &dwGetInfo)) {
  1615. // DbgPrint(DLLTEXT("UFO_GETINFO_STDVARIABLE failed.\r\n"));
  1616. return;
  1617. }
  1618. lres = pOEM->resolution;
  1619. // NTRAID#NTBUG-120640-2002/03/07-yasuho-:
  1620. // 150dpi means only image data is 150dpi
  1621. // if(lres == 150)
  1622. // lres = 300;
  1623. // use 1/300 inch unit, which should have already been set.
  1624. // convert font height to 1/300 inch units
  1625. lvert = FI_TEXTYRES;
  1626. if (!pOEM->unitdiv) return;
  1627. lheight = FI_HEIGHT / pOEM->unitdiv;
  1628. if (!lvert) return;
  1629. pOEM->tblCurrentFont.FontHeight = (short)((lheight
  1630. * lres + lvert/2) / lvert);
  1631. //pOEM->tblCurrentFont.FontHeight = (short)(((lheight
  1632. // - (long)(lpFont->dfInternalLeading)) * lres + lvert/2) / lvert);
  1633. pOEM->tblCurrentFont.FontWidth = (short)(FI_WIDTH / pOEM->unitdiv);
  1634. // lpLips->tblCurrentFont.MaxWidth = (short)(lpFont->dfMaxWidth);
  1635. pOEM->tblCurrentFont.MaxWidth = (short)(pIFI->fwdAveCharWidth * 2);
  1636. pOEM->tblCurrentFont.AvgWidth = (short)(pIFI->fwdAveCharWidth);
  1637. if (!(pIFI->fwdWinAscender + pIFI->fwdWinDescender)) return;
  1638. // NTRAID#NTBUG-120474-2002/03/07-yasuho-: font shift to right
  1639. pOEM->tblCurrentFont.Ascent = (short)(pOEM->tblCurrentFont.FontHeight
  1640. * pIFI->fwdWinAscender / (pIFI->fwdWinAscender +
  1641. pIFI->fwdWinDescender));
  1642. // Obtain X/Y size ratio and calculate horizontal
  1643. // expansion factor (supporting non-square scaling.)
  1644. if (!FI_HEIGHT || !FW_IFI(pIFI)) return;
  1645. pOEM->tblCurrentFont.Stretch = (SHORT)(100
  1646. * FI_WIDTH * FH_IFI(pIFI) / FI_HEIGHT / FW_IFI(pIFI));
  1647. // Get font ID
  1648. fontid = pubCmd[0]; // the first character means font Id
  1649. if(fontid < FirstLogicalFont)
  1650. return;
  1651. pch = ch;
  1652. // Send font, grx ids x 4 x 2
  1653. tid = LFontList[fontid - FirstLogicalFont][0];
  1654. if (&pch[2] > pend) return;
  1655. // Font ID G0
  1656. *pch++ = 'T';
  1657. if (!VFormat(tid, &pch, pend)) return;
  1658. *pch++ = 0x1E;
  1659. pOEM->curFontGrxIds[0] = tid;
  1660. tid = LFontList[fontid - FirstLogicalFont][1];
  1661. if (&pch[2] > pend) return;
  1662. // Font ID G1
  1663. *pch++ = 'm';
  1664. if (!VFormat(tid, &pch, pend)) return;
  1665. *pch++ = 0x1E;
  1666. pOEM->curFontGrxIds[1] = tid;
  1667. tid = LFontList[fontid - FirstLogicalFont][2];
  1668. if (&pch[2] > pend) return;
  1669. // Font ID G2
  1670. *pch++ = 'n';
  1671. if (!VFormat(tid, &pch, pend)) return;
  1672. *pch++ = 0x1E;
  1673. pOEM->curFontGrxIds[2] = tid;
  1674. tid = LFontList[fontid - FirstLogicalFont][3];
  1675. if (&pch[2] > pend) return;
  1676. // Font ID G3
  1677. *pch++ = 'o';
  1678. if (!VFormat(tid, &pch, pend)) return;
  1679. *pch++ = 0x1E;
  1680. pOEM->curFontGrxIds[3] = tid;
  1681. tid = LFontList[fontid - FirstLogicalFont][4];
  1682. if (&pch[2] > pend) return;
  1683. // Grx ID G0
  1684. *pch++ = ']';
  1685. if (!VFormat(tid, &pch, pend)) return;
  1686. *pch++ = 0x1E;
  1687. pOEM->curFontGrxIds[4] = tid;
  1688. tid = LFontList[fontid - FirstLogicalFont][5];
  1689. if (&pch[2] > pend) return;
  1690. // Grx ID G1
  1691. *pch++ = 0x60;
  1692. if (!VFormat(tid, &pch, pend)) return;
  1693. *pch++ = 0x1E;
  1694. pOEM->curFontGrxIds[5] = tid;
  1695. tid = LFontList[fontid - FirstLogicalFont][6];
  1696. if (&pch[2] > pend) return;
  1697. // Grx ID G2
  1698. *pch++ = 'a';
  1699. if (!VFormat(tid, &pch, pend)) return;
  1700. *pch++ = 0x1E;
  1701. pOEM->curFontGrxIds[6] = tid;
  1702. tid = LFontList[fontid - FirstLogicalFont][7];
  1703. if (&pch[2] > pend) return;
  1704. // Grx ID G3
  1705. *pch++ = 'b';
  1706. if (!VFormat(tid, &pch, pend)) return;
  1707. *pch++ = 0x1E;
  1708. pOEM->curFontGrxIds[7] = tid;
  1709. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  1710. pOEM->GLTable = INIT;
  1711. pOEM->GRTable = INIT;
  1712. // NTRAID#NTBUG-150055-2002/03/07-yasuho-:
  1713. // White device font isn't printed out
  1714. pOEM->OrnamentedChar[0] = pOEM->OrnamentedChar[1] = INIT;
  1715. //*******************************************************************
  1716. // Propotional Character Width Table
  1717. // This buffer is saved character widths of LIPS device font to
  1718. // caluculate a location of text in OEMOutputChar(). In LIPS, we
  1719. // have to specify a location of text when printing the text every
  1720. // time. But we can't get the information of lacation of text from
  1721. // Unidriver every calling. So we need to manage the location of
  1722. // text by ourselves in OEMOutputChar().
  1723. //
  1724. // By Hitoshis at March 28, 1995
  1725. //*******************************************************************
  1726. // Set Pitch of the font
  1727. // if (pIFI->flInfo &
  1728. // (FM_INFO_OPTICALLY_FIXED_PITCH|FM_INFO_DBCS_FIXED_PITCH))
  1729. // NTRAID#NTBUG9-120640-2002/03/07-yasuho-: for the proportional fonts
  1730. if (pIFI->jWinPitchAndFamily & 0x01)
  1731. pOEM->fpitch = FIXED;
  1732. else
  1733. pOEM->fpitch = PROP;
  1734. // NTRAID#NTBUG9-568220-2002/03/07-yasuho-: Remove the dead code
  1735. // Save cached font in this time
  1736. pOEM->cachedfont = fontid;
  1737. }
  1738. // **** Text path
  1739. BOOL SetTextPath(pdevobj, vert)
  1740. PDEVOBJ pdevobj;
  1741. BOOL vert;
  1742. {
  1743. PLIPSPDEV pOEM;
  1744. char c1;
  1745. BOOL ret;
  1746. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  1747. if(vert == TRUE) // Vertical writing mode
  1748. c1 = 0x33;
  1749. else // Horisontal writing mode
  1750. c1 = 0x30;
  1751. // Now send out printer commands if necessary.
  1752. ret = FALSE;
  1753. if (pOEM->TextPath != c1) {
  1754. // set horizontal or vertical writing mode
  1755. pOEM->TextPath = c1;
  1756. ret = TRUE;
  1757. }
  1758. return ret;
  1759. }
  1760. // **** Character orientation
  1761. BOOL SetCharOrient(pdevobj, vert)
  1762. PDEVOBJ pdevobj;
  1763. BOOL vert;
  1764. {
  1765. PLIPSPDEV pOEM;
  1766. short s1, s2, s3, s4;
  1767. short t1, t2, t3, t4;
  1768. BOOL ret;
  1769. short esc;
  1770. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  1771. if(pOEM->fitalic == TRUE && vert != TRUE) {
  1772. // if Italic and horisontal writing mode
  1773. s1 = 208; // x of up vecter
  1774. s2 = -978; // y of up vecter
  1775. s3 = 1000; // x of base vecter
  1776. s4 = 0; // y of base vecter
  1777. } else if(pOEM->fitalic != TRUE && vert != TRUE) {
  1778. // if non Italic and horisontal writing mode
  1779. s1 = 0; // x of up vecter
  1780. s2 = -1000; // y of up vecter
  1781. s3 = 1000; // x of base vecter
  1782. s4 = 0; // y of base vecter
  1783. } else if(pOEM->fitalic == TRUE && vert == TRUE) {
  1784. // if Italic and vertical writing mode
  1785. s1 = -1000; // x of up vecter
  1786. s2 = 0; // y of up vecter
  1787. s3 = 208; // x of base vecter
  1788. s4 = -978; // y of base vecter
  1789. } else {
  1790. // if non Italic and vertical writing mode
  1791. s1 = -1000; // x of up vecter
  1792. s2 = 0; // y of up vecter
  1793. s3 = 0; // x of base vecter
  1794. s4 = -1000; // y of base vecter
  1795. }
  1796. // calculate print direction
  1797. t1 = s1; t2 = s2; t3 = s3; t4 = s4;
  1798. esc = (pOEM->Escapement)/90;
  1799. switch(esc) {
  1800. case 0:
  1801. break;
  1802. case 1: // 90
  1803. s1 = t2; // x of up vecter
  1804. s2 = -t1; // y of up vecter
  1805. s3 = t4; // x of base vecter
  1806. s4 = -t3; // y of base vecter
  1807. break;
  1808. case 2: // 180
  1809. s1 = -t1; // x of up vecter
  1810. s2 = -t2; // y of up vecter
  1811. s3 = -t3; // x of base vecter
  1812. s4 = -t4; // y of base vecter
  1813. break;
  1814. case 3: // 270
  1815. s1 = -t2; // x of up vecter
  1816. s2 = t1; // y of up vecter
  1817. s3 = -t4; // x of base vecter
  1818. s4 = t3; // y of base vecter
  1819. break;
  1820. }
  1821. // Now send out printer commands if necessary.
  1822. ret = FALSE;
  1823. if (pOEM->CharOrientation[0] != s1 ||
  1824. pOEM->CharOrientation[1] != s2 ||
  1825. pOEM->CharOrientation[2] != s3 ||
  1826. pOEM->CharOrientation[3] != s4) {
  1827. // save character orientation vector
  1828. pOEM->CharOrientation[0] = s1;
  1829. pOEM->CharOrientation[1] = s2;
  1830. pOEM->CharOrientation[2] = s3;
  1831. pOEM->CharOrientation[3] = s4;
  1832. ret = TRUE;
  1833. }
  1834. return ret;
  1835. }
  1836. // **** Check cursor positoin after printing text
  1837. // Prop DBCS support
  1838. void UpdatePosition(pdevobj, len, width, bDBCSFont)
  1839. PDEVOBJ pdevobj;
  1840. short len;
  1841. short width;
  1842. BOOL bDBCSFont;
  1843. {
  1844. PLIPSPDEV pOEM;
  1845. char i;
  1846. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  1847. if(pOEM->fpitch == FIXED) {
  1848. long lmw, lc, s1;
  1849. // lmw = (long)(pOEM->tblCurrentFont.MaxWidth);
  1850. // lc = (long)len;
  1851. // NTRAID#NTBUG-120640-2002/03/07-yasuho-:
  1852. // should be used FontHeight instead of MaxWidth
  1853. // lmw = (long)(pOEM->tblCurrentFont.FontHeight);
  1854. // NTRAID#NTBUG9-394067-2002/03/07-yasuho-:
  1855. // Compute font width with font stretching.
  1856. s1 = pOEM->tblCurrentFont.Stretch;
  1857. lmw = (long)(pOEM->tblCurrentFont.FontHeight * s1) / 100;
  1858. if (len != 2) // for single byte chars
  1859. lmw /= 2;
  1860. // pOEM->stringwidth += (long)((lmw*lc+1)/2);
  1861. pOEM->stringwidth += lmw - 1;
  1862. } else if (bDBCSFont) {
  1863. // Prop DBCS support
  1864. long w;
  1865. // NTRAID#NTBUG9-371640-2002/03/07-yasuho-:
  1866. // Suisu and Dacchi isn't printed correctly on 150dpi.
  1867. w = (width * 300) / pOEM->resolution;
  1868. // NTRAID#NTBUG9-394067-2002/03/07-yasuho-:
  1869. // Compute font width with font stretching.
  1870. w = (w * pOEM->tblCurrentFont.Stretch) / 100;
  1871. pOEM->stringwidth += ((long)(pOEM->tblCurrentFont.FontHeight) * w)
  1872. / 1000;
  1873. } else {
  1874. // NTRAID#NTBUG9-568220-2002/03/07-yasuho-: Remove the dead code
  1875. // Prop DBCS support
  1876. // Save a printed string width for device propotional character
  1877. for(i=0; i<len; ++i) {
  1878. short res, pow;
  1879. long w;
  1880. // sc = (short)((uchar)(lpstr[i])); // getting character code
  1881. // pOEM->stringwidth += (long)((pOEM->widthbuffer)[sc]);
  1882. // NTRAID#NTBUG-120640-2002/03/07-yasuho-:
  1883. // I don't know why it should be power of 2 but it should be
  1884. // need to add for NT5 unidrv. 1/14/98 yasuho
  1885. res = pOEM->resolution;
  1886. w = width;
  1887. // NTRAID#NTBUG9-394067-2002/03/07-yasuho-:
  1888. // Compute font width with font stretching.
  1889. w = (w * pOEM->tblCurrentFont.Stretch) / 100;
  1890. #ifdef LIPS4C
  1891. // NTRAID#NTBUG-185704-2002/03/07-yasuho-:
  1892. // Font overlaps each other.
  1893. // Adjust font width calculation. This printers resolution does
  1894. // not divisible by integer calculation.
  1895. if (res == 360) {
  1896. pow = 1 * 2;
  1897. w = (long)width * 600L / res;
  1898. } else
  1899. #endif
  1900. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  1901. if (!res) return;
  1902. pow = 1200 / res;
  1903. pOEM->stringwidth += ((long)(pOEM->tblCurrentFont.FontHeight) *
  1904. (long)(w * pow)) / 1000;
  1905. }
  1906. }
  1907. }
  1908. // **** Put location of the text
  1909. VOID
  1910. PutTextLocation(
  1911. PDEVOBJ pdevobj,
  1912. LONG *pCx,
  1913. LONG *pCy)
  1914. {
  1915. PLIPSPDEV pOEM;
  1916. long cx, cy;
  1917. short esc;
  1918. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  1919. esc = (pOEM->Escapement)/90;
  1920. switch(esc) {
  1921. case 0:
  1922. pOEM->ptInLine.x += (short)(pOEM->stringwidth);
  1923. cx = pOEM->ptInLine.x;
  1924. cy = pOEM->ptInLine.y;
  1925. if(pOEM->fvertical == TRUE) { // Vertical writing mode
  1926. cy += (pOEM->tblCurrentFont.FontHeight / 2)
  1927. - pOEM->tblCurrentFont.Ascent;
  1928. }
  1929. break;
  1930. case 1: // 90
  1931. pOEM->ptInLine.y -= (short)(pOEM->stringwidth);
  1932. cx = pOEM->ptInLine.x;
  1933. cy = pOEM->ptInLine.y;
  1934. if(pOEM->fvertical == TRUE) { // Vertical writing mode
  1935. cx -= (pOEM->tblCurrentFont.FontHeight / 2)
  1936. + pOEM->tblCurrentFont.Ascent
  1937. - pOEM->tblCurrentFont.FontHeight;
  1938. }
  1939. break;
  1940. case 2: // 180
  1941. pOEM->ptInLine.x -= (short)(pOEM->stringwidth);
  1942. cx = pOEM->ptInLine.x;
  1943. cy = pOEM->ptInLine.y;
  1944. if(pOEM->fvertical == TRUE) { // Vertical writing mode
  1945. cy -= (pOEM->tblCurrentFont.FontHeight / 2)
  1946. - pOEM->tblCurrentFont.Ascent;
  1947. }
  1948. break;
  1949. case 3: // 270
  1950. pOEM->ptInLine.y += (short)(pOEM->stringwidth);
  1951. cx = pOEM->ptInLine.x;
  1952. cy = pOEM->ptInLine.y;
  1953. if(pOEM->fvertical == TRUE) { // Vertical writing mode
  1954. cx += (pOEM->tblCurrentFont.FontHeight / 2)
  1955. + pOEM->tblCurrentFont.Ascent
  1956. - pOEM->tblCurrentFont.FontHeight;
  1957. }
  1958. break;
  1959. }
  1960. *pCx = cx;
  1961. *pCy = cy;
  1962. pOEM->stringwidth = 0;
  1963. }
  1964. /***************************************************************************
  1965. Function Name : oemOutputChar
  1966. Parameters : LPDV lpdv Private Device Structure
  1967. LPSTR lpstr Print String
  1968. WORD len Length
  1969. WORD rcID Font ID
  1970. Note :
  1971. ***************************************************************************/
  1972. short WINAPI oemOutputChar(pdevobj, lpstr, len, pIFI, width)
  1973. PDEVOBJ pdevobj;
  1974. LPSTR lpstr;
  1975. WORD len;
  1976. PIFIMETRICS pIFI;
  1977. WORD width;
  1978. {
  1979. // #define MAKEWORD(l, h) ((WORD)(((BYTE)(l)) | (((WORD)((BYTE)(h))) << 8)))
  1980. // #define bIsDBCSLeadByte(c) \
  1981. // ((c) >= 0x81 && (c) <= 0x9f || (c) >= 0xe0 && (c) <=0xfc)
  1982. #define bIsControlChar(c) \
  1983. ((c) >= 0x00 && (c) <= 0x1f || (c) >= 0x80 && (c) <= 0x9f)
  1984. WORD wJIScode;
  1985. BYTE *pStr;
  1986. PLIPSPDEV pOEM;
  1987. BYTE ch[CCHMAXCMDLEN];
  1988. short i;
  1989. char c1, c2;
  1990. char p1, p2;
  1991. short s1;
  1992. short tsh, tsw;
  1993. BOOL bDBCSFont;
  1994. BYTE chCtrl[CCHMAXCMDLEN];
  1995. INT fTemp, fTempNew;
  1996. WORD wCount;
  1997. LONG cX, cY;
  1998. BOOL bVert;
  1999. BOOL bTemp;
  2000. BOOL bIsDBCS;
  2001. PBYTE pch;
  2002. PBYTE pend = &ch[CCHMAXCMDLEN];
  2003. // NTRAID#NTBUG9-679838-2002/08/05-yasuho-: dot does not printed.
  2004. PBYTE pchCtrl;
  2005. PBYTE pchCend = &chCtrl[CCHMAXCMDLEN];
  2006. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  2007. // pOEM->fvertical = RcidIsDBCSVertFont( rcID );
  2008. // bDBCSFont = RcidIsDBCSFont( rcID );
  2009. pStr = (BYTE *)pIFI + pIFI->dpwszFaceName;
  2010. pOEM->fvertical = (pStr[0] == '@' && pStr[1] == '\0'); // vertical font
  2011. bDBCSFont = (pIFI->jWinCharSet == SHIFTJIS_CHARSET);
  2012. bIsDBCS = (len == 2);
  2013. // **** Logic style
  2014. // Send logic style
  2015. if (pOEM->fcolor) {
  2016. // If it is full-color mode, set logic to PATCOPY
  2017. // (same value as B/W OR_MODE)
  2018. if (pOEM->bLogicStyle != OR_MODE) {
  2019. pch = ch;
  2020. if (&pch[4] > pend) return -1;
  2021. *pch++ = '\x7D';
  2022. *pch++ = 'H';
  2023. *pch++ = '1';
  2024. *pch++ = 0x1E;
  2025. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2026. pOEM->bLogicStyle = OR_MODE;
  2027. }
  2028. } else {
  2029. if(pOEM->fwhitetext == TRUE && pOEM->bLogicStyle != AND_MODE) {
  2030. // "\x7DH0\x0E" If White text mode, we should set AND mode
  2031. pch = ch;
  2032. if (&pch[4] > pend) return -1;
  2033. *pch++ = '\x7D';
  2034. *pch++ = 'H';
  2035. *pch++ = '3';
  2036. *pch++ = 0x1E;
  2037. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2038. pOEM->bLogicStyle = AND_MODE;
  2039. }
  2040. if(pOEM->fwhitetext != TRUE && pOEM->bLogicStyle != OR_MODE) {
  2041. // "\x7DH1\x0E" If Black text mode, we should set OR mode
  2042. pch = ch;
  2043. if (&pch[4] > pend) return -1;
  2044. *pch++ = '\x7D';
  2045. *pch++ = 'H';
  2046. *pch++ = '1';
  2047. *pch++ = 0x1E;
  2048. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2049. pOEM->bLogicStyle = OR_MODE;
  2050. }
  2051. } // fcolor
  2052. // NTRAID#NTBUG9-98276-2002/03/08-yasuho-: Support Color Bold
  2053. if (pOEM->fbold && pOEM->fcolor) {
  2054. if ((pOEM->fcolor == COLOR_8BPP && pOEM->dwCurIndex != pOEM->dwOutIndex) ||
  2055. (pOEM->fcolor != COLOR_8BPP &&
  2056. (pOEM->CurColor.dwRed != pOEM->OutColor.dwRed ||
  2057. pOEM->CurColor.dwGreen != pOEM->OutColor.dwGreen ||
  2058. pOEM->CurColor.dwBlue != pOEM->OutColor.dwBlue))) {
  2059. // Select Outline color.
  2060. // We also need to specify the outline color for expand the character.
  2061. pch = ch;
  2062. if (&pch[3] > pend) return -1;
  2063. *pch++ = 0x7D; // Select Outline color
  2064. *pch++ = 'X';
  2065. if (pOEM->fcolor == COLOR_8BPP) { // palette mode
  2066. if (!VFormat(pOEM->dwCurIndex, &pch, pend)) return -1;
  2067. pOEM->dwOutIndex = pOEM->dwCurIndex;
  2068. } else {
  2069. if (!VFormat(pOEM->CurColor.dwRed, &pch, pend)) return -1;
  2070. if (!VFormat(pOEM->CurColor.dwGreen, &pch, pend)) return -1;
  2071. if (!VFormat(pOEM->CurColor.dwBlue, &pch, pend)) return -1;
  2072. pOEM->OutColor = pOEM->CurColor;
  2073. }
  2074. *pch++ = 0x1E;
  2075. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2076. }
  2077. }
  2078. // **** Ornamented character
  2079. if(pOEM->fwhitetext == TRUE)
  2080. c1 = -9; // white fill
  2081. else
  2082. c1 = 1; // black fill
  2083. if(pOEM->fbold == TRUE)
  2084. {
  2085. short y;
  2086. short res;
  2087. y = pOEM->tblCurrentFont.FontHeight;
  2088. res = pOEM->resolution;
  2089. // OrnamentedChar[1] : means how much bold is per Character Height
  2090. // 0 regular,-2 < 48point,-3 < 96point,-4 >= 96points
  2091. // 150dpi : 0 regular,-2 < 200dots,-3 < 400dots,-4 >= 400dots
  2092. // 300dpi : 0 regular,-2 < 200dots,-3 < 400dots,-4 >= 400dots
  2093. // 600dpi : 0 regular,-2 < 400dots,-3 < 800dots,-4 >= 800dots
  2094. // (150dpi means only image date is 150dpi)
  2095. //
  2096. // NTRAID#NTBUG9-98276-2002/03/08-yasuho-: Support Color Bold
  2097. // Calculate the expanded factor for the color mode.
  2098. if (!(res / 6)) return -1;
  2099. if (pOEM->fcolor) {
  2100. c2 = (y / (res / 6)) + 1;
  2101. } else {
  2102. // NTRAID#NTBUG9-213732-2002/03/07-yasuho-: 1200dpi support
  2103. if(res == 1200)
  2104. {
  2105. if(y < 400)
  2106. c2 = -2; // Bold
  2107. else if(y < 800)
  2108. c2 = -3; // Bold
  2109. else if(y >= 800)
  2110. c2 = -4; // Bold
  2111. }
  2112. else if(res == 600)
  2113. {
  2114. if(y < 400)
  2115. c2 = -2; // Bold
  2116. else if(y < 800)
  2117. c2 = -3; // Bold
  2118. else if(y >= 800)
  2119. c2 = -4; // Bold
  2120. }
  2121. #ifdef LIPS4C
  2122. else if(res == 360)
  2123. {
  2124. if(y < 240)
  2125. c2 = -2; // Bold
  2126. else if(y < 480)
  2127. c2 = -3; // Bold
  2128. else if(y >= 480)
  2129. c2 = -4; // Bold
  2130. }
  2131. #endif // LIPS4C
  2132. else if(res == 300)
  2133. {
  2134. if(y < 200)
  2135. c2 = -2; // Bold
  2136. else if(y < 400)
  2137. c2 = -3; // Bold
  2138. else if(y >= 400)
  2139. c2 = -4; // Bold
  2140. }
  2141. else if(res == 150)
  2142. {
  2143. if(y < 200)
  2144. c2 = -2; // Bold
  2145. else if(y < 400)
  2146. c2 = -3; // Bold
  2147. else if(y >= 400)
  2148. c2 = -4; // Bold
  2149. }
  2150. else
  2151. {
  2152. c2 = 0; // Regular
  2153. }
  2154. } // fcolor
  2155. } // fbold
  2156. // NTRAID#NTBUG9-441432-2002/03/07-yasuho-:
  2157. // PREFIX: "c2" does not initialized if pOEM->fbold is FALSE.
  2158. else
  2159. c2 = 0; // Regular
  2160. // Output OrnamentedCharacter
  2161. p1 = pOEM->OrnamentedChar[0]; // fill mode
  2162. p2 = pOEM->OrnamentedChar[1]; // weight bold
  2163. if(c1==p1 && c2==p2)
  2164. ; // we don't need to send this command
  2165. else
  2166. // NTRAID#NTBUG9-98276-2002/03/07-yasuho-: Support Color Bold
  2167. if (pOEM->fcolor) {
  2168. // Character effects instruction #2.
  2169. // We should use this command to bold the font for color models
  2170. // because "<7D>^" command does not worked correctly on the color mode.
  2171. pch = ch;
  2172. if (&pch[11] > pend) return -1;
  2173. *pch++ = 0x7D;
  2174. *pch++ = '_';
  2175. *pch++ = (c1 == -9) ? 0x29 : 0x31; // White text
  2176. *pch++ = '0';
  2177. *pch++ = '0';
  2178. *pch++ = '0';
  2179. *pch++ = '1';
  2180. *pch++ = '0';
  2181. *pch++ = '0';
  2182. *pch++ = '0';
  2183. if (!VFormat(c2, &pch, pend)) return -1; // Outline size
  2184. *pch++ = 0x1E;
  2185. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2186. // save current mode
  2187. pOEM->OrnamentedChar[0] = c1;
  2188. pOEM->OrnamentedChar[1] = c2; //XXX
  2189. } else {
  2190. pch = ch;
  2191. if (&pch[5] > pend) return -1;
  2192. // \x7D^
  2193. *pch++ = '\x7D';
  2194. *pch++ = 0x5E;
  2195. // fill mode
  2196. *pch++ = (c1 == -9) ? 0x29 : 0x31; // -9:white text , 1:black text
  2197. // save fill mode
  2198. pOEM->OrnamentedChar[0] = c1;
  2199. // bold mode
  2200. if(c2==-4)
  2201. *pch++ = 0x24; // -4 : 7 dots bold text
  2202. else if(c2==-3)
  2203. *pch++ = 0x23; // -3 : 5 dots bold text
  2204. else if(c2==-2)
  2205. *pch++ = 0x22; // -2 : 3 dots bold text
  2206. else // should be c2 == 0
  2207. *pch++ = 0x30; // 0 : regular text
  2208. // save bold mode
  2209. pOEM->OrnamentedChar[1] = c2;
  2210. *pch++ = 0x1E;
  2211. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2212. }
  2213. // NTRAID#NTBUG9-568220-2002/03/07-yasuho-: Remove the dead code
  2214. // NTRAID#NTBUG-137882-2002/03/08-yasuho-: Black fonts doesn't printed.
  2215. // According to Canon, these commands doesn't necessary.
  2216. // **** Character height
  2217. s1 = pOEM->tblCurrentFont.FontHeight;
  2218. if(s1 == pOEM->tblPreviousFont.FontHeight)
  2219. ; // we don't need to send this command
  2220. else {
  2221. pch = ch;
  2222. if (&pch[2] > pend) return -1;
  2223. *pch++ = 'Y';
  2224. if (!VFormat((long)s1, &pch, pend)) return -1;
  2225. *pch++ = 0x1E;
  2226. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2227. // save character height
  2228. pOEM->tblPreviousFont.FontHeight = s1;
  2229. }
  2230. // **** Character expansion factor
  2231. // support TC_SF_X_YINDEP
  2232. //tsh = pOEM->tblCurrentFont.FontHeight;
  2233. //tsw = pOEM->tblCurrentFont.MaxWidth;
  2234. s1 = pOEM->tblCurrentFont.Stretch;
  2235. if(s1 == pOEM->tblPreviousFont.Stretch)
  2236. ; // we don't need to send this command
  2237. else {
  2238. pch = ch;
  2239. if (&pch[2] > pend) return -1;
  2240. *pch++ = 'V';
  2241. if (!VFormat((long)s1, &pch, pend)) return -1;
  2242. *pch++ = 0x1E;
  2243. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2244. // restore character expansion factor
  2245. pOEM->tblPreviousFont.Stretch = s1;
  2246. }
  2247. pStr = (BYTE *)lpstr;
  2248. // **** Set writing mode
  2249. pch = ch;
  2250. bVert = FALSE;
  2251. if (bDBCSFont) {
  2252. if (bIsDBCS) {
  2253. if (pOEM->fvertical)
  2254. bVert = TRUE;
  2255. }
  2256. }
  2257. if (SetTextPath(pdevobj, bVert)) {
  2258. if (&pch[3] > pend) return -1;
  2259. *pch++ = '[';
  2260. *pch++ = pOEM->TextPath;
  2261. *pch++ = 0x1E;
  2262. }
  2263. if (SetCharOrient(pdevobj, bVert)) {
  2264. if (&pch[2] > pend) return -1;
  2265. *pch++ = 'Z';
  2266. if (!VFormat(pOEM->CharOrientation[0], &pch, pend)) return -1;
  2267. if (!VFormat(pOEM->CharOrientation[1], &pch, pend)) return -1;
  2268. if (!VFormat(pOEM->CharOrientation[2], &pch, pend)) return -1;
  2269. if (!VFormat(pOEM->CharOrientation[3], &pch, pend)) return -1;
  2270. *pch++ = 0x1e;
  2271. }
  2272. // Normal Text mode
  2273. // **** Put location of the text
  2274. bTemp = pOEM->fvertical;
  2275. pOEM->fvertical = (char)bVert;
  2276. PutTextLocation(pdevobj, &cX, &cY);
  2277. pOEM->fvertical = (char)bTemp;
  2278. if (&pch[2] > pend) return -1;
  2279. *pch++ = '4';
  2280. *pch++ = '0';
  2281. if (!VFormat(cX, &pch, pend)) return -1;
  2282. if (!VFormat(cY, &pch, pend)) return -1;
  2283. // Check if we need switching between halfwidth and fulwidth.
  2284. // We also check the existence of control characters.
  2285. // Both of these require text data are send in separate chunks.
  2286. fTemp = -1;
  2287. // NTRAID#NTBUG9-550215-2002/03/07-yasuho-: PREFAST
  2288. fTempNew = -1;
  2289. wCount = 0;
  2290. for (i = 0; i < len; i++) {
  2291. if (bDBCSFont) {
  2292. if (bIsDBCS) {
  2293. fTempNew = 3;
  2294. i++;
  2295. }
  2296. else if (bIsControlChar(pStr[i])) {
  2297. fTempNew = 0;
  2298. }
  2299. else {
  2300. fTempNew = 2;
  2301. }
  2302. }
  2303. else {
  2304. if (bIsControlChar(pStr[i])) {
  2305. fTempNew = 0;
  2306. }
  2307. else {
  2308. fTempNew = 1;
  2309. }
  2310. }
  2311. // Status changed
  2312. if (fTemp != fTempNew) {
  2313. wCount++;
  2314. fTemp = fTempNew;
  2315. }
  2316. }
  2317. fTemp = -1;
  2318. pchCtrl = chCtrl;
  2319. for (i = 0; i < len; i++) {
  2320. if (bDBCSFont) {
  2321. if (bIsDBCS) {
  2322. fTempNew = 3;
  2323. }
  2324. else if (bIsControlChar(pStr[i])) {
  2325. fTempNew = 0;
  2326. }
  2327. else {
  2328. fTempNew = 2;
  2329. }
  2330. }
  2331. else {
  2332. if (bIsControlChar(pStr[i])) {
  2333. fTempNew = 0;
  2334. }
  2335. else {
  2336. fTempNew = 1;
  2337. }
  2338. }
  2339. if (fTemp != fTempNew) {
  2340. wCount--;
  2341. // NTRAID#NTBUG9-679838-2002/08/05-yasuho-: dot does not printed.
  2342. if (fTemp == 0) {
  2343. if (&pch[1] > pend) return -1;
  2344. *pch++ = 0x1E; // IS2
  2345. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2346. if (&pchCtrl[1] > pchCend) return -1;
  2347. *pchCtrl++ = 0x1E;
  2348. WRITESPOOLBUF(pdevobj, chCtrl, (DWORD)(pchCtrl - chCtrl));
  2349. pch = ch;
  2350. pchCtrl = chCtrl;
  2351. if (&pch[2] > pend) return -1;
  2352. *pch++ = '4';
  2353. *pch++ = '1';
  2354. }
  2355. if (&pch[1] > pend) return -1;
  2356. *pch++ = (wCount > 0) ? '0' : '1';
  2357. if (fTempNew == 3) {
  2358. if (pOEM->fvertical == TRUE) {
  2359. if (pOEM->GLTable != 3) {
  2360. if (&pch[2] > pend) return -1;
  2361. *pch++ = 0x1B; // LS3
  2362. *pch++ = 0x6F; // LS3
  2363. pOEM->GLTable = 3;
  2364. }
  2365. bTemp = FALSE;
  2366. if (SetTextPath(pdevobj, TRUE)) {
  2367. if (bTemp == FALSE) {
  2368. if (&pch[1] > pend) return -1;
  2369. *pch++ = 0x1e;
  2370. bTemp = TRUE;
  2371. }
  2372. if (&pch[3] > pend) return -1;
  2373. *pch++ = '[';
  2374. *pch++ = pOEM->TextPath;
  2375. *pch++ = 0x1E;
  2376. }
  2377. if (SetCharOrient(pdevobj, TRUE)) {
  2378. if (bTemp == FALSE) {
  2379. if (&pch[1] > pend) return -1;
  2380. *pch++ = 0x1e;
  2381. bTemp = TRUE;
  2382. }
  2383. if (&pch[2] > pend) return -1;
  2384. *pch++ = 'Z';
  2385. if (!VFormat(pOEM->CharOrientation[0], &pch, pend))
  2386. return -1;
  2387. if (!VFormat(pOEM->CharOrientation[1], &pch, pend))
  2388. return -1;
  2389. if (!VFormat(pOEM->CharOrientation[2], &pch, pend))
  2390. return -1;
  2391. if (!VFormat(pOEM->CharOrientation[3], &pch, pend))
  2392. return -1;
  2393. *pch++ = 0x1e;
  2394. }
  2395. if (bTemp != FALSE) {
  2396. if (&pch[3] > pend) return -1;
  2397. PutTextLocation(pdevobj, &cX, &cY);
  2398. *pch++ = '4';
  2399. *pch++ = '0';
  2400. if (!VFormat(cX, &pch, pend)) return -1;
  2401. if (!VFormat(cY, &pch, pend)) return -1;
  2402. *pch++ = (wCount > 0) ? '0' : '1';
  2403. }
  2404. }
  2405. else {
  2406. if (pOEM->GLTable != 2) {
  2407. if (&pch[2] > pend) return -1;
  2408. *pch++ = 0x1B; // LS2
  2409. *pch++ = 0x6E; // LS2
  2410. pOEM->GLTable = 2;
  2411. }
  2412. }
  2413. }
  2414. else {
  2415. if (pOEM->GLTable != 0) {
  2416. if (&pch[1] > pend) return -1;
  2417. *pch++ = 0x0F; // SI
  2418. pOEM->GLTable = 0;
  2419. }
  2420. if (pOEM->GRTable != 1) {
  2421. if (&pch[2] > pend) return -1;
  2422. *pch++ = 0x1B; // LS1R
  2423. *pch++ = 0x7E; // LS1R
  2424. pOEM->GRTable = 1;
  2425. }
  2426. }
  2427. }
  2428. if (fTempNew == 3) {
  2429. /* Shift JIS to JIS */
  2430. // wJIScode = MAKEWORD(pStr[i + 1], pStr[i]);
  2431. // wJIScode = sjis2jis( wJIScode );
  2432. if (&pch[2] > pend) return -1;
  2433. *pch++ = pStr[i];
  2434. *pch++ = pStr[i+1];
  2435. // If len = 2, we assume the character is DBCS. And DBCS
  2436. // character width is always fixed pitch.
  2437. UpdatePosition(pdevobj, 2, width, bDBCSFont);
  2438. i++;
  2439. }
  2440. else if (fTempNew == 0) {
  2441. // NTRAID#NTBUG9-679838-2002/08/05-yasuho-: dot does not printed.
  2442. if (pchCtrl == chCtrl) {
  2443. if (&pchCtrl[3] > pchCend) return -1;
  2444. *pchCtrl++ = '4';
  2445. *pchCtrl++ = 'B';
  2446. *pchCtrl++ = '1';
  2447. if (!VFormat(cX, &pchCtrl, pchCend)) return -1;
  2448. if (!VFormat(cY, &pchCtrl, pchCend)) return -1;
  2449. PutTextLocation(pdevobj, &cX, &cY);
  2450. }
  2451. if (&pchCtrl[1] > pchCend) return -1;
  2452. *pchCtrl++ = pStr[i];
  2453. UpdatePosition(pdevobj, 1, width, bDBCSFont);
  2454. }
  2455. else {
  2456. if (bDBCSFont) {
  2457. if(pOEM->fvertical == TRUE) // Vertical writing mode
  2458. { // Hankaku mode always requires Horisontal writing
  2459. // **** Set writing mode
  2460. bTemp = FALSE;
  2461. if (SetTextPath(pdevobj, FALSE)) {
  2462. if (bTemp == FALSE) {
  2463. if (&pch[1] > pend) return -1;
  2464. *pch++ = 0x1e;
  2465. bTemp = TRUE;
  2466. }
  2467. if (&pch[3] > pend) return -1;
  2468. *pch++ = '[';
  2469. *pch++ = pOEM->TextPath;
  2470. *pch++ = 0x1E;
  2471. }
  2472. if (SetCharOrient(pdevobj, FALSE)) {
  2473. if (bTemp == FALSE) {
  2474. if (&pch[1] > pend) return -1;
  2475. *pch++ = 0x1e;
  2476. bTemp = TRUE;
  2477. }
  2478. if (&pch[2] > pend) return -1;
  2479. *pch++ = 'Z';
  2480. if (!VFormat(pOEM->CharOrientation[0], &pch, pend))
  2481. return -1;
  2482. if (!VFormat(pOEM->CharOrientation[1], &pch, pend))
  2483. return -1;
  2484. if (!VFormat(pOEM->CharOrientation[2], &pch, pend))
  2485. return -1;
  2486. if (!VFormat(pOEM->CharOrientation[3], &pch, pend))
  2487. return -1;
  2488. *pch++ = 0x1e;
  2489. }
  2490. if (bTemp != FALSE) {
  2491. pOEM->fvertical = FALSE;
  2492. PutTextLocation(pdevobj, &cX, &cY);
  2493. if (&pch[3] > pend) return -1;
  2494. *pch++ = '4';
  2495. *pch++ = '0';
  2496. if (!VFormat(cX, &pch, pend)) return -1;
  2497. if (!VFormat(cY, &pch, pend)) return -1;
  2498. *pch++ = (wCount > 0) ? '0' : '1';
  2499. pOEM->fvertical = TRUE;
  2500. }
  2501. }
  2502. }
  2503. if (&pch[1] > pend) return -1;
  2504. *pch++ = pStr[i];
  2505. UpdatePosition(pdevobj, 1, width, bDBCSFont);
  2506. }
  2507. // Status changed
  2508. if (fTemp != fTempNew) {
  2509. fTemp = fTempNew;
  2510. }
  2511. }
  2512. // Terminait string
  2513. // NTRAID#NTBUG9-679838-2002/08/05-yasuho-: dot does not printed.
  2514. if (fTempNew == 0) {
  2515. if (&pch[1] > pend) return -1;
  2516. *pch++ = 0x1E; // IS2
  2517. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2518. if (&pchCtrl[1] > pchCend) return -1;
  2519. *pchCtrl++ = 0x1E;
  2520. WRITESPOOLBUF(pdevobj, chCtrl, (DWORD)(pchCtrl - chCtrl));
  2521. } else {
  2522. if (&pch[1] > pend) return -1;
  2523. *pch++ = 0x1E;
  2524. WRITESPOOLBUF(pdevobj, ch, (DWORD)(pch - ch));
  2525. }
  2526. return len;
  2527. }
  2528. /*
  2529. * OEMOutputCharStr
  2530. */
  2531. VOID APIENTRY
  2532. OEMOutputCharStr(
  2533. PDEVOBJ pdevobj,
  2534. PUNIFONTOBJ pUFObj,
  2535. DWORD dwType,
  2536. DWORD dwCount,
  2537. PVOID pGlyph)
  2538. {
  2539. PGETINFO_STDVAR pSV;
  2540. DWORD adwStdVariable[2+2*2];
  2541. #define FI_FONTID (pSV->StdVar[0].lStdVariable)
  2542. #undef FI_WIDTH
  2543. #define FI_WIDTH (pSV->StdVar[1].lStdVariable)
  2544. GETINFO_GLYPHSTRING GStr;
  2545. GETINFO_GLYPHWIDTH GWidth;
  2546. //
  2547. // NTRAID#NTBUG-185776-2002/03/07-yasuho-: Some objects doesn't print
  2548. // There were moved to DEVOBJ.
  2549. //
  2550. // BYTE aubBuff[256];
  2551. // LONG widBuf[64];
  2552. // NTRAID#NTBUG-185762-2002/03/08-yasuho-: Tilde isn't printed
  2553. // WCHAR uniBuff[256/sizeof(WCHAR)];
  2554. // NTRAID#NTBUG-333653-2002/03/07-yasuho-:
  2555. // Change I/F for GETINFO_GLYPHSTRING
  2556. PTRANSDATA pTrans, aTrans;
  2557. PDWORD pdwGlyphID;
  2558. PWORD pwUnicode;
  2559. DWORD dwI, dwGetInfo, width;
  2560. PLIPSPDEV pOEM;
  2561. PIFIMETRICS pIFI;
  2562. // Prop DBCS support
  2563. DWORD w;
  2564. // DbgPrint(DLLTEXT("OEMOutputCharStr() entry.\r\n"));
  2565. pOEM = (PLIPSPDEV)(pdevobj->pdevOEM);
  2566. switch (dwType)
  2567. {
  2568. case TYPE_GLYPHHANDLE:
  2569. // DbgPrint(DLLTEXT("dwType = TYPE_GLYPHHANDLE\n"));
  2570. GStr.dwSize = sizeof(GETINFO_GLYPHSTRING);
  2571. GStr.dwCount = dwCount;
  2572. GStr.dwTypeIn = TYPE_GLYPHHANDLE;
  2573. GStr.pGlyphIn = pGlyph;
  2574. GStr.dwTypeOut = TYPE_UNICODE;
  2575. GStr.pGlyphOut = pOEM->aubBuff;
  2576. dwGetInfo = GStr.dwSize;
  2577. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  2578. dwGetInfo, &dwGetInfo))
  2579. {
  2580. // DbgPrint(DLLTEXT("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\r\n"));
  2581. return;
  2582. }
  2583. CopyMemory(pOEM->uniBuff, pOEM->aubBuff, dwCount * sizeof(WCHAR));
  2584. // pwUnicode = (PWORD)pOEM->aubBuff;
  2585. // for (dwI = 0; dwI < dwCount; dwI ++)
  2586. // {
  2587. // DbgPrint(DLLTEXT("Unicode[%d] = %x\r\n"), dwI, pwUnicode[dwI]);
  2588. // }
  2589. GStr.dwTypeOut = TYPE_TRANSDATA;
  2590. // NTRAID#NTBUG-333653-2002/03/07-yasuho-:
  2591. // Change I/F for GETINFO_GLYPHSTRING
  2592. GStr.pGlyphOut = NULL;
  2593. GStr.dwGlyphOutSize = 0;
  2594. if (pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  2595. dwGetInfo, &dwGetInfo) || !GStr.dwGlyphOutSize)
  2596. {
  2597. // DbgPrint(DLLTEXT("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\r\n"));
  2598. return;
  2599. }
  2600. if ((aTrans = (PTRANSDATA)MemAlloc(GStr.dwGlyphOutSize)) == NULL) {
  2601. // DbgPrint(DLLTEXT("MemAlloc failed.\r\n"));
  2602. return;
  2603. }
  2604. GStr.pGlyphOut = aTrans;
  2605. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  2606. dwGetInfo, &dwGetInfo))
  2607. {
  2608. // DbgPrint(DLLTEXT("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\r\n"));
  2609. goto out;
  2610. }
  2611. //
  2612. // Get standard variables.
  2613. //
  2614. pSV = (PGETINFO_STDVAR)adwStdVariable;
  2615. pSV->dwSize = sizeof(GETINFO_STDVAR) + 2 * sizeof(DWORD) * (2 - 1);
  2616. pSV->dwNumOfVariable = 2;
  2617. pSV->StdVar[0].dwStdVarID = FNT_INFO_CURRENTFONTID;
  2618. pSV->StdVar[1].dwStdVarID = FNT_INFO_FONTWIDTH;
  2619. dwGetInfo = pSV->dwSize;
  2620. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_STDVARIABLE, pSV,
  2621. dwGetInfo, &dwGetInfo)) {
  2622. // DbgPrint(DLLTEXT("UFO_GETINFO_STDVARIABLE failed.\r\n"));
  2623. goto out;
  2624. }
  2625. GWidth.dwSize = sizeof(GETINFO_GLYPHWIDTH);
  2626. GWidth.dwCount = dwCount;
  2627. GWidth.dwType = TYPE_GLYPHHANDLE;
  2628. GWidth.pGlyph = pGlyph;
  2629. GWidth.plWidth = pOEM->widBuf;
  2630. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHWIDTH, &GWidth,
  2631. dwGetInfo, &dwGetInfo)) {
  2632. // DbgPrint(DLLTEXT("UFO_GETINFO_GLYPHWIDTH failed.\r\n"));
  2633. goto out;
  2634. }
  2635. // pTrans = (PTRANSDATA)pOEM->aubBuff;
  2636. pTrans = aTrans;
  2637. pIFI = pUFObj->pIFIMetrics;
  2638. if (!pOEM->unitdiv) return;
  2639. width = FI_WIDTH / pOEM->unitdiv;
  2640. for (dwI = 0; dwI < dwCount; dwI++, pTrans++)
  2641. {
  2642. // DbgPrint(DLLTEXT("TYPE_TRANSDATA:ubCodePageID:0x%x\n"),pTrans->ubCodePageID);
  2643. // DbgPrint(DLLTEXT("TYPE_TRANSDATA:ubType:0x%x\n"),pTrans->ubType);
  2644. switch (pTrans->ubType & MTYPE_FORMAT_MASK)
  2645. {
  2646. // NTRAID#NTBUG-185762-2002/03/07-yasuho-: Tilde isn't printed
  2647. case MTYPE_COMPOSE:
  2648. pTrans->uCode.ubCode = (BYTE)pOEM->uniBuff[dwI];
  2649. // FALL THRU
  2650. case MTYPE_DIRECT:
  2651. // DbgPrint(DLLTEXT("TYPE_TRANSDATA:ubCode:0x%x\n"),pTrans->uCode.ubCode);
  2652. oemOutputChar(pdevobj, &pTrans->uCode.ubCode, 1, pIFI,
  2653. pOEM->widBuf[dwI]);
  2654. break;
  2655. case MTYPE_PAIRED:
  2656. // DbgPrint(DLLTEXT("TYPE_TRANSDATA:ubPairs:0x%x\n"),*(PWORD)(pTrans->uCode.ubPairs));
  2657. // Prop DBCS support
  2658. w = (pOEM->fpitch == PROP) ? pOEM->widBuf[dwI] : width;
  2659. if (pTrans->uCode.ubPairs[0])
  2660. oemOutputChar(pdevobj, pTrans->uCode.ubPairs, 2, pIFI, w);
  2661. else
  2662. oemOutputChar(pdevobj, &(pTrans->uCode.ubPairs[1]), 1, pIFI, w);
  2663. break;
  2664. }
  2665. }
  2666. out:
  2667. MemFree(aTrans);
  2668. break;
  2669. case TYPE_GLYPHID:
  2670. // DbgPrint(DLLTEXT("dwType = TYPE_GLYPHID\n"));
  2671. GStr.dwSize = sizeof(GETINFO_GLYPHSTRING);
  2672. GStr.dwCount = dwCount;
  2673. GStr.dwTypeIn = TYPE_GLYPHID;
  2674. GStr.pGlyphIn = pGlyph;
  2675. GStr.dwTypeOut = TYPE_GLYPHHANDLE;
  2676. GStr.pGlyphOut = pOEM->aubBuff;
  2677. dwGetInfo = GStr.dwSize;
  2678. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  2679. dwGetInfo, &dwGetInfo))
  2680. {
  2681. // DbgPrint(DLLTEXT("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\r\n"));
  2682. }
  2683. pdwGlyphID = (PDWORD)pOEM->aubBuff;
  2684. for (dwI = 0; dwI < dwCount; dwI ++)
  2685. {
  2686. // DbgPrint(DLLTEXT("GlyphHandle[%d] = %d\r\n"), dwI, pdwGlyphID[dwI]);
  2687. }
  2688. GStr.dwTypeOut = TYPE_UNICODE;
  2689. if (!pUFObj->pfnGetInfo(pUFObj, UFO_GETINFO_GLYPHSTRING, &GStr,
  2690. dwGetInfo, &dwGetInfo))
  2691. {
  2692. // DbgPrint(DLLTEXT("UNIFONTOBJ_GetInfo:UFO_GETINFO_GLYPHSTRING failed.\r\n"));
  2693. }
  2694. pwUnicode = (PWORD)pOEM->aubBuff;
  2695. for (dwI = 0; dwI < dwCount; dwI ++)
  2696. {
  2697. // DbgPrint(DLLTEXT("Unicode[%d] = %x\r\n"), dwI, pwUnicode[dwI]);
  2698. }
  2699. for (dwI = 0; dwI < dwCount; dwI ++, ((PDWORD)pGlyph)++)
  2700. {
  2701. // DbgPrint(DLLTEXT("TYEP_GLYPHID:0x%x\n"), *(PDWORD)pGlyph);
  2702. pdevobj->pDrvProcs->DrvWriteSpoolBuf(pdevobj,
  2703. (PBYTE)pGlyph,
  2704. 1);
  2705. }
  2706. break;
  2707. }
  2708. }