GRAPHICS: MACGUI: text length should not bigger than maxWidth - 1
This commit is contained in:
parent
a317110704
commit
948604d79d
2 changed files with 5 additions and 5 deletions
|
@ -419,7 +419,7 @@ void MacFONTFont::drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color)
|
||||||
|
|
||||||
// due to the way we are handling the generated fonts. we only add the kerning offset for the original font
|
// due to the way we are handling the generated fonts. we only add the kerning offset for the original font
|
||||||
if (!_data._slant)
|
if (!_data._slant)
|
||||||
x += glyph->kerningOffset;
|
x += glyph->kerningOffset;
|
||||||
|
|
||||||
if (x >= dst->w)
|
if (x >= dst->w)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -275,7 +275,7 @@ MacFontRun MacText::getFgColor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// we are doing this because we may need to dealing with the plain byte. See ctor of mactext which contains String str instead of U32String str
|
// we are doing this because we may need to dealing with the plain byte. See ctor of mactext which contains String str instead of U32String str
|
||||||
// thus, if we are passing the str, meaning we are using plainByteMode. And when we calculating the string width. we need to convert it to it's orignal state first;
|
// thus, if we are passing the str, meaning we are using plainByteMode. And when we calculate the string width. we need to convert it to it's original state first;
|
||||||
int MacText::getStringWidth(MacFontRun &format, const Common::U32String &str) {
|
int MacText::getStringWidth(MacFontRun &format, const Common::U32String &str) {
|
||||||
if (format.plainByteMode())
|
if (format.plainByteMode())
|
||||||
return format.getFont()->getStringWidth(Common::convertFromU32String(str, format.getEncoding()));
|
return format.getFont()->getStringWidth(Common::convertFromU32String(str, format.getEncoding()));
|
||||||
|
@ -740,7 +740,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
|
||||||
D(9, "curWidth %d word_width %d", cur_width, word_width);
|
D(9, "curWidth %d word_width %d", cur_width, word_width);
|
||||||
// if cur_width == 0 but there`s chunks, meaning there must be empty string here
|
// if cur_width == 0 but there`s chunks, meaning there must be empty string here
|
||||||
// if cur_width == 0, then you don`t have to add a newline for it
|
// if cur_width == 0, then you don`t have to add a newline for it
|
||||||
if (cur_width + word_width > _maxWidth && cur_width != 0) {
|
if (cur_width + word_width >= _maxWidth && cur_width != 0) {
|
||||||
++curLine;
|
++curLine;
|
||||||
_textLines.insert_at(curLine, MacTextLine());
|
_textLines.insert_at(curLine, MacTextLine());
|
||||||
}
|
}
|
||||||
|
@ -778,7 +778,7 @@ void MacText::splitString(const Common::U32String &str, int curLine) {
|
||||||
} else {
|
} else {
|
||||||
char_width = word[i].getFont()->getCharWidth(c);
|
char_width = word[i].getFont()->getCharWidth(c);
|
||||||
}
|
}
|
||||||
if (char_width + tmp_width + cur_width > _maxWidth) {
|
if (char_width + tmp_width + cur_width >= _maxWidth) {
|
||||||
++curLine;
|
++curLine;
|
||||||
_textLines.insert_at(curLine, MacTextLine());
|
_textLines.insert_at(curLine, MacTextLine());
|
||||||
_textLines[curLine].chunks.push_back(word[i]);
|
_textLines[curLine].chunks.push_back(word[i]);
|
||||||
|
@ -900,7 +900,7 @@ void MacText::render(int from, int to, int shadow) {
|
||||||
|
|
||||||
// TODO: _textMaxWidth, when -1, was not rendering ANY text.
|
// TODO: _textMaxWidth, when -1, was not rendering ANY text.
|
||||||
for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
|
for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
|
||||||
debug(9, "MacText::render: line %d[%d] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
|
debug(0, "MacText::render: line %d[%d] h:%d at %d,%d (%s) fontid: %d on %dx%d, fgcolor: %d bgcolor: %d, font: %p",
|
||||||
i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
|
i, j, _textLines[i].height, xOffset, _textLines[i].y, _textLines[i].chunks[j].text.encode().c_str(),
|
||||||
_textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
|
_textLines[i].chunks[j].fontId, _surface->w, _surface->h, _textLines[i].chunks[j].fgcolor, _bgcolor,
|
||||||
(const void *)_textLines[i].chunks[j].getFont());
|
(const void *)_textLines[i].chunks[j].getFont());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue