Loading ui/fontformat_commands.py +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ def ffmt_change_weight(param_name: str, values: str, act_ffmt: FontFormat, is_gl @font_formating() def ffmt_change_bold(param_name: str, values: str, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem] = None, **kwargs): set_kwargs = global_default_set_kwargs if is_global else local_default_set_kwargs values = [QFont.Bold if value else QFont.Normal for value in values] values = [QFont.Weight.Bold if value else QFont.Weight.Normal for value in values] # ffmt_change_weight('weight', values, act_ffmt, is_global, blkitems, **kwargs) for blkitem, value in zip(blkitems, values): blkitem.setFontWeight(value, **set_kwargs) Loading ui/textitem.py +4 −8 Original line number Diff line number Diff line Loading @@ -590,7 +590,7 @@ class TextBlkItem(QGraphicsTextItem): weight = font.weight() # https://doc.qt.io/qt-5/qfont.html#Weight-enum, 50 is normal if weight == 0: weight = 50 weight = QFont.Weight.Normal return FontFormat( font.family(), Loading Loading @@ -833,10 +833,6 @@ class TextBlkItem(QGraphicsTextItem): def setFontColor(self, value: Tuple, repaint_background: bool = False, set_selected: bool = False, restore_cursor: bool = False, force=False): cursor, after_kwargs = self._before_set_ffmt(set_selected, restore_cursor) if not self.document().isEmpty(): fraghtml = cursor.selection().toHtml() cursor.insertHtml(set_html_color(fraghtml, value)) else: cfmt = cursor.charFormat() cfmt.setForeground(QColor(*value)) self.set_cursor_cfmt(cursor, cfmt, True) Loading utils/fontformat.py +13 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,10 @@ def px2pt(px) -> float: return px / shared.LDPI * 72. fontweight_qt5_to_qt6 = {0: 100, 12: 200, 25: 300, 50: 400, 57: 500, 63: 600, 75: 700, 81: 800, 87: 900} fontweight_qt6_to_qt5 = {100: 0, 200: 12, 300: 25, 400: 50, 500: 57, 600: 63, 700: 75, 800: 81, 900: 87} @nested_dataclass class FontFormat(Config): Loading Loading @@ -52,6 +56,15 @@ class FontFormat(Config): self.shadow_color = text_block.shadow_color self.shadow_offset = text_block.shadow_offset def __post_init__(self): if self.weight is not None: if shared.FLAG_QT6 and self.weight < 100: if self.weight in fontweight_qt5_to_qt6: self.weight = fontweight_qt5_to_qt6[self.weight] if not shared.FLAG_QT6 and self.weight >= 100: if self.weight in fontweight_qt6_to_qt5: self.weight = fontweight_qt6_to_qt5[self.weight] def update_textblock_format(self, blk: TextBlock): blk.default_stroke_width = self.stroke_width blk.line_spacing = self.line_spacing Loading Loading
ui/fontformat_commands.py +1 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,7 @@ def ffmt_change_weight(param_name: str, values: str, act_ffmt: FontFormat, is_gl @font_formating() def ffmt_change_bold(param_name: str, values: str, act_ffmt: FontFormat, is_global: bool, blkitems: List[TextBlkItem] = None, **kwargs): set_kwargs = global_default_set_kwargs if is_global else local_default_set_kwargs values = [QFont.Bold if value else QFont.Normal for value in values] values = [QFont.Weight.Bold if value else QFont.Weight.Normal for value in values] # ffmt_change_weight('weight', values, act_ffmt, is_global, blkitems, **kwargs) for blkitem, value in zip(blkitems, values): blkitem.setFontWeight(value, **set_kwargs) Loading
ui/textitem.py +4 −8 Original line number Diff line number Diff line Loading @@ -590,7 +590,7 @@ class TextBlkItem(QGraphicsTextItem): weight = font.weight() # https://doc.qt.io/qt-5/qfont.html#Weight-enum, 50 is normal if weight == 0: weight = 50 weight = QFont.Weight.Normal return FontFormat( font.family(), Loading Loading @@ -833,10 +833,6 @@ class TextBlkItem(QGraphicsTextItem): def setFontColor(self, value: Tuple, repaint_background: bool = False, set_selected: bool = False, restore_cursor: bool = False, force=False): cursor, after_kwargs = self._before_set_ffmt(set_selected, restore_cursor) if not self.document().isEmpty(): fraghtml = cursor.selection().toHtml() cursor.insertHtml(set_html_color(fraghtml, value)) else: cfmt = cursor.charFormat() cfmt.setForeground(QColor(*value)) self.set_cursor_cfmt(cursor, cfmt, True) Loading
utils/fontformat.py +13 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,10 @@ def px2pt(px) -> float: return px / shared.LDPI * 72. fontweight_qt5_to_qt6 = {0: 100, 12: 200, 25: 300, 50: 400, 57: 500, 63: 600, 75: 700, 81: 800, 87: 900} fontweight_qt6_to_qt5 = {100: 0, 200: 12, 300: 25, 400: 50, 500: 57, 600: 63, 700: 75, 800: 81, 900: 87} @nested_dataclass class FontFormat(Config): Loading Loading @@ -52,6 +56,15 @@ class FontFormat(Config): self.shadow_color = text_block.shadow_color self.shadow_offset = text_block.shadow_offset def __post_init__(self): if self.weight is not None: if shared.FLAG_QT6 and self.weight < 100: if self.weight in fontweight_qt5_to_qt6: self.weight = fontweight_qt5_to_qt6[self.weight] if not shared.FLAG_QT6 and self.weight >= 100: if self.weight in fontweight_qt6_to_qt5: self.weight = fontweight_qt6_to_qt5[self.weight] def update_textblock_format(self, blk: TextBlock): blk.default_stroke_width = self.stroke_width blk.line_spacing = self.line_spacing Loading