diff --git a/ui/scene_textlayout.py b/ui/scene_textlayout.py index 8ed6c21..decae05 100644 --- a/ui/scene_textlayout.py +++ b/ui/scene_textlayout.py @@ -450,7 +450,7 @@ def updateDrawOffsets(self): yoff = -non_bracket_br[1] - non_bracket_br[3] yoff = yoff - (line_width - non_bracket_br[3]) / 2 - elif vertical_force_aligncentel(char): + else: space_shift = 0 if num_lspaces > 0: space_shift = num_lspaces * cfmt.space_width @@ -472,15 +472,15 @@ def updateDrawOffsets(self): tbr, br = cfmt.punc_rect(char) yoff += (tbr.height() + cfmt.font_metrics.descent() - act_rect[3]) / 2 - else: - empty_spacing = num_lspaces * cfmt.space_width - if TEXTLAYOUT_QTVERSION: - xshift = max(line.naturalTextWidth() - cfmt.br.width(), 0) - else: - xshift = empty_spacing + # else: + # empty_spacing = num_lspaces * cfmt.space_width + # if TEXTLAYOUT_QTVERSION: + # xshift = max(line.naturalTextWidth() - cfmt.br.width(), 0) + # else: + # xshift = empty_spacing - xoff = -xshift - yoff = min(cfmt.br.top() - cfmt.tbr.top(), -cfmt.tbr.top() - line.ascent()) + empty_spacing + # xoff = -xshift + # yoff = min(cfmt.br.top() - cfmt.tbr.top(), -cfmt.tbr.top() - line.ascent()) + empty_spacing xy_offsets[0], xy_offsets[1] = xoff, yoff block = block.next() diff --git a/ui/textitem.py b/ui/textitem.py index 12b1860..ad03320 100644 --- a/ui/textitem.py +++ b/ui/textitem.py @@ -810,7 +810,7 @@ def setStrokeWidth(self, stroke_width: float, padding=True, repaint_background=T self.fontformat.stroke_width = stroke_width if stroke_width > 0 and padding: - p = self.layout.max_font_size(to_px=True) * stroke_width / 2 + p = self.layout.max_font_size(to_px=True) * (stroke_width + 0.05) / 2 self.setPadding(p) self._after_set_ffmt(cursor, repaint_background, restore_cursor, **after_kwargs) @@ -829,7 +829,8 @@ def setFontSize(self, value: float, repaint_background: bool = False, set_select if repaint_background: fs = pt2px(max(self.layout.max_font_size(), value)) self.layout.relayout_on_changed = False - self.setPadding(fs * self.fontformat.stroke_width / 2) + if self.fontformat.stroke_width > 0: + self.setPadding(fs * (self.fontformat.stroke_width + 0.05) / 2) self.layout.relayout_on_changed = True cfmt = QTextCharFormat() cfmt.setFontPointSize(value)