mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-06 00:36:25 +08:00
ui: change alerts to Inter (#24937)
* ui: change alerts to Inter * fix up test old-commit-hash: 88f246b909e3e111ac84e964bb811efefd923163
This commit is contained in:
@@ -48,20 +48,17 @@ class TestAlerts(unittest.TestCase):
|
||||
# ensure alert text doesn't exceed allowed width
|
||||
def test_alert_text_length(self):
|
||||
font_path = os.path.join(BASEDIR, "selfdrive/assets/fonts")
|
||||
regular_font_path = os.path.join(font_path, "opensans_semibold.ttf")
|
||||
bold_font_path = os.path.join(font_path, "opensans_semibold.ttf")
|
||||
semibold_font_path = os.path.join(font_path, "opensans_semibold.ttf")
|
||||
|
||||
max_text_width = 1920 - 300 # full screen width is useable, minus sidebar
|
||||
# TODO: get exact scale factor. found this empirically, works well enough
|
||||
font_scale_factor = 1.55 # factor to scale from nanovg units to PIL
|
||||
regular_font_path = os.path.join(font_path, "Inter-SemiBold.ttf")
|
||||
bold_font_path = os.path.join(font_path, "Inter-Bold.ttf")
|
||||
semibold_font_path = os.path.join(font_path, "Inter-SemiBold.ttf")
|
||||
|
||||
max_text_width = 2160 - 300 # full screen width is useable, minus sidebar
|
||||
draw = ImageDraw.Draw(Image.new('RGB', (0, 0)))
|
||||
|
||||
fonts = {
|
||||
AlertSize.small: [ImageFont.truetype(semibold_font_path, int(40 * font_scale_factor))],
|
||||
AlertSize.mid: [ImageFont.truetype(bold_font_path, int(48 * font_scale_factor)),
|
||||
ImageFont.truetype(regular_font_path, int(36 * font_scale_factor))],
|
||||
AlertSize.small: [ImageFont.truetype(semibold_font_path, 74)],
|
||||
AlertSize.mid: [ImageFont.truetype(bold_font_path, 88),
|
||||
ImageFont.truetype(regular_font_path, 66)],
|
||||
}
|
||||
|
||||
for alert in ALERTS:
|
||||
|
||||
@@ -146,18 +146,18 @@ void OnroadAlerts::paintEvent(QPaintEvent *event) {
|
||||
p.setPen(QColor(0xff, 0xff, 0xff));
|
||||
p.setRenderHint(QPainter::TextAntialiasing);
|
||||
if (alert.size == cereal::ControlsState::AlertSize::SMALL) {
|
||||
configFont(p, "Open Sans", 74, "SemiBold");
|
||||
configFont(p, "Inter", 74, "SemiBold");
|
||||
p.drawText(r, Qt::AlignCenter, alert.text1);
|
||||
} else if (alert.size == cereal::ControlsState::AlertSize::MID) {
|
||||
configFont(p, "Open Sans", 88, "Bold");
|
||||
configFont(p, "Inter", 88, "Bold");
|
||||
p.drawText(QRect(0, c.y() - 125, width(), 150), Qt::AlignHCenter | Qt::AlignTop, alert.text1);
|
||||
configFont(p, "Open Sans", 66, "Regular");
|
||||
configFont(p, "Inter", 66, "Regular");
|
||||
p.drawText(QRect(0, c.y() + 21, width(), 90), Qt::AlignHCenter, alert.text2);
|
||||
} else if (alert.size == cereal::ControlsState::AlertSize::FULL) {
|
||||
bool l = alert.text1.length() > 15;
|
||||
configFont(p, "Open Sans", l ? 132 : 177, "Bold");
|
||||
configFont(p, "Inter", l ? 132 : 177, "Bold");
|
||||
p.drawText(QRect(0, r.y() + (l ? 240 : 270), width(), 600), Qt::AlignHCenter | Qt::TextWordWrap, alert.text1);
|
||||
configFont(p, "Open Sans", 88, "Regular");
|
||||
configFont(p, "Inter", 88, "Regular");
|
||||
p.drawText(QRect(0, r.height() - (l ? 361 : 420), width(), 300), Qt::AlignHCenter | Qt::TextWordWrap, alert.text2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user