Example #1
0
def _get_qfont(font: fonts.FontFace) -> Optional[qg.QFont]:
    qfont = None
    if font:
        family = font.family
        italic = "italic" in font.style.lower()
        weight = _map_weight(font.weight)
        qfont = qg.QFont(family, weight=weight, italic=italic)
        # INFO: setting the stretch value makes results worse!
        # qfont.setStretch(_map_stretch(font.stretch))
    return qfont
Example #2
0
    def __init__(
        self,
        scene: Optional[qw.QGraphicsScene] = None,
        *,
        use_text_cache: bool = True,
        debug_draw_rect: bool = False,
        extra_lineweight_scaling: float = 2.0,
    ):
        """
        Args:
            extra_lineweight_scaling: compared to other backends,
                PyQt draws lines which appear thinner
        """
        super().__init__()
        self._scene = scene or qw.QGraphicsScene()  # avoids many type errors
        self._color_cache: Dict[Color, qg.QColor] = {}
        self._pattern_cache: Dict[PatternKey, int] = {}
        self._no_line = qg.QPen(qc.Qt.NoPen)
        self._no_fill = qg.QBrush(qc.Qt.NoBrush)

        self._text_renderer = TextRenderer(qg.QFont(), use_text_cache)
        self._line_renderer: PyQtLineRenderer
        self._extra_lineweight_scaling = extra_lineweight_scaling
        self._debug_draw_rect = debug_draw_rect