Ticket #8134: smush-frender.diff

File smush-frender.diff, 1.7 KB (added by eriktorbjorn, 21 years ago)

Patch against a November 20 CVS snapshot

  • scummvm/scumm/smush/frenderer.cpp

    diff -ur ScummVM-cvs20021120/scummvm/scumm/smush/frenderer.cpp ScummVM-cvs20021120+hack/scummvm/scumm/smush/frenderer.cpp
    old new  
    306306}
    307307
    308308bool FontRenderer::drawStringWrapCentered(const char * str, char * buffer, const Point & size, int32 x, int32 y, int32 width) const {
     309        int32 max_substr_width = 0;
    309310        debug(9, "FontRenderer::drawStringWrapCentered(%s, %d, %d)", str, x, y);
    310311        assert(strchr(str, '\n') == 0);
    311312        char * * words = split(str, ' ');
     
    324325        int32 space_width = charWidth(' ');
    325326
    326327        i = 0;
     328        width = MIN(width, size.getX());
    327329        while(i < nb_sub) {
    328330                int32 substr_width = sizes[i];
    329331                char * substr = new char[1000];
    330332                strcpy(substr, words[i]);
    331333                int32 j = i + 1;
    332334
    333                 while(j < nb_sub && (substr_width + space_width + sizes[j]) < size.getX()) {
     335                while(j < nb_sub && (substr_width + space_width + sizes[j]) < width) {
    334336                        substr_width += sizes[j++] + space_width;
    335337                }
    336338
     
    341343
    342344                substrings[nb_subs] = substr;
    343345                substr_widths[nb_subs++] = substr_width;
     346                max_substr_width = MAX(substr_width, max_substr_width);
    344347                i = j;
    345348                height += stringHeight(substr);
    346349        }
     
    355358                y = size.getY() - height;
    356359        }
    357360
     361        if(x - max_substr_width / 2 < 0) {
     362                x = max_substr_width / 2;
     363        } else if (x + max_substr_width / 2 >= size.getX()) {
     364                x = size.getX() - 1 - max_substr_width / 2;
     365        }
     366
    358367        for(i = 0; i < nb_subs; i++) {
    359368                int32 substr_width = substr_widths[i];
    360369                drawSubstring((const byte *)substrings[i], buffer, size, x - substr_width / 2, y);