Skip to content

Commit 4eab7ba

Browse files
committed
fix(steami_screen): adjust text width calculation and vertical positioning
1 parent 0800142 commit 4eab7ba

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/steami_screen/steami_screen/device.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def value(self, val, unit=None, at="CENTER", label=None,
122122
cx, cy = self.center
123123
char_w = self.CHAR_W * scale
124124
char_h = self.CHAR_H * scale
125-
tw = len(text) * char_w
125+
tw = len(text) * char_w // 2
126126

127127
# Compute vertical position: center the value+unit block
128128
if unit:
@@ -138,10 +138,10 @@ def value(self, val, unit=None, at="CENTER", label=None,
138138
y = vy + y_offset
139139
elif at == "W":
140140
x = self.width // 4 - tw // 2
141-
y = vy
141+
y = vy + y_offset
142142
elif at == "E":
143143
x = 3 * self.width // 4 - tw // 2
144-
y = vy
144+
y = vy + y_offset
145145
else:
146146
x, y = self._resolve(at, len(text), scale)
147147

@@ -155,7 +155,7 @@ def value(self, val, unit=None, at="CENTER", label=None,
155155

156156
# Optional unit below (medium font if backend supports it)
157157
if unit:
158-
unit_y = y + char_h + char_h // 3
158+
unit_y = y + char_h
159159
ux = x + tw // 2 - len(unit) * self.CHAR_W // 2
160160
if hasattr(self._d, 'draw_medium_text'):
161161
self._d.draw_medium_text(unit, ux, unit_y, LIGHT)

0 commit comments

Comments
 (0)