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

Method getBreakPos

Engine/source/gfx/gFont.cpp:511–553  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 2

getTextPositionMethod · 0.80
splitAtomListEmitMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected