CGE: Fix problem with calculating box sizes for text strings

This commit is contained in:
Paul Gilbert 2011-07-02 16:04:47 +10:00
parent 3469d1fb04
commit 1ab67c2124

View File

@ -80,7 +80,7 @@ uint16 FONT::Width(const char *text) {
uint16 w = 0; uint16 w = 0;
if (text) if (text)
while (* text) while (* text)
w += Wid[*(text++)]; w += Wid[(unsigned char)*(text++)];
return w; return w;
} }
@ -151,7 +151,7 @@ void TALK::Update(const char *tx) {
mw = k; mw = k;
k = 2 * hmarg; k = 2 * hmarg;
} else } else
k += _Font->Wid[*p]; k += _Font->Wid[(unsigned char)*p];
} }
if (k > mw) if (k > mw)
mw = k; mw = k;
@ -164,8 +164,8 @@ void TALK::Update(const char *tx) {
if (*tx == '|' || *tx == '\n') if (*tx == '|' || *tx == '\n')
m = TS[0]->_m + (ln += FONT_HIG + TEXT_LS) * mw + hmarg; m = TS[0]->_m + (ln += FONT_HIG + TEXT_LS) * mw + hmarg;
else { else {
int cw = _Font->Wid[*tx], i; int cw = _Font->Wid[(unsigned char)*tx], i;
uint8 *f = _Font->Map + _Font->Pos[*tx]; uint8 *f = _Font->Map + _Font->Pos[(unsigned char)*tx];
for (i = 0; i < cw; i++) { for (i = 0; i < cw; i++) {
uint8 *pp = m; uint8 *pp = m;
uint16 n; uint16 n;
@ -262,8 +262,8 @@ void TALK::PutLine(int line, const char *text) {
q = v + size; q = v + size;
while (* text) { while (* text) {
uint16 cw = _Font->Wid[*text], i; uint16 cw = _Font->Wid[(unsigned char)*text], i;
uint8 *fp = _Font->Map + _Font->Pos[*text]; uint8 *fp = _Font->Map + _Font->Pos[(unsigned char)*text];
for (i = 0; i < cw; i++) { for (i = 0; i < cw; i++) {
register uint16 b = fp[i]; register uint16 b = fp[i];
@ -310,8 +310,8 @@ void INFO_LINE::Update(const char *tx) {
uint8 *p = v + 2, * q = p + size; uint8 *p = v + 2, * q = p + size;
while (*tx) { while (*tx) {
uint16 cw = _Font->Wid[*tx]; uint16 cw = _Font->Wid[(unsigned char)*tx];
uint8 *fp = _Font->Map + _Font->Pos[*tx]; uint8 *fp = _Font->Map + _Font->Pos[(unsigned char)*tx];
for (uint16 i = 0; i < cw; i++) { for (uint16 i = 0; i < cw; i++) {
register uint16 b = fp[i]; register uint16 b = fp[i];