mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-05-28 15:24:49 -05:00
Rationalise the mechanism in do_text_internal for providing the 'lpDx'
array to ExtTextOut: - move it inside the new big loop (this should fix a potential bug whereby the DBCS handling altered some elements of it but the loop did not actually step along it) - initialise it more sensibly - rename it to lpDx rather than IpDx, since as far as I can tell the latter name was derived from a misreading of the former in the Windows API docs. [originally from svn r9066]
This commit is contained in:
parent
46355d29ae
commit
a418e0d2dc
@ -3239,8 +3239,9 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
int text_adjust = 0;
|
int text_adjust = 0;
|
||||||
int xoffset = 0;
|
int xoffset = 0;
|
||||||
int maxlen, remaining, opaque;
|
int maxlen, remaining, opaque;
|
||||||
static int *IpDx = 0, IpDxLEN = 0;
|
static int *lpDx = NULL;
|
||||||
int *IpDxReal;
|
static int lpDx_len = 0;
|
||||||
|
int *lpDx_maybe;
|
||||||
|
|
||||||
lattr &= LATTR_MODE;
|
lattr &= LATTR_MODE;
|
||||||
|
|
||||||
@ -3249,17 +3250,6 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
if (attr & ATTR_WIDE)
|
if (attr & ATTR_WIDE)
|
||||||
char_width *= 2;
|
char_width *= 2;
|
||||||
|
|
||||||
if (len > IpDxLEN || IpDx[0] != char_width) {
|
|
||||||
int i;
|
|
||||||
if (len > IpDxLEN) {
|
|
||||||
sfree(IpDx);
|
|
||||||
IpDx = snewn(len + 16, int);
|
|
||||||
IpDxLEN = (len + 16);
|
|
||||||
}
|
|
||||||
for (i = 0; i < IpDxLEN; i++)
|
|
||||||
IpDx[i] = char_width;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only want the left half of double width lines */
|
/* Only want the left half of double width lines */
|
||||||
if (lattr != LATTR_NORM && x*2 >= term->cols)
|
if (lattr != LATTR_NORM && x*2 >= term->cols)
|
||||||
return;
|
return;
|
||||||
@ -3385,12 +3375,12 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
* If we're using a variable-pitch font, we unconditionally
|
* If we're using a variable-pitch font, we unconditionally
|
||||||
* draw the glyphs one at a time and centre them in their
|
* draw the glyphs one at a time and centre them in their
|
||||||
* character cells (which means in particular that we must
|
* character cells (which means in particular that we must
|
||||||
* disable the IpDx mechanism). This gives slightly odd but
|
* disable the lpDx mechanism). This gives slightly odd but
|
||||||
* generally reasonable results.
|
* generally reasonable results.
|
||||||
*/
|
*/
|
||||||
xoffset = char_width / 2;
|
xoffset = char_width / 2;
|
||||||
SetTextAlign(hdc, TA_TOP | TA_CENTER | TA_NOUPDATECP);
|
SetTextAlign(hdc, TA_TOP | TA_CENTER | TA_NOUPDATECP);
|
||||||
IpDxReal = NULL;
|
lpDx_maybe = NULL;
|
||||||
maxlen = 1;
|
maxlen = 1;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -3399,7 +3389,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
*/
|
*/
|
||||||
xoffset = 0;
|
xoffset = 0;
|
||||||
SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
|
SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
|
||||||
IpDxReal = IpDx;
|
lpDx_maybe = lpDx;
|
||||||
maxlen = len;
|
maxlen = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3408,6 +3398,18 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
text += len, remaining -= len, x += char_width * len) {
|
text += len, remaining -= len, x += char_width * len) {
|
||||||
len = (maxlen < remaining ? maxlen : remaining);
|
len = (maxlen < remaining ? maxlen : remaining);
|
||||||
|
|
||||||
|
if (len > lpDx_len) {
|
||||||
|
if (len > lpDx_len) {
|
||||||
|
lpDx_len = len * 9 / 8 + 16;
|
||||||
|
lpDx = sresize(lpDx, lpDx_len, int);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < len; i++)
|
||||||
|
lpDx[i] = char_width;
|
||||||
|
}
|
||||||
|
|
||||||
/* We're using a private area for direct to font. (512 chars.) */
|
/* We're using a private area for direct to font. (512 chars.) */
|
||||||
if (ucsdata.dbcs_screenfont && (text[0] & CSET_MASK) == CSET_ACP) {
|
if (ucsdata.dbcs_screenfont && (text[0] & CSET_MASK) == CSET_ACP) {
|
||||||
/* Ho Hum, dbcs fonts are a PITA! */
|
/* Ho Hum, dbcs fonts are a PITA! */
|
||||||
@ -3428,7 +3430,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
char dbcstext[2];
|
char dbcstext[2];
|
||||||
dbcstext[0] = text[mptr] & 0xFF;
|
dbcstext[0] = text[mptr] & 0xFF;
|
||||||
dbcstext[1] = text[mptr+1] & 0xFF;
|
dbcstext[1] = text[mptr+1] & 0xFF;
|
||||||
IpDx[nlen] += char_width;
|
lpDx[nlen] += char_width;
|
||||||
MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
|
MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
|
||||||
dbcstext, 2, uni_buf+nlen, 1);
|
dbcstext, 2, uni_buf+nlen, 1);
|
||||||
mptr++;
|
mptr++;
|
||||||
@ -3449,16 +3451,16 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
y - font_height * (lattr == LATTR_BOT) + text_adjust,
|
y - font_height * (lattr == LATTR_BOT) + text_adjust,
|
||||||
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
||||||
&line_box, uni_buf, nlen,
|
&line_box, uni_buf, nlen,
|
||||||
IpDxReal);
|
lpDx_maybe);
|
||||||
if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
||||||
SetBkMode(hdc, TRANSPARENT);
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
ExtTextOutW(hdc, x + xoffset - 1,
|
ExtTextOutW(hdc, x + xoffset - 1,
|
||||||
y - font_height * (lattr ==
|
y - font_height * (lattr ==
|
||||||
LATTR_BOT) + text_adjust,
|
LATTR_BOT) + text_adjust,
|
||||||
ETO_CLIPPED, &line_box, uni_buf, nlen, IpDxReal);
|
ETO_CLIPPED, &line_box, uni_buf, nlen, lpDx_maybe);
|
||||||
}
|
}
|
||||||
|
|
||||||
IpDx[0] = -1;
|
lpDx[0] = -1;
|
||||||
} else if (DIRECT_FONT(text[0])) {
|
} else if (DIRECT_FONT(text[0])) {
|
||||||
static char *directbuf = NULL;
|
static char *directbuf = NULL;
|
||||||
static int directlen = 0;
|
static int directlen = 0;
|
||||||
@ -3474,7 +3476,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
ExtTextOut(hdc, x + xoffset,
|
ExtTextOut(hdc, x + xoffset,
|
||||||
y - font_height * (lattr == LATTR_BOT) + text_adjust,
|
y - font_height * (lattr == LATTR_BOT) + text_adjust,
|
||||||
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
||||||
&line_box, directbuf, len, IpDxReal);
|
&line_box, directbuf, len, lpDx_maybe);
|
||||||
if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
||||||
SetBkMode(hdc, TRANSPARENT);
|
SetBkMode(hdc, TRANSPARENT);
|
||||||
|
|
||||||
@ -3490,7 +3492,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
ExtTextOut(hdc, x + xoffset - 1,
|
ExtTextOut(hdc, x + xoffset - 1,
|
||||||
y - font_height * (lattr ==
|
y - font_height * (lattr ==
|
||||||
LATTR_BOT) + text_adjust,
|
LATTR_BOT) + text_adjust,
|
||||||
ETO_CLIPPED, &line_box, directbuf, len, IpDxReal);
|
ETO_CLIPPED, &line_box, directbuf, len, lpDx_maybe);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* And 'normal' unicode characters */
|
/* And 'normal' unicode characters */
|
||||||
@ -3510,7 +3512,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
/* print Glyphs as they are, without Windows' Shaping*/
|
/* print Glyphs as they are, without Windows' Shaping*/
|
||||||
general_textout(hdc, x + xoffset,
|
general_textout(hdc, x + xoffset,
|
||||||
y - font_height * (lattr==LATTR_BOT) + text_adjust,
|
y - font_height * (lattr==LATTR_BOT) + text_adjust,
|
||||||
&line_box, wbuf, len, IpDx,
|
&line_box, wbuf, len, lpDx,
|
||||||
opaque && !(attr & TATTR_COMBINING));
|
opaque && !(attr & TATTR_COMBINING));
|
||||||
|
|
||||||
/* And the shadow bold hack. */
|
/* And the shadow bold hack. */
|
||||||
@ -3519,7 +3521,7 @@ void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|||||||
ExtTextOutW(hdc, x + xoffset - 1,
|
ExtTextOutW(hdc, x + xoffset - 1,
|
||||||
y - font_height * (lattr ==
|
y - font_height * (lattr ==
|
||||||
LATTR_BOT) + text_adjust,
|
LATTR_BOT) + text_adjust,
|
||||||
ETO_CLIPPED, &line_box, wbuf, len, IpDxReal);
|
ETO_CLIPPED, &line_box, wbuf, len, lpDx_maybe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user