diff --git a/pygame_gui/core/text/html_parser.py b/pygame_gui/core/text/html_parser.py
index 39b4c960..96bcb78b 100644
--- a/pygame_gui/core/text/html_parser.py
+++ b/pygame_gui/core/text/html_parser.py
@@ -255,7 +255,7 @@ def _handle_line_break(self):
antialiased=self.current_style['antialiased'],
script=self.current_style['script'],
direction=self.current_style['direction'])
- dimensions = (current_font.get_rect(' ').width,
+ dimensions = (4,
int(round(self.current_style['font_size'] *
self.line_spacing)))
chunk = self.create_styled_text_chunk('')
diff --git a/pygame_gui/core/text/line_break_layout_rect.py b/pygame_gui/core/text/line_break_layout_rect.py
index 97d2eff4..c540400f 100644
--- a/pygame_gui/core/text/line_break_layout_rect.py
+++ b/pygame_gui/core/text/line_break_layout_rect.py
@@ -39,4 +39,5 @@ def finalise(self,
self.select_surf = Surface((self.selection_chunk_width, row_bg_height), flags=pygame.SRCALPHA)
self.select_surf.fill(self.selection_colour)
target_surface.blit(self.select_surf, self.topleft, special_flags=pygame.BLEND_PREMULTIPLIED)
+ # should be cleared by row
diff --git a/pygame_gui/core/text/text_box_layout.py b/pygame_gui/core/text/text_box_layout.py
index 4502b8a0..ee09cae0 100644
--- a/pygame_gui/core/text/text_box_layout.py
+++ b/pygame_gui/core/text/text_box_layout.py
@@ -186,7 +186,7 @@ def _add_row_to_layout(self, current_row: TextBoxLayoutRow, last_row=False):
# otherwise we add infinite rows with no height
# instead add a line break rect to an empty row.
if len(current_row.items) == 0 and not last_row:
- current_row.add_item(LineBreakLayoutRect(dimensions=(2, self.last_row_height),
+ current_row.add_item(LineBreakLayoutRect(dimensions=(4, self.last_row_height),
font=current_row.fall_back_font))
if current_row not in self.layout_rows:
self.layout_rows.append(current_row)
@@ -903,6 +903,9 @@ def set_text_selection(self, start_index, end_index):
if self.finalised_surface is not None:
for row in rows_to_finalise:
row.finalise(self.finalised_surface)
+ for floating_rect in self.floating_rects:
+ floating_rect.finalise(self.finalised_surface,
+ self.view_rect, 0, 0, 0)
def _find_chunk_and_chunk_x(self, index: int):
found_chunk = None
diff --git a/pygame_gui/core/text/text_box_layout_row.py b/pygame_gui/core/text/text_box_layout_row.py
index 344d3656..013a46e2 100644
--- a/pygame_gui/core/text/text_box_layout_row.py
+++ b/pygame_gui/core/text/text_box_layout_row.py
@@ -364,7 +364,7 @@ def clear(self):
"""
if self.target_surface is not None and self.surf_row_dirty:
slightly_wider_rect = pygame.Rect(self.x, self.y,
- self.layout.view_rect.width,
+ self.width + self.cursor_draw_width,
self.height)
self.target_surface.fill(pygame.Color('#00000000'), slightly_wider_rect)
self.surf_row_dirty = False
diff --git a/pygame_gui/core/text/text_line_chunk.py b/pygame_gui/core/text/text_line_chunk.py
index ad453d90..19d7ef00 100644
--- a/pygame_gui/core/text/text_line_chunk.py
+++ b/pygame_gui/core/text/text_line_chunk.py
@@ -190,7 +190,7 @@ def finalise(self,
if self.underlined:
self.font.underline_adjustment = 0.5
- surface = self._draw_text(chunk_draw_height, chunk_draw_width,
+ surface = self._draw_text(chunk_draw_height, chunk_draw_width, text_shadow_width,
chunk_x_origin, final_str_text, row_bg_height, row_chunk_origin)
target_surface = self._finalise_horizontal_scroll(target_area,
@@ -213,7 +213,7 @@ def _finalise_horizontal_scroll(self, target_area, text_shadow_width, x_scroll_o
target_surface, surface):
# sort out horizontal scrolling
final_pos = (max(target_area.left, self.left - x_scroll_offset),
- self.top - self.origin_row_y_adjust + text_shadow_width)
+ self.top - self.origin_row_y_adjust)
distance_to_lhs_overlap = self.left - target_area.left
lhs_overlap = max(0, x_scroll_offset - distance_to_lhs_overlap)
remaining_rhs_space = target_area.width - (final_pos[0] - target_area.left)
@@ -264,11 +264,12 @@ def _handle_bg_selection_and_bg_drawing(self, size) -> pygame.Surface:
return surface
- def _handle_text_selection_and_text_drawing(self, final_str_text, chunk_draw_width, chunk_draw_height,
- chunk_x_origin, row_chunk_origin) -> pygame.Surface:
+ def _handle_text_selection_and_text_drawing(self, final_str_text, chunk_draw_width, text_shadow_width,
+ chunk_draw_height, chunk_x_origin, row_chunk_origin) -> pygame.Surface:
text_surface: pygame.Surface = self.font.render_premul_to(final_str_text, Color('#FFFFFFFF'),
surf_size=(chunk_draw_width, chunk_draw_height),
- surf_position=(chunk_x_origin, row_chunk_origin))
+ surf_position=(chunk_x_origin,
+ row_chunk_origin + text_shadow_width))
if (self.selection_rect is not None
and (self.selection_rect.width != 0 or self.selection_rect.height != 0)
@@ -301,11 +302,11 @@ def _handle_text_selection_and_text_drawing(self, final_str_text, chunk_draw_wid
return text_surface
- def _draw_text(self, chunk_draw_height, chunk_draw_width, chunk_x_origin,
+ def _draw_text(self, chunk_draw_height, chunk_draw_width, text_shadow_width, chunk_x_origin,
final_str_text, row_bg_height, row_chunk_origin):
- text_surface = self._handle_text_selection_and_text_drawing(final_str_text, chunk_draw_width, chunk_draw_height,
- chunk_x_origin, row_chunk_origin)
+ text_surface = self._handle_text_selection_and_text_drawing(final_str_text, chunk_draw_width, text_shadow_width,
+ chunk_draw_height, chunk_x_origin, row_chunk_origin)
surface = self._handle_bg_selection_and_bg_drawing((chunk_draw_width, row_bg_height))
# center the text in the line
@@ -319,7 +320,7 @@ def _draw_text(self, chunk_draw_height, chunk_draw_width, chunk_x_origin,
text_rect.centery = surface.get_rect().centery
# apply any shadow effects
self._apply_shadow_effect(surface, text_rect, final_str_text,
- text_surface, (chunk_x_origin, row_chunk_origin))
+ text_surface, (chunk_x_origin, row_chunk_origin + text_shadow_width))
surface.blit(text_surface, text_rect, special_flags=BLEND_PREMULTIPLIED)
return surface