Optionally return wraps width when computing breaks WIP.

This commit is contained in:
Martín Lucas Golini
2026-01-26 21:59:53 -03:00
parent efc361b654
commit b3b5f97ab8
4 changed files with 176 additions and 24 deletions

View File

@@ -15,6 +15,10 @@ struct LineWrapInfo {
Float paddingStart{ 0 };
};
struct LineWrapInfoEx : public LineWrapInfo {
std::vector<Float> wrapsWidth;
};
class EE_API LineWrap {
public:
static LineWrapMode toLineWrapMode( std::string mode );
@@ -55,12 +59,47 @@ class EE_API LineWrap {
Uint32 textHints = TextHints::None,
bool tabStops = false, Float initialXOffset = 0.f );
static LineWrapInfoEx computeLineBreaksEx(
const String::View& string, Font* font, Uint32 characterSize, Float maxWidth,
LineWrapMode mode, Uint32 fontStyle = 0, Float outlineThickness = 0.f,
bool keepIndentation = false, Uint32 tabWidth = 4,
Float whiteSpaceWidth = 0.f /* 0 = should calculate it */,
Uint32 textHints = TextHints::None, bool tabStops = false, Float initialXOffset = 0.f );
static LineWrapInfoEx computeLineBreaksEx(
const String& string, Font* font, Uint32 characterSize, Float maxWidth, LineWrapMode mode,
Uint32 fontStyle = 0, Float outlineThickness = 0.f, bool keepIndentation = false,
Uint32 tabWidth = 4, Float whiteSpaceWidth = 0.f /* 0 = should calculate it */,
Uint32 textHints = TextHints::None, bool tabStops = false, Float initialXOffset = 0.f );
static LineWrapInfoEx computeLineBreaksEx(
const String::View& string, const FontStyleConfig& fontStyle, Float maxWidth,
LineWrapMode mode, bool keepIndentation = false, Uint32 tabWidth = 4,
Float whiteSpaceWidth = 0.f /* 0 = should calculate it */,
Uint32 textHints = TextHints::None, bool tabStops = false, Float initialXOffset = 0.f );
static LineWrapInfoEx computeLineBreaksEx( const String& string,
const FontStyleConfig& fontStyle, Float maxWidth,
LineWrapMode mode, bool keepIndentation = false,
Uint32 tabWidth = 4, Float whiteSpaceWidth = 0.f,
Uint32 textHints = TextHints::None,
bool tabStops = false, Float initialXOffset = 0.f );
static Float computeOffsets( const String::View& string, Font* font, Uint32 characterSize,
Uint32 fontStyle, Float outlineThickness, Uint32 tabWidth = 0.f,
Float maxWidth = 0.f, bool tabStops = false );
static Float computeOffsets( const String::View& string, const FontStyleConfig& fontStyle,
Uint32 tabWidth, Float maxWidth = 0.f, bool tabStops = false );
protected:
template <typename T>
static T computeLineBreaksInternal( const String::View& string, Font* font,
Uint32 characterSize, Float maxWidth, LineWrapMode mode,
Uint32 fontStyle, Float outlineThickness,
bool keepIndentation, Uint32 tabWidth,
Float whiteSpaceWidth, Uint32 textDrawHints, bool tabStops,
Float initialXOffset );
};
} // namespace EE::Graphics

View File

@@ -15,7 +15,7 @@ class Font;
struct ShapedTextParagraph {
std::vector<ShapedGlyph> shapedGlyphs;
LineWrapInfo wrapInfo;
LineWrapInfoEx wrapInfo;
Sizef size;
};