Пример #1
0
void break_up_text_into_lines(int wii,int fonnt, const char*todis) {
    if (fonnt == -1)
        fonnt = play.normal_font;

    //  char sofar[100];
    if (todis[0]=='&') {
        while ((todis[0]!=' ') & (todis[0]!=0)) todis++;
        if (todis[0]==' ') todis++;
    }
    numlines=0;
    longestline=0;

    // Don't attempt to display anything if the width is tiny
    if (wii < 3)
        return;

    int rr;

    if (game.options[OPT_RIGHTLEFTWRITE] == 0)
    {
        split_lines_leftright(todis, wii, fonnt);
    }
    else {
        // Right-to-left just means reverse the text then
        // write it as normal
        char *backwards = reverse_text(todis);
        split_lines_rightleft (backwards, wii, fonnt);
        free(backwards);
    }

    for (rr=0;rr<numlines;rr++) {
        if (wgettextwidth_compensate(lines[rr],fonnt) > longestline)
            longestline = wgettextwidth_compensate(lines[rr],fonnt);
    }
}
Пример #2
0
int GetTextWidth(char *text, int fontnum) {
  VALIDATE_STRING(text);
  if ((fontnum < 0) || (fontnum >= game.numfonts))
    quit("!GetTextWidth: invalid font number.");

  return divide_down_coordinate(wgettextwidth_compensate(text, fontnum));
}
Пример #3
0
void IAGSEngine::GetTextExtent (int32 font, const char *text, int32 *width, int32 *height) {
  if ((font < 0) || (font >= game.numfonts)) {
    if (width != NULL) width[0] = 0;
    if (height != NULL) height[0] = 0;
    return;
  }
    
  if (width != NULL)
    width[0] = wgettextwidth_compensate (text, font);
  if (height != NULL)
    height[0] = wgettextheight ((char*)text, font);
}
Пример #4
0
void split_lines_rightleft (char *todis, int wii, int fonnt) {
    // start on the last character
    char *thisline = todis + strlen(todis) - 1;
    char prevlwas, *prevline = NULL;
    // work backwards
    while (thisline >= todis) {

        int needBreak = 0;
        if (thisline <= todis) 
            needBreak = 1;
        // ignore \[ sequence
        else if ((thisline > todis) && (thisline[-1] == '\\')) { }
        else if (thisline[0] == '[') {
            needBreak = 1;
            thisline++;
        }
        else if (wgettextwidth_compensate(thisline, fonnt) >= wii) {
            // go 'back' to the nearest word
            while ((thisline[0] != ' ') && (thisline[0] != 0))
                thisline++;

            if (thisline[0] == 0)
                quit("!Single word too wide for window");

            thisline++;
            needBreak = 1;
        }

        if (needBreak) {
            strcpy(lines[numlines], thisline);
            removeBackslashBracket(lines[numlines]);
            numlines++;
            if (prevline) {
                prevline[0] = prevlwas;
            }
            thisline--;
            prevline = thisline;
            prevlwas = prevline[0];
            prevline[0] = 0;
        }

        thisline--;
    }
    if (prevline)
        prevline[0] = prevlwas;
}