src/fixedfontwrap.cpp
// calculateTextLine ********
// According to the font characteristics, this method separates the first
// line of text it finds in a given multiline text, while keeping
// the characters which determine line break (0xA and 0xD) out of sight.

calculateTextLine
According to the font characteristics, this method separates the first
line of text it finds in a given multiline text, while keeping
the characters which determine line break (0xA and 0xD) out of sight.
calculateTextLine According to the font characteristics this method separates the first line of text it finds in a given multiline text while keeping the characters which determine line break ( 0xA and 0xD ) out of sight .
bool fixedFontClass::calculateTextLine(
	char* text,
	int textSize,
	int maxWidth,
	char** startOfLine,
	int* lineSize)
{
	bool endOfLoop=false;
	int maxWidthInChars=maxWidth/charW;
	char* thisChar=text;
	char* lastAcceptableEnd;
	char* tmpStartOfLine;
	while (thisChar-text<textSize && *thisChar==' ') thisChar++;
	tmpStartOfLine=thisChar;
	lastAcceptableEnd=thisChar;
	do{
		if (thisChar-text>=textSize ||
			*thisChar==0xA ||
			*thisChar==0xD) {
			lastAcceptableEnd=thisChar;
			endOfLoop=true;
		}
		if (!endOfLoop) {
			while (thisChar-text<textSize && *thisChar!=' ' && *thisChar!=0xA && *thisChar!=0xD)
				thisChar++;
			if (thisChar-tmpStartOfLine>maxWidthInChars) {
				if (lastAcceptableEnd==tmpStartOfLine) {
					lastAcceptableEnd=tmpStartOfLine+maxWidthInChars;
				}
				endOfLoop=true;
			}
			if (!endOfLoop) {
				lastAcceptableEnd=thisChar;
				while (thisChar-text<textSize && *thisChar==' ') thisChar++;
			}
		}
	}while (!endOfLoop);
	(*startOfLine)=tmpStartOfLine;
	(*lineSize)=lastAcceptableEnd-tmpStartOfLine;
	return true;
}
bool fixedFontClass :: calculateTextLine ( char * text , int textSize , int maxWidth , char * * startOfLine , int * lineSize ) { bool endOfLoop = false ; int maxWidthInChars = maxWidth / charW ; char * thisChar = text ; char * lastAcceptableEnd ; char * tmpStartOfLine ; while ( thisChar - text < textSize && * thisChar == ' ' ) thisChar ++ ; tmpStartOfLine = thisChar ; lastAcceptableEnd = thisChar ; do { if ( thisChar - text >= textSize || * thisChar == 0xA || * thisChar == 0xD ) { lastAcceptableEnd = thisChar ; endOfLoop = true ; } if ( ! endOfLoop ) { while ( thisChar - text < textSize && * thisChar != ' ' && * thisChar != 0xA && * thisChar != 0xD ) thisChar ++ ; if ( thisChar - tmpStartOfLine > maxWidthInChars ) { if ( lastAcceptableEnd == tmpStartOfLine ) { lastAcceptableEnd = tmpStartOfLine + maxWidthInChars ; } endOfLoop = true ; } if ( ! endOfLoop ) { lastAcceptableEnd = thisChar ; while ( thisChar - text < textSize && * thisChar == ' ' ) thisChar ++ ; } } } while ( ! endOfLoop ) ; ( * startOfLine ) = tmpStartOfLine ; ( * lineSize ) = lastAcceptableEnd - tmpStartOfLine ; return true ; }
calculateTextLine 
According to the font characteristics, this method separates the first
line of text it finds in a given multiline text, while keeping
the characters which determine line break (0xA and 0xD) out of sight.
calculateTextLine According to the font characteristics this method separates the first line of text it finds in a given multiline text while keeping the characters which determine line break ( 0xA and 0xD ) out of sight .
// string where to find the line
 // string size
 // max width for the text, in pixels
 // pointer to a char* which will point to the beginning of the next line of text, after executing this method
 // pointer to an integer which will contain the size of the line starting in *startOfLine, after executing this method
 // this will tell us when we finished the calculation
 // pointer to the char next to the latest character for this line
 // avoid all the initial spaces...
 // for every word...
 // check whether it's time to jump out of the text
 // look for the next non space character
 // check if this word fits in the text box
 // It doesn't fit... it's time to decide whether to
 // partition it or not (only partition it if
 // real necessary)
 // it's a word wider than the text box... draw it
 // in parts
 // in any case, it's time to end the loop
 // if it fitted, let's considerate this word into the
 // accepted line until now
 // avoid all the spaces...
 // save the values to return
 // all ok
