From 112b3f0f073c9296572badf5f2ea71a7786cc4e0 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 4 Jun 2021 11:30:15 -0400 Subject: [PATCH] Drop hidpi font size hacking from contents labels --- piker/ui/_graphics/_cursor.py | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/piker/ui/_graphics/_cursor.py b/piker/ui/_graphics/_cursor.py index 0919f6f9..a32a3870 100644 --- a/piker/ui/_graphics/_cursor.py +++ b/piker/ui/_graphics/_cursor.py @@ -31,6 +31,7 @@ from .._style import ( _xaxis_at, hcolor, _font, + _font_small, ) from .._axes import YAxisLabel, XAxisLabel from ...log import get_logger @@ -109,7 +110,7 @@ class LineDot(pg.CurvePoint): return False -# TODO: change this into our own ``Label`` +# TODO: change this into our own ``_label.Label`` class ContentsLabel(pg.LabelItem): """Label anchored to a ``ViewBox`` typically for displaying datum-wise points from the "viewed" contents. @@ -138,22 +139,14 @@ class ContentsLabel(pg.LabelItem): justify_text: str = 'left', font_size: Optional[int] = None, ) -> None: - font_size = font_size or _font.font.pixelSize() + + font_size = font_size or _font_small.px_size super().__init__( justify=justify_text, size=f'{str(font_size)}px' ) - if _font._physical_dpi >= 97: - # ad-hoc scale it based on boundingRect - # TODO: need proper fix for this? - typical_br = _font._qfm.boundingRect('Qyp') - anchor_font_size = math.ceil(typical_br.height() * 1.25) - - else: - anchor_font_size = font_size - # anchor to viewbox self.setParentItem(chart._vb) chart.scene().addItem(self) @@ -165,7 +158,7 @@ class ContentsLabel(pg.LabelItem): ydim = margins[1] if inspect.isfunction(margins[1]): - margins = margins[0], ydim(anchor_font_size) + margins = margins[0], ydim(font_size) self.anchor(itemPos=index, parentPos=index, offset=margins)