Address Inter font review findings (#52)
CI / core (pull_request) Successful in 38s
CI / core (push) Successful in 1m14s

- Set Inter only when DirectWrite resolves its family, so a name
  mismatch keeps the system font instead of a fallback on every run.
- Rename init to init_theme and share the family name as a constant.
- Make the test prove a semibold face: its glyphs are wider.
- Ship the license from the same Inter release as the font.
- Shorten the search placeholder so it fits at the minimum width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit was merged in pull request #52.
This commit is contained in:
nessarandClaude Opus 5.5 committed 2026-11-19 22:10:16 +01:00
1 parent 1016b68e41
commit 650dfd4bfa
3 files changed
+36 -26

No files matched your search

+3 -4
View File
@@ -1,9 +1,8 @@
Copyright 2020 The Inter Project Authors (https://github.com/rsms/inter) Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
This Font Software is licensed under the SIL Open Font License, Version 1.1. This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org http://scripts.sil.org/OFL
----------------------------------------------------------- -----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
@@ -44,7 +43,7 @@ new environment.
"Author" refers to any designer, engineer, programmer, technical "Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software. writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS PERMISSION AND CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify, a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font redistribute, and sell modified and unmodified copies of the Font
+32 -20
View File
@@ -223,13 +223,20 @@ fn startup() -> Result<Setup, (Vec<String>, Preferences)> {
}) })
} }
fn init(cx: &mut App) { /// DirectWrite exposes the variable font's text optical size as its own family.
gpui_kit::init(cx); const INTER: &str = "Inter Variable Text";
let inter = include_bytes!("../assets/InterVariable.ttf");
match cx.text_system().add_fonts(vec![Cow::Borrowed(inter)]) { /// Sets Inter as the interface font and adjusts the theme colours. Needs `gpui_kit::init` first.
// DirectWrite exposes the variable font's text optical size as its own family. fn init_theme(cx: &mut App) {
Ok(()) => Theme::update(cx, |theme| theme.font_family = "Inter Variable Text".into()), let text = cx.text_system();
Err(error) => eprintln!("Failed to load Inter: {error}"), let ttf = include_bytes!("../assets/InterVariable.ttf");
if let Err(error) = text.add_fonts(vec![Cow::Borrowed(ttf)]) {
eprintln!("Failed to load Inter: {error}");
}
// A family that falls back costs a font lookup on every text run: keep the system font then.
let inter = font(INTER);
if text.get_font_for_id(text.resolve_font(&inter)) == Some(inter) {
Theme::update(cx, |theme| theme.font_family = INTER.into());
} }
// The default dark table header text has low contrast against its background. // The default dark table header text has low contrast against its background.
let dark = Rc::make_mut(&mut Theme::global_mut(cx).dark_theme); let dark = Rc::make_mut(&mut Theme::global_mut(cx).dark_theme);
@@ -239,7 +246,8 @@ fn init(cx: &mut App) {
fn main() { fn main() {
let app = gpui_kit::application().with_assets(gpui_kit::assets::Assets); let app = gpui_kit::application().with_assets(gpui_kit::assets::Assets);
app.run(move |cx| { app.run(move |cx| {
init(cx); gpui_kit::init(cx);
init_theme(cx);
#[cfg(feature = "profile")] #[cfg(feature = "profile")]
profile::start(cx); profile::start(cx);
let options = WindowOptions { let options = WindowOptions {
@@ -289,12 +297,13 @@ mod tests {
use gpui_kit::component::{Theme, ThemeMode}; use gpui_kit::component::{Theme, ThemeMode};
use gpui_kit::{ use gpui_kit::{
AppContext as _, FontWeight, KeyDownEvent, KeyUpEvent, Keystroke, Modifiers, AppContext as _, FontWeight, KeyDownEvent, KeyUpEvent, Keystroke, Modifiers,
TestAppContext, VisualTestContext, WindowOptions, font, point, TestAppContext, VisualTestContext, WindowOptions, font, point, px,
}; };
use super::{KeyStore, RootView, Screen, Setup}; use super::{INTER, KeyStore, RootView, Screen, Setup};
use crate::title_bar::{BAR_HEIGHT, BUTTON_WIDTH}; use crate::title_bar::{BAR_HEIGHT, BUTTON_WIDTH};
// Not #[gpui::test]: its text system is a no-op, and this checks DirectWrite's real one.
#[test] #[test]
fn inter_is_used_in_both_themes() { fn inter_is_used_in_both_themes() {
let platform = gpui_kit::platform::current_platform(false); let platform = gpui_kit::platform::current_platform(false);
@@ -304,19 +313,22 @@ mod tests {
platform.text_system(), platform.text_system(),
); );
cx.update(|cx| { cx.update(|cx| {
super::init(cx); gpui_kit::init(cx);
super::init_theme(cx);
for mode in [ThemeMode::Light, ThemeMode::Dark] { for mode in [ThemeMode::Light, ThemeMode::Dark] {
Theme::change(mode, None, cx); Theme::change(mode, None, cx);
let family = &Theme::global(cx).font_family; assert_eq!(Theme::global(cx).font_family.as_str(), INTER);
assert_eq!(family.as_str(), "Inter Variable Text");
let text = cx.text_system();
for weight in [FontWeight::NORMAL, FontWeight::SEMIBOLD] {
let mut requested = font(family.clone());
requested.weight = weight;
let resolved = text.get_font_for_id(text.resolve_font(&requested));
assert_eq!(resolved, Some(requested));
}
} }
// DirectWrite returns the nearest weight, so only a wider glyph proves a semibold face.
let text = cx.text_system();
let [regular, semibold] = [FontWeight::NORMAL, FontWeight::SEMIBOLD].map(|weight| {
let mut requested = font(INTER);
requested.weight = weight;
let id = text.resolve_font(&requested);
assert_eq!(text.get_font_for_id(id), Some(requested));
text.advance(id, px(14.), 'm').unwrap().width
});
assert!(semibold > regular, "{semibold:?} <= {regular:?}");
}); });
} }
+1 -2
View File
@@ -168,8 +168,7 @@ impl StatsPage {
let format_names = vec![SharedString::from(ALL_FORMATS)]; let format_names = vec![SharedString::from(ALL_FORMATS)];
let format_select = cx let format_select = cx
.new(|cx| SelectState::new(format_names.clone(), Some(IndexPath::new(0)), window, cx)); .new(|cx| SelectState::new(format_names.clone(), Some(IndexPath::new(0)), window, cx));
let search_input = let search_input = cx.new(|cx| InputState::new(window, cx).placeholder("Rechercher"));
cx.new(|cx| InputState::new(window, cx).placeholder("Rechercher un champion"));
let charts = cx.new(|_| ChartsRow::new()); let charts = cx.new(|_| ChartsRow::new());
let table = cx.new(|_| ChampionTable::new()); let table = cx.new(|_| ChampionTable::new());