From 6f2bd6efa3d3bd83b79d146f8ce36240cd68e5ea Mon Sep 17 00:00:00 2001 From: mouxangithub Date: Thu, 20 Nov 2025 11:43:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E5=B0=86=E5=AD=97=E4=BD=93?= =?UTF-8?q?=E6=9D=83=E9=87=8D=E7=BB=9F=E4=B8=80=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?=20CHINA=20=E4=BB=A5=E6=94=AF=E6=8C=81=E4=B8=AD=E6=96=87?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E6=B8=B2=E6=9F=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将多个 UI 组件中的字体权重从原有的 `MEDIUM`、`NORMAL`、`BOLD` 等值统一修改为 `CHINA`, 以确保界面文本能够正确使用中文字体进行显示。同时调整了部分字号和标签样式,提升中文环境下的展示效果。 --- selfdrive/ui/layouts/home.py | 2 +- selfdrive/ui/layouts/onboarding.py | 6 ++--- selfdrive/ui/layouts/settings/firehose.py | 10 ++++---- selfdrive/ui/layouts/settings/settings.py | 2 +- selfdrive/ui/layouts/sidebar.py | 4 ++-- selfdrive/ui/onroad/alert_renderer.py | 6 ++--- selfdrive/ui/onroad/driver_camera_dialog.py | 2 +- selfdrive/ui/onroad/hud_renderer.py | 8 +++---- selfdrive/ui/onroad/model_renderer.py | 4 ++-- selfdrive/ui/widgets/exp_mode_button.py | 2 +- selfdrive/ui/widgets/offroad_alerts.py | 10 ++++---- selfdrive/ui/widgets/pairing_dialog.py | 6 ++--- selfdrive/ui/widgets/prime.py | 8 +++---- selfdrive/ui/widgets/setup.py | 8 +++---- selfdrive/ui/widgets/ssh_key.py | 2 +- system/ui/lib/application.py | 4 ++-- system/ui/reset.py | 2 +- system/ui/setup.py | 18 +++++++------- system/ui/updater.py | 2 +- system/ui/widgets/button.py | 2 +- system/ui/widgets/confirm_dialog.py | 2 +- system/ui/widgets/html_render.py | 26 ++++++++++----------- system/ui/widgets/keyboard.py | 4 ++-- system/ui/widgets/label.py | 12 +++++----- system/ui/widgets/list_view.py | 16 ++++++------- system/ui/widgets/option_dialog.py | 4 ++-- 26 files changed, 86 insertions(+), 86 deletions(-) diff --git a/selfdrive/ui/layouts/home.py b/selfdrive/ui/layouts/home.py index 42bbc6c..968e41f 100644 --- a/selfdrive/ui/layouts/home.py +++ b/selfdrive/ui/layouts/home.py @@ -141,7 +141,7 @@ class HomeLayout(Widget): self._set_state(HomeLayoutState.ALERTS) def _render_header(self): - font = gui_app.font(FontWeight.MEDIUM) + font = gui_app.font(FontWeight.CHINA) version_text_width = self.header_rect.width diff --git a/selfdrive/ui/layouts/onboarding.py b/selfdrive/ui/layouts/onboarding.py index df259a8..ac6f9c9 100644 --- a/selfdrive/ui/layouts/onboarding.py +++ b/selfdrive/ui/layouts/onboarding.py @@ -108,9 +108,9 @@ class TermsPage(Widget): self._on_accept = on_accept self._on_decline = on_decline - self._title = Label(tr("Welcome to openpilot"), font_size=90, font_weight=FontWeight.BOLD, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT) + self._title = Label(tr("Welcome to openpilot"), font_size=90, font_weight=FontWeight.CHINA, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT) self._desc = Label(tr("You must accept the Terms and Conditions to use openpilot. Read the latest terms at https://comma.ai/terms before continuing."), - font_size=90, font_weight=FontWeight.MEDIUM, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT) + font_size=90, font_weight=FontWeight.CHINA, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT) self._decline_btn = Button(tr("Decline"), click_callback=on_decline) self._accept_btn = Button(tr("Agree"), button_style=ButtonStyle.PRIMARY, click_callback=on_accept) @@ -143,7 +143,7 @@ class DeclinePage(Widget): def __init__(self, back_callback=None): super().__init__() self._text = Label(tr("You must accept the Terms and Conditions in order to use openpilot."), - font_size=90, font_weight=FontWeight.MEDIUM, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT) + font_size=90, font_weight=FontWeight.CHINA, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT) self._back_btn = Button(tr("Back"), click_callback=back_callback) self._uninstall_btn = Button(tr("Decline, uninstall openpilot"), button_style=ButtonStyle.DANGER, click_callback=self._on_uninstall_clicked) diff --git a/selfdrive/ui/layouts/settings/firehose.py b/selfdrive/ui/layouts/settings/firehose.py index bbd4aef..5a7b82d 100644 --- a/selfdrive/ui/layouts/settings/firehose.py +++ b/selfdrive/ui/layouts/settings/firehose.py @@ -87,14 +87,14 @@ class FirehoseLayout(Widget): # Title (centered) title_text = tr(TITLE) # live translate - title_font = gui_app.font(FontWeight.MEDIUM) + title_font = gui_app.font(FontWeight.CHINA) text_width = measure_text_cached(title_font, title_text, 100).x title_x = rect.x + (rect.width - text_width) / 2 rl.draw_text_ex(title_font, title_text, rl.Vector2(title_x, y), 100, 0, rl.WHITE) y += 200 # Description - y = self._draw_wrapped_text(x, y, w, tr(DESCRIPTION), gui_app.font(FontWeight.NORMAL), 45, rl.WHITE) + y = self._draw_wrapped_text(x, y, w, tr(DESCRIPTION), gui_app.font(FontWeight.CHINA), 45, rl.WHITE) y += 40 + 20 # Separator @@ -103,14 +103,14 @@ class FirehoseLayout(Widget): # Status status_text, status_color = self._get_status() - y = self._draw_wrapped_text(x, y, w, status_text, gui_app.font(FontWeight.BOLD), 60, status_color) + y = self._draw_wrapped_text(x, y, w, status_text, gui_app.font(FontWeight.CHINA), 60, status_color) y += 20 + 20 # Contribution count (if available) if self.segment_count > 0: contrib_text = trn("{} segment of your driving is in the training dataset so far.", "{} segments of your driving is in the training dataset so far.", self.segment_count).format(self.segment_count) - y = self._draw_wrapped_text(x, y, w, contrib_text, gui_app.font(FontWeight.BOLD), 52, rl.WHITE) + y = self._draw_wrapped_text(x, y, w, contrib_text, gui_app.font(FontWeight.CHINA), 52, rl.WHITE) y += 20 + 20 # Separator @@ -118,7 +118,7 @@ class FirehoseLayout(Widget): y += 30 + 20 # Instructions - y = self._draw_wrapped_text(x, y, w, tr(INSTRUCTIONS), gui_app.font(FontWeight.NORMAL), 40, self.LIGHT_GRAY) + y = self._draw_wrapped_text(x, y, w, tr(INSTRUCTIONS), gui_app.font(FontWeight.CHINA), 40, self.LIGHT_GRAY) # bottom margin + remove effect of scroll offset return int(round(y - self.scroll_panel.offset + 40)) diff --git a/selfdrive/ui/layouts/settings/settings.py b/selfdrive/ui/layouts/settings/settings.py index 559c2b2..345ddae 100644 --- a/selfdrive/ui/layouts/settings/settings.py +++ b/selfdrive/ui/layouts/settings/settings.py @@ -68,7 +68,7 @@ class SettingsLayout(Widget): PanelType.DRAGONPILOT: PanelInfo(tr_noop("Dp"), DragonpilotLayout()), } - self._font_medium = gui_app.font(FontWeight.MEDIUM) + self._font_medium = gui_app.font(FontWeight.CHINA) # Callbacks self._close_callback: Callable | None = None diff --git a/selfdrive/ui/layouts/sidebar.py b/selfdrive/ui/layouts/sidebar.py index f42cbf6..8248769 100644 --- a/selfdrive/ui/layouts/sidebar.py +++ b/selfdrive/ui/layouts/sidebar.py @@ -78,8 +78,8 @@ class Sidebar(Widget): self._settings_img = gui_app.texture("images/button_settings.png", SETTINGS_BTN.width, SETTINGS_BTN.height) self._mic_img = gui_app.texture("icons/microphone.png", 30, 30) self._mic_indicator_rect = rl.Rectangle(0, 0, 0, 0) - self._font_regular = gui_app.font(FontWeight.NORMAL) - self._font_bold = gui_app.font(FontWeight.SEMI_BOLD) + self._font_regular = gui_app.font(FontWeight.CHINA) + self._font_bold = gui_app.font(FontWeight.CHINA) # Callbacks self._on_settings_click: Callable | None = None diff --git a/selfdrive/ui/onroad/alert_renderer.py b/selfdrive/ui/onroad/alert_renderer.py index a81fbfc..dedb340 100644 --- a/selfdrive/ui/onroad/alert_renderer.py +++ b/selfdrive/ui/onroad/alert_renderer.py @@ -72,11 +72,11 @@ ALERT_CRITICAL_REBOOT = Alert( class AlertRenderer(Widget): def __init__(self): super().__init__() - self.font_regular: rl.Font = gui_app.font(FontWeight.NORMAL) - self.font_bold: rl.Font = gui_app.font(FontWeight.BOLD) + self.font_regular: rl.Font = gui_app.font(FontWeight.CHINA) + self.font_bold: rl.Font = gui_app.font(FontWeight.CHINA) # font size is set dynamically - self._full_text1_label = Label("", font_size=0, font_weight=FontWeight.BOLD, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER, + self._full_text1_label = Label("", font_size=0, font_weight=FontWeight.CHINA, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER, text_alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_TOP) self._full_text2_label = Label("", font_size=ALERT_FONT_BIG, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER, text_alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_TOP) diff --git a/selfdrive/ui/onroad/driver_camera_dialog.py b/selfdrive/ui/onroad/driver_camera_dialog.py index 543ea35..9adf63a 100644 --- a/selfdrive/ui/onroad/driver_camera_dialog.py +++ b/selfdrive/ui/onroad/driver_camera_dialog.py @@ -33,7 +33,7 @@ class DriverCameraDialog(CameraView): rect, tr("camera starting"), font_size=100, - font_weight=FontWeight.BOLD, + font_weight=FontWeight.CHINA, alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER, ) return -1 diff --git a/selfdrive/ui/onroad/hud_renderer.py b/selfdrive/ui/onroad/hud_renderer.py index a2459c2..2a92d08 100644 --- a/selfdrive/ui/onroad/hud_renderer.py +++ b/selfdrive/ui/onroad/hud_renderer.py @@ -29,7 +29,7 @@ class UIConfig: class FontSizes: current_speed: int = 176 speed_unit: int = 66 - max_speed: int = 40 + max_speed: int = 30 set_speed: int = 90 @@ -66,9 +66,9 @@ class HudRenderer(Widget): self.speed: float = 0.0 self.v_ego_cluster_seen: bool = False - self._font_semi_bold: rl.Font = gui_app.font(FontWeight.SEMI_BOLD) - self._font_bold: rl.Font = gui_app.font(FontWeight.BOLD) - self._font_medium: rl.Font = gui_app.font(FontWeight.MEDIUM) + self._font_semi_bold: rl.Font = gui_app.font(FontWeight.CHINA) + self._font_bold: rl.Font = gui_app.font(FontWeight.CHINA) + self._font_medium: rl.Font = gui_app.font(FontWeight.CHINA) self._exp_button: ExpButton = ExpButton(UI_CONFIG.button_size, UI_CONFIG.wheel_icon_size) diff --git a/selfdrive/ui/onroad/model_renderer.py b/selfdrive/ui/onroad/model_renderer.py index d871fb8..e991810 100644 --- a/selfdrive/ui/onroad/model_renderer.py +++ b/selfdrive/ui/onroad/model_renderer.py @@ -538,13 +538,13 @@ class ModelRenderer(Widget): ) def _dp_paint_centered_lead_text(self, text, size, x, y): - font = gui_app.font(FontWeight.NORMAL) + font = gui_app.font(FontWeight.CHINA) text_width = measure_text_cached(font, text, size).x text_x = x - text_width / 2 rl.draw_text_ex(font, text, rl.Vector2(text_x, y), size, 0, rl.WHITE) def _draw_live_tracks(self, sm): - font = gui_app.font(FontWeight.NORMAL) + font = gui_app.font(FontWeight.CHINA) live_tracks = sm['liveTracks'] font_size = 40 line_height = 40 diff --git a/selfdrive/ui/widgets/exp_mode_button.py b/selfdrive/ui/widgets/exp_mode_button.py index faa3bf8..c70d56b 100644 --- a/selfdrive/ui/widgets/exp_mode_button.py +++ b/selfdrive/ui/widgets/exp_mode_button.py @@ -51,7 +51,7 @@ class ExperimentalModeButton(Widget): text_x = rect.x + self.horizontal_padding text_y = rect.y + rect.height / 2 - 45 * FONT_SCALE // 2 # Center vertically - rl.draw_text_ex(gui_app.font(FontWeight.NORMAL), text, rl.Vector2(int(text_x), int(text_y)), 45, 0, rl.BLACK) + rl.draw_text_ex(gui_app.font(FontWeight.CHINA), text, rl.Vector2(int(text_x), int(text_y)), 45, 0, rl.BLACK) # Draw icon (right aligned) icon_x = rect.x + rect.width - self.horizontal_padding - self.img_width diff --git a/selfdrive/ui/widgets/offroad_alerts.py b/selfdrive/ui/widgets/offroad_alerts.py index 802243f..07174c5 100644 --- a/selfdrive/ui/widgets/offroad_alerts.py +++ b/selfdrive/ui/widgets/offroad_alerts.py @@ -59,14 +59,14 @@ class ActionButton(Widget): self._text = text self._style = style self._min_width = min_width - self._font = gui_app.font(FontWeight.MEDIUM) + self._font = gui_app.font(FontWeight.CHINA) @property def text(self) -> str: return self._text() if callable(self._text) else self._text def _render(self, _): - text_size = measure_text_cached(gui_app.font(FontWeight.MEDIUM), self.text, AlertConstants.FONT_SIZE) + text_size = measure_text_cached(gui_app.font(FontWeight.CHINA), self.text, AlertConstants.FONT_SIZE) self._rect.width = max(text_size.x + 60 * 2, self._min_width) self._rect.height = AlertConstants.BUTTON_HEIGHT @@ -241,7 +241,7 @@ class OffroadAlert(AbstractAlert): return 0 total_height = 20 - font = gui_app.font(FontWeight.NORMAL) + font = gui_app.font(FontWeight.CHINA) for alert_data in self.sorted_alerts: if not alert_data.visible: @@ -268,7 +268,7 @@ class OffroadAlert(AbstractAlert): def _render_content(self, content_rect: rl.Rectangle): y_offset = AlertConstants.ALERT_SPACING - font = gui_app.font(FontWeight.NORMAL) + font = gui_app.font(FontWeight.CHINA) for alert_data in self.sorted_alerts: if not alert_data.visible: @@ -334,7 +334,7 @@ class UpdateAlert(AbstractAlert): if self._cached_content_height == 0: self._wrapped_release_notes = self.release_notes - size = measure_text_cached(gui_app.font(FontWeight.NORMAL), self._wrapped_release_notes, AlertConstants.FONT_SIZE) + size = measure_text_cached(gui_app.font(FontWeight.CHINA), self._wrapped_release_notes, AlertConstants.FONT_SIZE) self._cached_content_height = max(size.y + 60, 100) return self._cached_content_height diff --git a/selfdrive/ui/widgets/pairing_dialog.py b/selfdrive/ui/widgets/pairing_dialog.py index 85b42d1..45b850a 100644 --- a/selfdrive/ui/widgets/pairing_dialog.py +++ b/selfdrive/ui/widgets/pairing_dialog.py @@ -101,7 +101,7 @@ class PairingDialog(Widget): # Title title = tr("Pair your device to your comma account") - title_font = gui_app.font(FontWeight.NORMAL) + title_font = gui_app.font(FontWeight.CHINA) left_width = int(content_rect.width * 0.5 - 15) title_wrapped = wrap_text(title_font, title, 75, left_width) @@ -130,7 +130,7 @@ class PairingDialog(Widget): tr("Bookmark connect.comma.ai to your home screen to use it like an app"), ] - font = gui_app.font(FontWeight.BOLD) + font = gui_app.font(FontWeight.CHINA) y = rect.y for i, text in enumerate(instructions): @@ -156,7 +156,7 @@ class PairingDialog(Widget): def _render_qr_code(self, rect: rl.Rectangle) -> None: if not self.qr_texture: rl.draw_rectangle_rounded(rect, 0.1, 20, rl.Color(240, 240, 240, 255)) - error_font = gui_app.font(FontWeight.BOLD) + error_font = gui_app.font(FontWeight.CHINA) rl.draw_text_ex( error_font, tr("QR Code Error"), rl.Vector2(rect.x + 20, rect.y + rect.height // 2 - 15), 30, 0.0, rl.RED ) diff --git a/selfdrive/ui/widgets/prime.py b/selfdrive/ui/widgets/prime.py index 49a0e56..b710b5c 100644 --- a/selfdrive/ui/widgets/prime.py +++ b/selfdrive/ui/widgets/prime.py @@ -30,18 +30,18 @@ class PrimeWidget(Widget): w = rect.width - 160 # Title - gui_label(rl.Rectangle(x, y, w, 90), tr("Upgrade Now"), 75, font_weight=FontWeight.BOLD) + gui_label(rl.Rectangle(x, y, w, 90), tr("Upgrade Now"), 75, font_weight=FontWeight.CHINA) # Description with wrapping desc_y = y + 140 - font = gui_app.font(FontWeight.LIGHT) + font = gui_app.font(FontWeight.CHINA) wrapped_text = "\n".join(wrap_text(font, tr("Become a comma prime member at connect.comma.ai"), 56, int(w))) text_size = measure_text_cached(font, wrapped_text, 56) rl.draw_text_ex(font, wrapped_text, rl.Vector2(x, desc_y), 56, 0, rl.WHITE) # Features section features_y = desc_y + text_size.y + 50 - gui_label(rl.Rectangle(x, features_y, w, 50), tr("PRIME FEATURES:"), 41, font_weight=FontWeight.BOLD) + gui_label(rl.Rectangle(x, features_y, w, 50), tr("PRIME FEATURES:"), 41, font_weight=FontWeight.CHINA) # Feature list features = [tr("Remote access"), tr("24/7 LTE connectivity"), tr("1 year of drive storage"), tr("Remote snapshots")] @@ -58,6 +58,6 @@ class PrimeWidget(Widget): x = rect.x + 56 y = rect.y + 40 - font = gui_app.font(FontWeight.BOLD) + font = gui_app.font(FontWeight.CHINA) rl.draw_text_ex(font, tr("✓ SUBSCRIBED"), rl.Vector2(x, y), 41, 0, rl.Color(134, 255, 78, 255)) rl.draw_text_ex(font, tr("comma prime"), rl.Vector2(x, y + 61), 75, 0, rl.WHITE) diff --git a/selfdrive/ui/widgets/setup.py b/selfdrive/ui/widgets/setup.py index 80090e6..ea2c295 100644 --- a/selfdrive/ui/widgets/setup.py +++ b/selfdrive/ui/widgets/setup.py @@ -19,7 +19,7 @@ class SetupWidget(Widget): self._pair_device_btn = Button(lambda: tr("Pair device"), self._show_pairing, button_style=ButtonStyle.PRIMARY) self._open_settings_btn = Button(lambda: tr("Open"), lambda: self._open_settings_callback() if self._open_settings_callback else None, button_style=ButtonStyle.PRIMARY) - self._firehose_label = Label(lambda: tr("🔥 Firehose Mode 🔥"), font_weight=FontWeight.MEDIUM, font_size=64) + self._firehose_label = Label(lambda: tr("🔥 Firehose Mode 🔥"), font_weight=FontWeight.CHINA, font_size=64) def set_open_settings_callback(self, callback): self._open_settings_callback = callback @@ -40,13 +40,13 @@ class SetupWidget(Widget): w = rect.width - 128 # Title - font = gui_app.font(FontWeight.BOLD) + font = gui_app.font(FontWeight.CHINA) rl.draw_text_ex(font, tr("Finish Setup"), rl.Vector2(x, y), 75, 0, rl.WHITE) y += 113 # 75 + 38 spacing # Description desc = tr("Pair your device with comma connect (connect.comma.ai) and claim your comma prime offer.") - light_font = gui_app.font(FontWeight.LIGHT) + light_font = gui_app.font(FontWeight.CHINA) wrapped = wrap_text(light_font, desc, 50, int(w)) for line in wrapped: rl.draw_text_ex(light_font, line, rl.Vector2(x, y), 50, 0, rl.WHITE) @@ -71,7 +71,7 @@ class SetupWidget(Widget): y += 64 + spacing # Description - desc_font = gui_app.font(FontWeight.NORMAL) + desc_font = gui_app.font(FontWeight.CHINA) desc_text = tr("Maximize your training data uploads to improve openpilot's driving models.") wrapped_desc = wrap_text(desc_font, desc_text, 40, int(w)) diff --git a/selfdrive/ui/widgets/ssh_key.py b/selfdrive/ui/widgets/ssh_key.py index 88389cb..8bf1cda 100644 --- a/selfdrive/ui/widgets/ssh_key.py +++ b/selfdrive/ui/widgets/ssh_key.py @@ -41,7 +41,7 @@ class SshKeyAction(ItemAction): self._keyboard = Keyboard(min_text_size=1) self._params = Params() self._error_message: str = "" - self._text_font = gui_app.font(FontWeight.NORMAL) + self._text_font = gui_app.font(FontWeight.CHINA) self._button = Button("", click_callback=self._handle_button_click, button_style=ButtonStyle.LIST_ACTION, border_radius=BUTTON_BORDER_RADIUS, font_size=BUTTON_FONT_SIZE) diff --git a/system/ui/lib/application.py b/system/ui/lib/application.py index d5399d9..f2d7af3 100644 --- a/system/ui/lib/application.py +++ b/system/ui/lib/application.py @@ -351,7 +351,7 @@ class GuiApplication: except KeyboardInterrupt: pass - def font(self, font_weight: FontWeight = FontWeight.NORMAL) -> rl.Font: + def font(self, font_weight: FontWeight = FontWeight.CHINA) -> rl.Font: return self._fonts[font_weight] @property @@ -393,7 +393,7 @@ class GuiApplication: self._fonts[font_weight_file] = font rl.unload_codepoints(codepoints) - rl.gui_set_font(self._fonts[FontWeight.NORMAL]) + rl.gui_set_font(self._fonts[FontWeight.CHINA]) def _set_styles(self): rl.gui_set_style(rl.GuiControl.DEFAULT, rl.GuiControlProperty.BORDER_WIDTH, 0) diff --git a/system/ui/reset.py b/system/ui/reset.py index 8f6466c..afbedd8 100755 --- a/system/ui/reset.py +++ b/system/ui/reset.py @@ -71,7 +71,7 @@ class Reset(Widget): def _render(self, rect: rl.Rectangle): label_rect = rl.Rectangle(rect.x + 140, rect.y, rect.width - 280, 100 * FONT_SCALE) - gui_label(label_rect, "System Reset", 100, font_weight=FontWeight.BOLD) + gui_label(label_rect, "System Reset", 100, font_weight=FontWeight.CHINA) text_rect = rl.Rectangle(rect.x + 140, rect.y + 140, rect.width - 280, rect.height - 90 - 100 * FONT_SCALE) gui_text_box(text_rect, self._get_body_text(), 90) diff --git a/system/ui/setup.py b/system/ui/setup.py index 5dbf597..10a178b 100755 --- a/system/ui/setup.py +++ b/system/ui/setup.py @@ -25,7 +25,7 @@ NetworkType = log.DeviceState.NetworkType MARGIN = 50 TITLE_FONT_SIZE = 90 -TITLE_FONT_WEIGHT = FontWeight.MEDIUM +TITLE_FONT_WEIGHT = FontWeight.CHINA NEXT_BUTTON_WIDTH = 310 BODY_FONT_SIZE = 80 BUTTON_HEIGHT = 160 @@ -79,7 +79,7 @@ class Setup(Widget): self.warning = gui_app.texture("icons/warning.png", 150, 150) self.checkmark = gui_app.texture("icons/circled_check.png", 100, 100) - self._low_voltage_title_label = Label("WARNING: Low Voltage", TITLE_FONT_SIZE, FontWeight.MEDIUM, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, + self._low_voltage_title_label = Label("WARNING: Low Voltage", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_color=rl.Color(255, 89, 79, 255), text_padding=20) self._low_voltage_body_label = Label("Power your device in a car with a harness or proceed at your own risk.", BODY_FONT_SIZE, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) @@ -87,7 +87,7 @@ class Setup(Widget): self._low_voltage_poweroff_button = Button("Power Off", HARDWARE.shutdown) self._getting_started_button = Button("", self._getting_started_button_callback, button_style=ButtonStyle.PRIMARY, border_radius=0) - self._getting_started_title_label = Label("Getting Started", TITLE_FONT_SIZE, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) + self._getting_started_title_label = Label("Getting Started", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) self._getting_started_body_label = Label("Before we get on the road, let's finish installation and cover some details.", BODY_FONT_SIZE, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) @@ -97,26 +97,26 @@ class Setup(Widget): button_style=ButtonStyle.PRIMARY) self._software_selection_continue_button.set_enabled(False) self._software_selection_back_button = Button("Back", self._software_selection_back_button_callback) - self._software_selection_title_label = Label("Choose Software to Use", TITLE_FONT_SIZE, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, + self._software_selection_title_label = Label("Choose Software to Use", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) self._download_failed_reboot_button = Button("Reboot device", HARDWARE.reboot) self._download_failed_startover_button = Button("Start over", self._download_failed_startover_button_callback, button_style=ButtonStyle.PRIMARY) - self._download_failed_title_label = Label("Download Failed", TITLE_FONT_SIZE, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) - self._download_failed_url_label = Label("", 52, FontWeight.NORMAL, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) + self._download_failed_title_label = Label("Download Failed", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) + self._download_failed_url_label = Label("", 52, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) self._download_failed_body_label = Label("", BODY_FONT_SIZE, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) self._network_setup_back_button = Button("Back", self._network_setup_back_button_callback) self._network_setup_continue_button = Button("Waiting for internet", self._network_setup_continue_button_callback, button_style=ButtonStyle.PRIMARY) self._network_setup_continue_button.set_enabled(False) - self._network_setup_title_label = Label("Connect to Wi-Fi", TITLE_FONT_SIZE, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) + self._network_setup_title_label = Label("Connect to Wi-Fi", TITLE_FONT_SIZE, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) self._custom_software_warning_continue_button = Button("Scroll to continue", self._custom_software_warning_continue_button_callback, button_style=ButtonStyle.PRIMARY) self._custom_software_warning_continue_button.set_enabled(False) self._custom_software_warning_back_button = Button("Back", self._custom_software_warning_back_button_callback) - self._custom_software_warning_title_label = Label("WARNING: Custom Software", 81, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, + self._custom_software_warning_title_label = Label("WARNING: Custom Software", 81, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_color=rl.Color(255, 89, 79, 255), text_padding=60) self._custom_software_warning_body_label = Label("Use caution when installing third-party software.\n\n" @@ -128,7 +128,7 @@ class Setup(Widget): 68, text_alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=60) self._custom_software_warning_body_scroll_panel = GuiScrollPanel() - self._downloading_body_label = Label("Downloading...", TITLE_FONT_SIZE, FontWeight.MEDIUM, text_padding=20) + self._downloading_body_label = Label("Downloading...", TITLE_FONT_SIZE, FontWeight.CHINA, text_padding=20) try: with open("/sys/class/hwmon/hwmon1/in1_input") as f: diff --git a/system/ui/updater.py b/system/ui/updater.py index 5dd5a69..a73a73c 100755 --- a/system/ui/updater.py +++ b/system/ui/updater.py @@ -90,7 +90,7 @@ class Updater(Widget): def render_prompt_screen(self, rect: rl.Rectangle): # Title title_rect = rl.Rectangle(MARGIN + 50, 250, rect.width - MARGIN * 2 - 100, TITLE_FONT_SIZE * FONT_SCALE) - gui_label(title_rect, "Update Required", TITLE_FONT_SIZE, font_weight=FontWeight.BOLD) + gui_label(title_rect, "Update Required", TITLE_FONT_SIZE, font_weight=FontWeight.CHINA) # Description desc_text = ("An operating system update is required. Connect your device to Wi-Fi for the fastest update experience. " + diff --git a/system/ui/widgets/button.py b/system/ui/widgets/button.py index 5b9c518..225f788 100644 --- a/system/ui/widgets/button.py +++ b/system/ui/widgets/button.py @@ -82,7 +82,7 @@ class Button(Widget): text: str | Callable[[], str], click_callback: Callable[[], None] | None = None, font_size: int = DEFAULT_BUTTON_FONT_SIZE, - font_weight: FontWeight = FontWeight.MEDIUM, + font_weight: FontWeight = FontWeight.CHINA, button_style: ButtonStyle = ButtonStyle.NORMAL, border_radius: int = 10, text_alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_CENTER, diff --git a/system/ui/widgets/confirm_dialog.py b/system/ui/widgets/confirm_dialog.py index 8c5ae0a..1ba202a 100644 --- a/system/ui/widgets/confirm_dialog.py +++ b/system/ui/widgets/confirm_dialog.py @@ -21,7 +21,7 @@ class ConfirmDialog(Widget): super().__init__() if cancel_text is None: cancel_text = tr("Cancel") - self._label = Label(text, 70, FontWeight.BOLD, text_color=rl.Color(201, 201, 201, 255)) + self._label = Label(text, 70, FontWeight.CHINA, text_color=rl.Color(201, 201, 201, 255)) self._html_renderer = HtmlRenderer(text=text, text_size={ElementType.P: 50}, center_text=True) self._cancel_button = Button(cancel_text, self._cancel_button_callback) self._confirm_button = Button(confirm_text, self._confirm_button_callback, button_style=ButtonStyle.PRIMARY) diff --git a/system/ui/widgets/html_render.py b/system/ui/widgets/html_render.py index 5a6bf37..aa38fab 100644 --- a/system/ui/widgets/html_render.py +++ b/system/ui/widgets/html_render.py @@ -62,8 +62,8 @@ class HtmlRenderer(Widget): super().__init__() self._text_color = text_color self._center_text = center_text - self._normal_font = gui_app.font(FontWeight.NORMAL) - self._bold_font = gui_app.font(FontWeight.BOLD) + self._normal_font = gui_app.font(FontWeight.CHINA) + self._bold_font = gui_app.font(FontWeight.CHINA) self._indent_level = 0 if text_size is None: @@ -77,16 +77,16 @@ class HtmlRenderer(Widget): # Untagged text defaults to

