font browser
Preview a family's Narrow / Condensed cuts at their own width
face_attrs now passes the face's width class through cce-ui's new
TextAttrs::stretch, so choosing Circe Slab A's Narrow styles previews
the narrow cut instead of its normal-width sibling at the same weight.
Repins cce-ui to its origin head for TextAttrs::stretch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cargo.lock | 2 +-
Cargo.toml | 2 +-
src/main.rs | 20 +++++++++++---------
3 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index ce9d7aa..fd5437d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -348,7 +348,7 @@ dependencies = [
[[package]]
name = "cce-ui"
version = "0.1.0"
-source = "git+https://github.com/lsgalante/cce-ui.git?rev=0dea9002fa5a7d828fac3e373167e6b620765479#0dea9002fa5a7d828fac3e373167e6b620765479"
+source = "git+https://github.com/lsgalante/cce-ui.git?rev=9771c92bc295ccc161e68a493251e7096b765b05#9771c92bc295ccc161e68a493251e7096b765b05"
dependencies = [
"ash",
"bitflags 2.13.1",
diff --git a/Cargo.toml b/Cargo.toml
index 4fc329e..cf460a6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-cce-ui = { git = "https://github.com/lsgalante/cce-ui.git", rev = "0dea9002fa5a7d828fac3e373167e6b620765479" }
+cce-ui = { git = "https://github.com/lsgalante/cce-ui.git", rev = "9771c92bc295ccc161e68a493251e7096b765b05" }
smithay-client-toolkit = "0.19.2"
calloop = "0.13.0"
calloop-wayland-source = "0.3.0"
diff --git a/src/main.rs b/src/main.rs
index 4ff1096..f8ed278 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -396,22 +396,24 @@ impl TypefaceApp {
self.sync_preview_font();
}
- /// The italic / weight that select exactly the face at `file`#`index`, as
- /// fontdb read them from the font itself. cosmic-text takes a family's face
- /// only at its exact weight (and style), so the style NAME is no guide:
+ /// The italic / weight / width that select exactly the face at `file`#`index`,
+ /// as fontdb read them from the font itself. cosmic-text takes a family's face
+ /// only at its exact weight, style and stretch, so the style NAME is no guide:
/// Circe Slab's Light is weight 350, Bodoni Egyptian Mono Thin 280, Roboto's
- /// Thin 250, and a guessed 300 or 400 matched none of them. (A cut that
- /// differs only in width, Circe Slab A Narrow, cannot be told apart this
- /// way: `TextAttrs` carries no stretch, so it previews as its normal-width
- /// sibling at the same weight.)
+ /// Thin 250, and a guessed 300 or 400 matched none of them; Circe Slab A Narrow
+ /// differs from its sibling only in width.
fn face_attrs(&self, file: &str, index: u32) -> cce_ui::scene::paint::TextAttrs {
- use cce_ui::cosmic_text::fontdb::{Source, Style};
+ use cce_ui::cosmic_text::fontdb::{Source, Stretch, Style};
let face = self.font_system.db().faces().find(|f| {
f.index == index
&& matches!(&f.source, Source::File(p) | Source::SharedFile(p, _) if p.as_os_str() == file)
});
match face {
- Some(f) => cce_ui::scene::paint::TextAttrs { italic: f.style != Style::Normal, weight: Some(f.weight.0) },
+ Some(f) => cce_ui::scene::paint::TextAttrs {
+ italic: f.style != Style::Normal,
+ weight: Some(f.weight.0),
+ stretch: (f.stretch != Stretch::Normal).then(|| f.stretch.to_number()),
+ },
None => cce_ui::scene::paint::TextAttrs::default(),
}
}