| 508 | } |
| 509 | |
| 510 | U32 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 | |
| 554 | void GFont::wrapString(const UTF8 *txt, U32 lineWidth, Vector<U32> &startLineOffset, Vector<U32> &lineLen) |
| 555 | { |
no outgoing calls
no test coverage detected