self.styles: dict[ElementType, dict[str, Any]] = { - ElementType.H1: {"size": round(base_p_size * 2), "weight": FontWeight.BOLD, "margin_top": 20, "margin_bottom": 16}, - ElementType.H2: {"size": round(base_p_size * 1.50), "weight": FontWeight.BOLD, "margin_top": 24, "margin_bottom": 12}, - ElementType.H3: {"size": round(base_p_size * 1.17), "weight": FontWeight.BOLD, "margin_top": 20, "margin_bottom": 10}, - ElementType.H4: {"size": round(base_p_size * 1.00), "weight": FontWeight.BOLD, "margin_top": 16, "margin_bottom": 8}, - ElementType.H5: {"size": round(base_p_size * 0.83), "weight": FontWeight.BOLD, "margin_top": 12, "margin_bottom": 6}, - ElementType.H6: {"size": round(base_p_size * 0.67), "weight": FontWeight.BOLD, "margin_top": 10, "margin_bottom": 4}, - ElementType.P: {"size": base_p_size, "weight": FontWeight.NORMAL, "margin_top": 8, "margin_bottom": 12}, - ElementType.B: {"size": base_p_size, "weight": FontWeight.BOLD, "margin_top": 8, "margin_bottom": 12}, - ElementType.LI: {"size": base_p_size, "weight": FontWeight.NORMAL, "color": rl.Color(40, 40, 40, 255), "margin_top": 6, "margin_bottom": 6}, - ElementType.BR: {"size": 0, "weight": FontWeight.NORMAL, "margin_top": 0, "margin_bottom": 12}, + ElementType.H1: {"size": round(base_p_size * 2), "weight": FontWeight.CHINA, "margin_top": 20, "margin_bottom": 16}, + ElementType.H2: {"size": round(base_p_size * 1.50), "weight": FontWeight.CHINA, "margin_top": 24, "margin_bottom": 12}, + ElementType.H3: {"size": round(base_p_size * 1.17), "weight": FontWeight.CHINA, "margin_top": 20, "margin_bottom": 10}, + ElementType.H4: {"size": round(base_p_size * 1.00), "weight": FontWeight.CHINA, "margin_top": 16, "margin_bottom": 8}, + ElementType.H5: {"size": round(base_p_size * 0.83), "weight": FontWeight.CHINA, "margin_top": 12, "margin_bottom": 6}, + ElementType.H6: {"size": round(base_p_size * 0.67), "weight": FontWeight.CHINA, "margin_top": 10, "margin_bottom": 4}, + ElementType.P: {"size": base_p_size, "weight": FontWeight.CHINA, "margin_top": 8, "margin_bottom": 12}, + ElementType.B: {"size": base_p_size, "weight": FontWeight.CHINA, "margin_top": 8, "margin_bottom": 12}, + ElementType.LI: {"size": base_p_size, "weight": FontWeight.CHINA, "color": rl.Color(40, 40, 40, 255), "margin_top": 6, "margin_bottom": 6}, + ElementType.BR: {"size": 0, "weight": FontWeight.CHINA, "margin_top": 0, "margin_bottom": 12}, } self.elements: list[HtmlElement] = [] @@ -250,7 +250,7 @@ class HtmlRenderer(Widget): return total_height def _get_font(self, weight: FontWeight): - if weight == FontWeight.BOLD: + if weight == FontWeight.CHINA: return self._bold_font return self._normal_font diff --git a/system/ui/widgets/keyboard.py b/system/ui/widgets/keyboard.py index d80a2f3..a75e4f3 100644 --- a/system/ui/widgets/keyboard.py +++ b/system/ui/widgets/keyboard.py @@ -63,8 +63,8 @@ class Keyboard(Widget): self._layout_name: Literal["lowercase", "uppercase", "numbers", "specials"] = "lowercase" self._caps_lock = False self._last_shift_press_time = 0 - self._title = Label("", 90, FontWeight.BOLD, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) - self._sub_title = Label("", 55, FontWeight.NORMAL, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) + self._title = Label("", 90, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) + self._sub_title = Label("", 55, FontWeight.CHINA, rl.GuiTextAlignment.TEXT_ALIGN_LEFT, text_padding=20) self._max_text_size = max_text_size self._min_text_size = min_text_size diff --git a/system/ui/widgets/label.py b/system/ui/widgets/label.py index 4259208..7b8f8c4 100644 --- a/system/ui/widgets/label.py +++ b/system/ui/widgets/label.py @@ -26,7 +26,7 @@ def gui_label( text: str, font_size: int = DEFAULT_TEXT_SIZE, color: rl.Color = DEFAULT_TEXT_COLOR, - font_weight: FontWeight = FontWeight.NORMAL, + font_weight: FontWeight = FontWeight.CHINA, alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_LEFT, alignment_vertical: int = rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE, elide_right: bool = True @@ -75,7 +75,7 @@ def gui_text_box( color: rl.Color = DEFAULT_TEXT_COLOR, alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_LEFT, alignment_vertical: int = rl.GuiTextAlignmentVertical.TEXT_ALIGN_TOP, - font_weight: FontWeight = FontWeight.NORMAL, + font_weight: FontWeight = FontWeight.CHINA, ): styles = [ (rl.GuiControl.DEFAULT, rl.GuiControlProperty.TEXT_COLOR_NORMAL, rl.color_to_int(color)), @@ -85,14 +85,14 @@ def gui_text_box( (rl.GuiControl.DEFAULT, rl.GuiDefaultProperty.TEXT_ALIGNMENT_VERTICAL, alignment_vertical), (rl.GuiControl.DEFAULT, rl.GuiDefaultProperty.TEXT_WRAP_MODE, rl.GuiTextWrapMode.TEXT_WRAP_WORD) ] - if font_weight != FontWeight.NORMAL: + if font_weight != FontWeight.CHINA: rl.gui_set_font(gui_app.font(font_weight)) with GuiStyleContext(styles): rl.gui_label(rect, text) - if font_weight != FontWeight.NORMAL: - rl.gui_set_font(gui_app.font(FontWeight.NORMAL)) + if font_weight != FontWeight.CHINA: + rl.gui_set_font(gui_app.font(FontWeight.CHINA)) # Non-interactive text area. Can render emojis and an optional specified icon. @@ -100,7 +100,7 @@ class Label(Widget): def __init__(self, text: str | Callable[[], str], font_size: int = DEFAULT_TEXT_SIZE, - font_weight: FontWeight = FontWeight.NORMAL, + font_weight: FontWeight = FontWeight.CHINA, text_alignment: int = rl.GuiTextAlignment.TEXT_ALIGN_CENTER, text_alignment_vertical: int = rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE, text_padding: int = 0, diff --git a/system/ui/widgets/list_view.py b/system/ui/widgets/list_view.py index 6de10f4..de0e305 100644 --- a/system/ui/widgets/list_view.py +++ b/system/ui/widgets/list_view.py @@ -26,7 +26,7 @@ BUTTON_WIDTH = 250 BUTTON_HEIGHT = 100 BUTTON_BORDER_RADIUS = 50 BUTTON_FONT_SIZE = 35 -BUTTON_FONT_WEIGHT = FontWeight.MEDIUM +BUTTON_FONT_WEIGHT = FontWeight.CHINA TEXT_PADDING = 20 @@ -84,7 +84,7 @@ class ButtonAction(ItemAction): self._text_source = text self._value_source: str | Callable[[], str] | None = None self._pressed = False - self._font = gui_app.font(FontWeight.NORMAL) + self._font = gui_app.font(FontWeight.CHINA) def pressed(): self._pressed = True @@ -136,7 +136,7 @@ class ButtonAction(ItemAction): if value_text: value_rect = rl.Rectangle(rect.x, rect.y, rect.width - BUTTON_WIDTH - TEXT_PADDING, rect.height) gui_label(value_rect, value_text, font_size=ITEM_TEXT_FONT_SIZE, color=ITEM_TEXT_VALUE_COLOR, - font_weight=FontWeight.NORMAL, alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, + font_weight=FontWeight.CHINA, alignment=rl.GuiTextAlignment.TEXT_ALIGN_LEFT, alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE) # TODO: just use the generic Widget click callbacks everywhere, no returning from render @@ -150,7 +150,7 @@ class TextAction(ItemAction): self._text_source = text self.color = color - self._font = gui_app.font(FontWeight.NORMAL) + self._font = gui_app.font(FontWeight.CHINA) initial_text = _resolve_value(text, "") text_width = measure_text_cached(self._font, initial_text, ITEM_TEXT_FONT_SIZE).x super().__init__(int(text_width + TEXT_PADDING), enabled) @@ -165,7 +165,7 @@ class TextAction(ItemAction): def _render(self, rect: rl.Rectangle) -> bool: gui_label(self._rect, self.text, font_size=ITEM_TEXT_FONT_SIZE, color=self.color, - font_weight=FontWeight.NORMAL, alignment=rl.GuiTextAlignment.TEXT_ALIGN_RIGHT, + font_weight=FontWeight.CHINA, alignment=rl.GuiTextAlignment.TEXT_ALIGN_RIGHT, alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE) return False @@ -217,7 +217,7 @@ class MultipleButtonAction(ItemAction): self.button_width = button_width self.selected_button = selected_index self.callback = callback - self._font = gui_app.font(FontWeight.MEDIUM) + self._font = gui_app.font(FontWeight.CHINA) def set_selected_button(self, index: int): if 0 <= index < len(self.buttons): @@ -287,7 +287,7 @@ class ListItem(Widget): self.action_item = action_item self.set_rect(rl.Rectangle(0, 0, ITEM_BASE_WIDTH, ITEM_BASE_HEIGHT)) - self._font = gui_app.font(FontWeight.NORMAL) + self._font = gui_app.font(FontWeight.CHINA) self._html_renderer = HtmlRenderer(text="", text_size={ElementType.P: ITEM_DESC_FONT_SIZE}, text_color=ITEM_DESC_TEXT_COLOR) @@ -539,7 +539,7 @@ class BaseSpinBoxAction(ItemAction, ABC): display_text = self._get_display_text() color = ITEM_TEXT_VALUE_COLOR if is_enabled else ITEM_DESC_TEXT_COLOR gui_label(label_rect, display_text, font_size=ITEM_TEXT_FONT_SIZE, color=color, - font_weight=FontWeight.NORMAL, alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER, + font_weight=FontWeight.CHINA, alignment=rl.GuiTextAlignment.TEXT_ALIGN_CENTER, alignment_vertical=rl.GuiTextAlignmentVertical.TEXT_ALIGN_MIDDLE) return False diff --git a/system/ui/widgets/option_dialog.py b/system/ui/widgets/option_dialog.py index 3b22011..e3455bc 100644 --- a/system/ui/widgets/option_dialog.py +++ b/system/ui/widgets/option_dialog.py @@ -17,7 +17,7 @@ LIST_ITEM_SPACING = 25 class MultiOptionDialog(Widget): - def __init__(self, title, options, current="", option_font_weight=FontWeight.MEDIUM): + def __init__(self, title, options, current="", option_font_weight=FontWeight.CHINA): super().__init__() self.title = title self.options = options @@ -48,7 +48,7 @@ class MultiOptionDialog(Widget): content_rect = rl.Rectangle(dialog_rect.x + MARGIN, dialog_rect.y + MARGIN, dialog_rect.width - 2 * MARGIN, dialog_rect.height - 2 * MARGIN) - gui_label(rl.Rectangle(content_rect.x, content_rect.y, content_rect.width, TITLE_FONT_SIZE), self.title, 70, font_weight=FontWeight.BOLD) + gui_label(rl.Rectangle(content_rect.x, content_rect.y, content_rect.width, TITLE_FONT_SIZE), self.title, 70, font_weight=FontWeight.CHINA) # Options area options_y = content_rect.y + TITLE_FONT_SIZE + ITEM_SPACING