Skip to content

Commit c30d09d

Browse files
pd0wmspektor56
authored andcommitted
ui: change alerts to Inter (commaai#24937)
* ui: change alerts to Inter * fix up test
1 parent 00b85a9 commit c30d09d

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

selfdrive/controls/tests/test_alerts.py

+7-10
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,17 @@ def test_events_defined(self):
4848
# ensure alert text doesn't exceed allowed width
4949
def test_alert_text_length(self):
5050
font_path = os.path.join(BASEDIR, "selfdrive/assets/fonts")
51-
regular_font_path = os.path.join(font_path, "opensans_semibold.ttf")
52-
bold_font_path = os.path.join(font_path, "opensans_semibold.ttf")
53-
semibold_font_path = os.path.join(font_path, "opensans_semibold.ttf")
54-
55-
max_text_width = 1920 - 300 # full screen width is useable, minus sidebar
56-
# TODO: get exact scale factor. found this empirically, works well enough
57-
font_scale_factor = 1.55 # factor to scale from nanovg units to PIL
51+
regular_font_path = os.path.join(font_path, "Inter-SemiBold.ttf")
52+
bold_font_path = os.path.join(font_path, "Inter-Bold.ttf")
53+
semibold_font_path = os.path.join(font_path, "Inter-SemiBold.ttf")
5854

55+
max_text_width = 2160 - 300 # full screen width is useable, minus sidebar
5956
draw = ImageDraw.Draw(Image.new('RGB', (0, 0)))
6057

6158
fonts = {
62-
AlertSize.small: [ImageFont.truetype(semibold_font_path, int(40 * font_scale_factor))],
63-
AlertSize.mid: [ImageFont.truetype(bold_font_path, int(48 * font_scale_factor)),
64-
ImageFont.truetype(regular_font_path, int(36 * font_scale_factor))],
59+
AlertSize.small: [ImageFont.truetype(semibold_font_path, 74)],
60+
AlertSize.mid: [ImageFont.truetype(bold_font_path, 88),
61+
ImageFont.truetype(regular_font_path, 66)],
6562
}
6663

6764
for alert in ALERTS:

selfdrive/ui/qt/onroad.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,18 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
146146
p.setPen(QColor(0xff, 0xff, 0xff));
147147
p.setRenderHint(QPainter::TextAntialiasing);
148148
if (alert.size == cereal::ControlsState::AlertSize::SMALL) {
149-
configFont(p, "Open Sans", 74, "SemiBold");
149+
configFont(p, "Inter", 74, "SemiBold");
150150
p.drawText(r, Qt::AlignCenter, alert.text1);
151151
} else if (alert.size == cereal::ControlsState::AlertSize::MID) {
152-
configFont(p, "Open Sans", 88, "Bold");
152+
configFont(p, "Inter", 88, "Bold");
153153
p.drawText(QRect(0, c.y() - 125, width(), 150), Qt::AlignHCenter | Qt::AlignTop, alert.text1);
154-
configFont(p, "Open Sans", 66, "Regular");
154+
configFont(p, "Inter", 66, "Regular");
155155
p.drawText(QRect(0, c.y() + 21, width(), 90), Qt::AlignHCenter, alert.text2);
156156
} else if (alert.size == cereal::ControlsState::AlertSize::FULL) {
157157
bool l = alert.text1.length() > 15;
158-
configFont(p, "Open Sans", l ? 132 : 177, "Bold");
158+
configFont(p, "Inter", l ? 132 : 177, "Bold");
159159
p.drawText(QRect(0, r.y() + (l ? 240 : 270), width(), 600), Qt::AlignHCenter | Qt::TextWordWrap, alert.text1);
160-
configFont(p, "Open Sans", 88, "Regular");
160+
configFont(p, "Inter", 88, "Regular");
161161
p.drawText(QRect(0, r.height() - (l ? 361 : 420), width(), 300), Qt::AlignHCenter | Qt::TextWordWrap, alert.text2);
162162
}
163163
}

0 commit comments

Comments
 (0)