Home: the title is drawn at 24 points again

The compact type was set to 92% of its nominal sizes (body 13 to 12,
labels 12.5 to 11.5, captions 11.5 to 10.5), but the display type that
draws the Home title stayed at 26 points on a 32-point line, so the
title drew about 8.7% larger than in 0.24.1. The display type is now
24 points on a 29-point line, its nominal 26 on 32 at the same scale.

A test checks that the title keeps the nominal title-to-body
proportion against the compact body type, and that its line keeps the
framework's display line proportion.
This commit is contained in:
dotCooCoo committed 2026-12-02 13:51:35 -08:00
1 parent 38df6754c0
commit f5111b293d
1 file changed
+35 -3
+35 -3
View File
@@ -146,7 +146,8 @@ pub fn root_theme(prefs: &Prefs) -> (ThemeId, ModeChoice, Option<Rgba>) {
}
/// The app's sizes over the framework's size sets (`sizes.json`): push buttons have the app's 4-point corners
/// where the sets give pills, the Home title is 26-point with a 36-point call to action, 28-point New and Open with 16
/// where the sets give pills, the Home title is 24-point on a 29-point line (its nominal 26 points on 32 at the 92%
/// the body type below is set at) with a 36-point call to action, 28-point New and Open with 16
/// points beside their labels and 24-point link rows. Home's margin and the gaps between its title, actions, sections,
/// headings and links are the framework's page tokens, which follow its spacing scale (`space.gap.*`). The compact set
/// takes the reference app's metrics:
@@ -159,8 +160,8 @@ pub fn root_theme(prefs: &Prefs) -> (ThemeId, ModeChoice, Option<Rgba>) {
const SIZES: &[u8] = br#"{
"all": {
"radius.button": 4,
"typography.display.size": 26,
"typography.display.line_height": 32,
"typography.display.size": 24,
"typography.display.line_height": 29,
"size.page.action": 36,
"size.page.button": 28,
"size.page.button_side": 16,
@@ -236,6 +237,37 @@ mod tests {
assert!(AppSizes::parse(SIZES).is_ok_and(|sizes| !sizes.is_empty()));
}
/// The Home title (the display type) is set at the same scale as the compact body type, so it keeps the nominal
/// 26-point title over a 13-point body proportion, and its line keeps the framework's display line proportion.
#[test]
fn the_home_title_is_scaled_with_the_body_type() {
use craft::theme::Size;
use craft::ui::runtime::env::{Env, RootEnv};
use craft::ui::testing::Fixture;
use std::cell::Cell;
use std::rc::Rc;
const NOMINAL_TITLE_OVER_BODY: f32 = 26.0 / 13.0;
let typography = |sizes: Arc<AppSizes>| {
let seen = Rc::new(Cell::new(None));
let seen_in = Rc::clone(&seen);
let mut fixture = Fixture::new(move |ui| {
let t = Env::of(ui).tokens.tokens().typography;
seen_in.set(Some((t.display, t.body)));
});
let mut root = RootEnv::new().density(Size::Compact);
root.sizes = sizes;
fixture.root(root);
fixture.frame(vec![]);
seen.get().expect("the fixture drew a frame")
};
let (display, body) = typography(app_sizes());
let ratio = display.size / body.size;
assert!((ratio - NOMINAL_TITLE_OVER_BODY).abs() < 0.05, "a {}-point title over a {}-point body", display.size, body.size);
let (framework, _) = typography(Arc::new(AppSizes::default()));
let (line, framework_line) = (display.line_height / display.size, framework.line_height / framework.size);
assert!((line - framework_line).abs() < 0.05, "a {}-point line for a {}-point title", display.line_height, display.size);
}
/// Home's margin and gaps are the framework's page tokens: no size set gives them points of its own, so they follow
/// the framework's spacing scale.
#[test]