- /* 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;
- IpDx[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,
- y - font_height * (lattr == LATTR_BOT) + text_adjust,
- ETO_CLIPPED | ETO_OPAQUE, &line_box, uni_buf, nlen, IpDx);
- if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
- SetBkMode(hdc, TRANSPARENT);
- ExtTextOutW(hdc, x - 1,
- y - font_height * (lattr ==
- LATTR_BOT) + text_adjust,
- ETO_CLIPPED, &line_box, uni_buf, nlen, IpDx);
- }
+ if (font_varpitch) {
+ /*
+ * If we're using a variable-pitch font, we unconditionally
+ * draw the glyphs one at a time and centre them in their
+ * character cells (which means in particular that we must
+ * disable the IpDx mechanism). This gives slightly odd but
+ * generally reasonable results.
+ */
+ xoffset = char_width / 2;
+ SetTextAlign(hdc, TA_TOP | TA_CENTER | TA_NOUPDATECP);
+ IpDxReal = NULL;
+ maxlen = 1;
+ } else {
+ /*
+ * In a fixed-pitch font, we draw the whole string in one go
+ * in the normal way.
+ */
+ xoffset = 0;
+ SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
+ IpDxReal = IpDx;
+ maxlen = len;
+ }