diff --git a/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout-2.webp b/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout-2.webp
index f658020cb..1a7acfa91 100644
Binary files a/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout-2.webp and b/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout-2.webp differ
diff --git a/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout-3.webp b/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout-3.webp
index 340f7f8ee..6a3be4b5a 100644
Binary files a/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout-3.webp and b/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout-3.webp differ
diff --git a/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout.webp b/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout.webp
index 82dd9da68..9b9f1dd90 100644
Binary files a/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout.webp and b/bin/unit_tests/assets/html/eepp-uihtmltable-complex-layout.webp differ
diff --git a/src/eepp/graphics/richtext.cpp b/src/eepp/graphics/richtext.cpp
index 5e35eaace..6030aa17c 100644
--- a/src/eepp/graphics/richtext.cpp
+++ b/src/eepp/graphics/richtext.cpp
@@ -289,7 +289,7 @@ Sizef RichText::getPixelsSize() {
void RichText::addSpan( const String& text, const FontStyleConfig& style, const Rectf& margin,
const Rectf& padding ) {
- if ( text.empty() )
+ if ( text.empty() && margin == Rectf::Zero && padding == Rectf::Zero )
return;
auto span = std::make_shared();
@@ -312,7 +312,7 @@ void RichText::addCustomSize( const Sizef& size, bool isBlock ) {
}
void RichText::addSpan( const String& text, const FontStyleConfig& style ) {
- addSpan( text, style, Rectf(), Rectf() );
+ addSpan( text, style, Rectf::Zero, Rectf::Zero );
}
void RichText::addSpan( const String& text, Font* font, Uint32 characterSize, Color color,
@@ -457,9 +457,20 @@ void RichText::updateLayout() {
for ( auto& block : mBlocks ) {
if ( auto pText = std::get_if( &block ) ) {
auto& span = pText->text;
- if ( !span || span->getString().empty() )
+ if ( !span )
continue;
+ if ( span->getString().empty() ) {
+ Float l = pText->margin.Left + pText->padding.Left;
+ Float r = pText->margin.Right + pText->padding.Right;
+ if ( l <= 0 && r <= 0 )
+ continue;
+ curX += l + r;
+ if ( !mLines.empty() )
+ mLines.back().width += l + r;
+ continue;
+ }
+
auto& fontStyle = span->getFontStyleConfig();
if ( !fontStyle.Font )
continue;
diff --git a/src/eepp/ui/uirichtext.cpp b/src/eepp/ui/uirichtext.cpp
index 57179aab8..84d19f56c 100644
--- a/src/eepp/ui/uirichtext.cpp
+++ b/src/eepp/ui/uirichtext.cpp
@@ -659,11 +659,18 @@ void UIRichText::rebuildRichText( UILayout* container, RichText& richText, Intri
if ( widget->isType( UI_TYPE_HTML_WIDGET ) &&
widget->asType()->isMergeable() ) {
UITextSpan* span = widget->asType();
- if ( !span->getText().empty() && NULL != span->getFontStyleConfig().Font ) {
- Rectf margin = span->getLayoutPixelsMargin();
- Rectf padding = span->getPixelsPadding();
+ Rectf margin = span->getLayoutPixelsMargin();
+ Rectf padding = span->getPixelsPadding();
+ bool hasOwnText = !span->getText().empty() && NULL != span->getFontStyleConfig().Font;
+
+ if ( hasOwnText ) {
richText.addSpan( span->getText(), span->getFontStyleConfig(), margin, padding );
+ } else if ( margin.Left > 0 || margin.Top > 0 || padding.Left > 0 || padding.Top > 0 ) {
+ Rectf leftOnly( margin.Left, margin.Top, 0, 0 );
+ Rectf padLeftOnly( padding.Left, padding.Top, 0, 0 );
+ richText.addSpan( "", span->getFontStyleConfig(), leftOnly, padLeftOnly );
}
+
Node* spanChild = span->getFirstChild();
while ( spanChild != NULL ) {
bool isOutOfFlow = spanChild->isType( UI_TYPE_HTML_WIDGET ) &&
@@ -672,6 +679,13 @@ void UIRichText::rebuildRichText( UILayout* container, RichText& richText, Intri
processNodeRef( spanChild, processNodeRef );
spanChild = spanChild->getNextNode();
}
+
+ if ( !hasOwnText && ( margin.Right > 0 || margin.Bottom > 0 || padding.Right > 0 ||
+ padding.Bottom > 0 ) ) {
+ Rectf rightOnly( 0, 0, margin.Right, margin.Bottom );
+ Rectf padRightOnly( 0, 0, padding.Right, padding.Bottom );
+ richText.addSpan( "", span->getFontStyleConfig(), rightOnly, padRightOnly );
+ }
} else if ( widget->isType( UI_TYPE_BR ) ) {
richText.addSpan( "\n",
widget->asType()->getRichText().getFontStyleConfig() );