MCPcopy Create free account
hub / github.com/SpartanJ/eepp / hardWrapText

Method hardWrapText

src/eepp/graphics/text.cpp:520–540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518}
519
520bool Text::hardWrapText( Font* font, const Uint32& fontSize, String& string, const Float& maxWidth,
521 const Uint32& style, const Uint32& tabWidth, const Float& outlineThickness,
522 std::optional<Float> tabOffset, Uint32 textHints ) {
523
524 if ( string.empty() || NULL == font )
525 return false;
526
527 LineWrapInfo lineWrap = LineWrap::computeLineBreaks(
528 string, font, fontSize, maxWidth, LineWrapMode::Word, style, outlineThickness,
529 tabOffset.has_value(), tabWidth, tabOffset ? *tabOffset : 0.f, textHints );
530
531 if ( lineWrap.wraps.size() <= 1 )
532 return false;
533
534 for ( Int64 i = lineWrap.wraps.size() - 1; i > 0; i-- ) {
535 if ( string[lineWrap.wraps[i]] != '\n' ) // Skip real line-breaks!
536 string.insert( lineWrap.wraps[i], '\n' );
537 }
538
539 return true;
540}
541
542bool Text::hardWrapText( String& string, const Float& maxWidth, const FontStyleConfig& config,
543 const Uint32& tabWidth, std::optional<Float> tabOffset,

Callers 2

UTESTFunction · 0.80
mainFunction · 0.80

Calls 3

emptyMethod · 0.45
sizeMethod · 0.45
insertMethod · 0.45

Tested by 1

UTESTFunction · 0.64