MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / getBreakPos

Method getBreakPos

Engine/source/gfx/gFont.cpp:510–552  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508}
509
510U32 GFont::getBreakPos(const UTF16 *str16, U32 slen, U32 width, bool breakOnWhitespace)
511{
512 // Some early out cases.
513 if(slen==0)
514 return 0;
515
516 U32 ret = 0;
517 U32 lastws = 0;
518 UTF16 c;
519 U32 charCount = 0;
520
521 for( charCount=0; charCount < slen; charCount++)
522 {
523 c = str16[charCount];
524 if(c == '\0')
525 break;
526
527 if(c == dT('\t'))
528 c = dT(' ');
529
530 if(!isValidChar(c))
531 {
532 ret++;
533 continue;
534 }
535
536 if(c == dT(' '))
537 lastws = ret+1;
538
539 const PlatformFont::CharInfo& rChar = getCharInfo(c);
540 if(rChar.width > width || rChar.xIncrement > width)
541 {
542 if(lastws && breakOnWhitespace)
543 return lastws;
544 return ret;
545 }
546
547 width -= rChar.xIncrement;
548
549 ret++;
550 }
551 return ret;
552}
553
554void GFont::wrapString(const UTF8 *txt, U32 lineWidth, Vector<U32> &startLineOffset, Vector<U32> &lineLen)
555{

Callers 2

getTextPositionMethod · 0.80
splitAtomListEmitMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected