src/fixedfontwrap.cpp
// privateDrawMultilineText ********
// This method is used to draw a text in a given surface, with any
// alignment, dividing it in multiple lines as it's needed, or to
// calculate the size of such a text, or both... method to be used only
// by the class itself

privateDrawMultilineText
This method is used to draw a text in a given surface, with any
alignment, dividing it in multiple lines as it's needed, or to
calculate the size of such a text, or both... method to be used only
by the class itself
privateDrawMultilineText This method is used to draw a text in a given surface with any alignment dividing it in multiple lines as it ' s needed or to calculate the size of such a text or both ... method to be used only by the class itself
bool fixedFontClass::privateDrawMultilineText(
	ddSurfaceClass& srfTo,
	char* text,
	int textSize,
	int x, int y,
	int boxWidth, int boxHeight,
	bool transparent,
	alignEnum alignment,
	bool drawText,
	int* definitiveX, int* definitiveY,
	int* definitiveW, int* definitiveH)
{
	char* currChar=text;
	int currX=x, currY=y;
	int lineSize;
	int tempDX=x+boxWidth, tempDY=y+boxHeight, tempDX2=x, tempDY2=y;
	int lastDX, lastDY, lastDW, lastDH;
	if (boxWidth<charW) {
		if (definitiveX!=NULL) (*definitiveX)=x;
		if (definitiveY!=NULL) (*definitiveY)=y;
		if (definitiveW!=NULL) (*definitiveW)=0;
		if (definitiveH!=NULL) (*definitiveH)=0;
		return true;
	}
	while(currChar-text<textSize) {
		if (!calculateTextLine(
			currChar,  textSize-(currChar-text),
			boxWidth,
			&currChar, &lineSize)) {
			return false;
		}
			if (!privateDrawTextLine(
				srfTo,
				currChar, lineSize,
				currX, currY,
				boxWidth, boxHeight,
				transparent, alignment,
				drawText,
				&lastDX, &lastDY, &lastDW, &lastDH
				)) {
				return false;
			}
		tempDX=MIN(tempDX, lastDX);
		tempDY=MIN(tempDY, lastDY);
		tempDX2=MAX(tempDX2, lastDX+lastDW);
		tempDY2=MAX(tempDY2, lastDY+lastDH);
		currChar+=lineSize;
		if (currChar-text<textSize) {
			if (*currChar==0xD) {
				currChar++;
				if (currChar-text<textSize && *currChar==0xA) currChar++;
			} else if (*currChar==0xA) {
				currChar++;
			}
		}
		currY+=charH;
	}
	if (definitiveX!=NULL) (*definitiveX)=tempDX;
	if (definitiveY!=NULL) (*definitiveY)=tempDY;
	if (definitiveW!=NULL) (*definitiveW)=tempDX2-tempDX;
	if (definitiveH!=NULL) (*definitiveH)=tempDY2-tempDY;
	return true;
}
bool fixedFontClass :: privateDrawMultilineText ( ddSurfaceClass & srfTo , char * text , int textSize , int x , int y , int boxWidth , int boxHeight , bool transparent , alignEnum alignment , bool drawText , int * definitiveX , int * definitiveY , int * definitiveW , int * definitiveH ) { char * currChar = text ; int currX = x , currY = y ; int lineSize ; int tempDX = x + boxWidth , tempDY = y + boxHeight , tempDX2 = x , tempDY2 = y ; int lastDX , lastDY , lastDW , lastDH ; if ( boxWidth < charW ) { if ( definitiveX != NULL ) ( * definitiveX ) = x ; if ( definitiveY != NULL ) ( * definitiveY ) = y ; if ( definitiveW != NULL ) ( * definitiveW ) = 0 ; if ( definitiveH != NULL ) ( * definitiveH ) = 0 ; return true ; } while ( currChar - text < textSize ) { if ( ! calculateTextLine ( currChar , textSize - ( currChar - text ) , boxWidth , & currChar , & lineSize ) ) { return false ; } if ( ! privateDrawTextLine ( srfTo , currChar , lineSize , currX , currY , boxWidth , boxHeight , transparent , alignment , drawText , & lastDX , & lastDY , & lastDW , & lastDH ) ) { return false ; } tempDX = MIN ( tempDX , lastDX ) ; tempDY = MIN ( tempDY , lastDY ) ; tempDX2 = MAX ( tempDX2 , lastDX + lastDW ) ; tempDY2 = MAX ( tempDY2 , lastDY + lastDH ) ; currChar += lineSize ; if ( currChar - text < textSize ) { if ( * currChar == 0xD ) { currChar ++ ; if ( currChar - text < textSize && * currChar == 0xA ) currChar ++ ; } else if ( * currChar == 0xA ) { currChar ++ ; } } currY += charH ; } if ( definitiveX != NULL ) ( * definitiveX ) = tempDX ; if ( definitiveY != NULL ) ( * definitiveY ) = tempDY ; if ( definitiveW != NULL ) ( * definitiveW ) = tempDX2 - tempDX ; if ( definitiveH != NULL ) ( * definitiveH ) = tempDY2 - tempDY ; return true ; }
privateDrawMultilineText 
This method is used to draw a text in a given surface, with any
alignment, dividing it in multiple lines as it's needed, or to
calculate the size of such a text, or both... method to be used only
by the class itself
privateDrawMultilineText This method is used to draw a text in a given surface with any alignment dividing it in multiple lines as it ' s needed or to calculate the size of such a text or both ... method to be used only by the class itself
// surface where to draw the text
 // text to draw
 // size of the string to draw
 // position where to draw the text
 // size of the text box (used for clipping)
 // will the text be transparent?
 // text alignment, either FILE_DDWRAP_ALIGN_LEFT, FILE_DDWRAP_ALIGN_CENTER or FILE_DDWRAP_ALIGN_RIGHT
 // tells whether we'll draw the text, or only calculate it
 // pointer to variables where to return the actual x and y coordinates (and box size) where the text was placed... if null, they aren't used
 // temporary variables to be used while calculating the definitive
 // text size...
 // one exceptional case: if width is lower than the character
 // width, there is nothing to be drawn
 // return an ok error code, but do nothing really, and
 // notify the box is an empty one
 // calculate the next text line
 // text and text size
 // maxWidth
 // to be returned by the function
 // error
 // draw the line...
 //		if (lineSize!=0) {
 // the surface
 // text and text size
 // line position
 // text box size
 // some other stuff
 // should we draw the text?
 // where to store the real text box coordinates and size
 // error
 //		}
 // keep calculating the smallest text box which covers the text
 // increment the position in the text...
 // if we found a 0xD, let's see if there is a 0xA grouped with
 // it...
 // increment y...
 // return the text size data
