+ /* We're using a private area for direct to font. (512 chars.) */
+ if (ucsdata.dbcs_screenfont && (text[0] & CSET_MASK) == CSET_ACP) {
+ /* Ho Hum, dbcs fonts are a PITA! */
+ /* To display on W9x I have to convert to UCS */
+ static wchar_t *uni_buf = 0;
+ static int uni_len = 0;
+ int nlen, mptr;
+ if (len > uni_len) {
+ sfree(uni_buf);
+ uni_len = len;
+ uni_buf = snewn(uni_len, wchar_t);
+ }
+
+ for(nlen = mptr = 0; mptr<len; mptr++) {
+ uni_buf[nlen] = 0xFFFD;
+ if (IsDBCSLeadByteEx(ucsdata.font_codepage,
+ (BYTE) text[mptr])) {
+ char dbcstext[2];
+ dbcstext[0] = text[mptr] & 0xFF;
+ dbcstext[1] = text[mptr+1] & 0xFF;
+ lpDx[nlen] += char_width;
+ MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
+ dbcstext, 2, uni_buf+nlen, 1);
+ mptr++;
+ }
+ else
+ {
+ char dbcstext[1];
+ dbcstext[0] = text[mptr] & 0xFF;
+ MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
+ dbcstext, 1, uni_buf+nlen, 1);
+ }
+ nlen++;
+ }
+ if (nlen <= 0)
+ return; /* Eeek! */
+
+ ExtTextOutW(hdc, x + xoffset,
+ y - font_height * (lattr == LATTR_BOT) + text_adjust,
+ ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
+ &line_box, uni_buf, nlen,
+ lpDx_maybe);
+ if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
+ SetBkMode(hdc, TRANSPARENT);
+ ExtTextOutW(hdc, x + xoffset - 1,
+ y - font_height * (lattr ==
+ LATTR_BOT) + text_adjust,
+ ETO_CLIPPED, &line_box, uni_buf, nlen, lpDx_maybe);
+ }
+
+ lpDx[0] = -1;
+ } else if (DIRECT_FONT(text[0])) {
+ static char *directbuf = NULL;
+ static int directlen = 0;
+ int i;
+ if (len > directlen) {
+ directlen = len;
+ directbuf = sresize(directbuf, directlen, char);
+ }
+
+ for (i = 0; i < len; i++)
+ directbuf[i] = text[i] & 0xFF;
+
+ ExtTextOut(hdc, x + xoffset,
+ y - font_height * (lattr == LATTR_BOT) + text_adjust,
+ ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
+ &line_box, directbuf, len, lpDx_maybe);
+ if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
+ SetBkMode(hdc, TRANSPARENT);
+
+ /* GRR: This draws the character outside its box and
+ * can leave 'droppings' even with the clip box! I
+ * suppose I could loop it one character at a time ...
+ * yuk.
+ *
+ * Or ... I could do a test print with "W", and use +1
+ * or -1 for this shift depending on if the leftmost
+ * column is blank...
+ */
+ ExtTextOut(hdc, x + xoffset - 1,
+ y - font_height * (lattr ==
+ LATTR_BOT) + text_adjust,
+ ETO_CLIPPED, &line_box, directbuf, len, lpDx_maybe);
+ }
+ } else {
+ /* And 'normal' unicode characters */
+ static WCHAR *wbuf = NULL;
+ static int wlen = 0;
+ int i;
+
+ if (wlen < len) {
+ sfree(wbuf);
+ wlen = len;
+ wbuf = snewn(wlen, WCHAR);
+ }
+
+ for (i = 0; i < len; i++)
+ wbuf[i] = text[i];
+
+ /* print Glyphs as they are, without Windows' Shaping*/
+ general_textout(hdc, x + xoffset,
+ y - font_height * (lattr==LATTR_BOT) + text_adjust,
+ &line_box, wbuf, len, lpDx,
+ opaque && !(attr & TATTR_COMBINING));
+
+ /* And the shadow bold hack. */
+ if (bold_font_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
+ SetBkMode(hdc, TRANSPARENT);
+ ExtTextOutW(hdc, x + xoffset - 1,
+ y - font_height * (lattr ==
+ LATTR_BOT) + text_adjust,
+ ETO_CLIPPED, &line_box, wbuf, len, lpDx_maybe);
+ }
+ }