(self)
| 83 | return path |
| 84 | |
| 85 | def _natural_text_rect(self) -> QRectF: |
| 86 | hdr_font = QFont(COMP_REFDES_FONT_FAMILY) |
| 87 | hdr_font.setBold(True) |
| 88 | hdr_font.setPointSizeF(COMP_LABEL_FONT_SIZE) |
| 89 | body_font = QFont(COMP_REFDES_FONT_FAMILY) |
| 90 | body_font.setPointSizeF(COMP_LABEL_FONT_SIZE) |
| 91 | |
| 92 | fm_h = QFontMetricsF(hdr_font) |
| 93 | fm_b = QFontMetricsF(body_font) |
| 94 | |
| 95 | lines = self._text_display_lines() |
| 96 | pad = fm_b.height() * 0.3 |
| 97 | line_h = fm_b.height() * _LINE_SPACING |
| 98 | |
| 99 | widths = [fm_h.horizontalAdvance(lines[0])] + [ |
| 100 | fm_b.horizontalAdvance(l) for l in lines[1:] |
| 101 | ] |
| 102 | max_w = max(widths) if widths else 10.0 |
| 103 | total_w = max_w + 2 * pad |
| 104 | total_h = pad + fm_h.height() + len(lines[1:]) * line_h + pad |
| 105 | return QRectF(0, 0, max(1.0, total_w), max(1.0, total_h)) |
| 106 | |
| 107 | # ── paint ───────────────────────────────────────────────────────────────── |
| 108 |
no test coverage detected