iris: make font families application-named strings

This commit is contained in:
iris committed 2026-09-12 13:09:31 -04:00
1 parent bdc9c914c4
commit 4cbe7baea0
9 files changed
+56 -90

No files matched your search

+4 -4
View File
@@ -210,7 +210,7 @@ pub fn render_markdown(src: &str, base_size: f32, theme: &Theme) -> Rendered {
TagEnd::CodeBlock => {
spans.push(
SpanStyle::new(range.clone())
.family(Family::Monospace)
.family(MONOSPACE)
.color(theme.code.clone()),
);
if let Some(language) = fence_language.take() {
@@ -226,7 +226,7 @@ pub fn render_markdown(src: &str, base_size: f32, theme: &Theme) -> Rendered {
out.push_str(&text);
spans.push(
SpanStyle::new(start..out.len())
.family(Family::Monospace)
.family(MONOSPACE)
.color(theme.code.clone()),
);
}
@@ -291,7 +291,7 @@ pub(crate) fn highlight_into(
};
spans.push(
SpanStyle::new(range.start + start..range.start + end)
.family(Family::Monospace)
.family(MONOSPACE)
.color(syntax_color(span.kind, theme)),
);
}
@@ -525,7 +525,7 @@ mod tests {
let r = block("```brainfuck\nlet x = 1;\n```");
assert_eq!(r.text, "let x = 1;");
assert_eq!(r.spans.len(), 1);
assert!(r.spans[0].family == Some(Family::Monospace));
assert!(r.spans[0].family.as_deref() == Some(MONOSPACE));
assert_eq!(r.spans[0].color, Some(code_color()));
}
+3 -2
View File
@@ -15,12 +15,13 @@ use std::{mem, rc::Rc};
use theme::Theme;
const ICON_FONT: &[u8] = include_bytes!("../../assets/fonts/nerd_icons.ttf");
const ICON_FAMILY: &str = "ai-app-icons";
pub(crate) fn register_fonts(ui: &mut Ui) {
if ui.is_font_registered(&Family::Icons) {
if ui.is_font_registered(ICON_FAMILY) {
return;
}
ui.register_font(Family::Icons, ICON_FONT)
ui.register_font(ICON_FAMILY, ICON_FONT)
.expect("the ai-app icon font must register before text is drawn");
}
+1 -5
View File
@@ -198,11 +198,7 @@ where
.spans(rendered.spans)
.text_align(Align::LEFT)
.wrap(!verbatim)
.family(if verbatim {
Family::Monospace
} else {
Family::SansSerif
})
.family(if verbatim { MONOSPACE } else { SANS_SERIF })
.size(BASE_SIZE)
.color(match frame {
BlockFrame::Quote => theme.quote_text.clone(),
+2 -6
View File
@@ -80,18 +80,14 @@ fn text<Rsc>(content: impl Into<String>, size: f32, color: PaintId) -> TextBuild
}
fn disclosure<Rsc>(glyph: &'static str, theme: &Theme) -> TextBuilder<Rsc> {
text(glyph, MARK_DP, theme.muted.clone()).family(Family::Icons)
text(glyph, MARK_DP, theme.muted.clone()).family(super::ICON_FAMILY)
}
fn raw_block<Rsc: HasEvents>(rsc: &mut Rsc, body: TextBuilder<Rsc>, theme: &Theme) -> StrongWidget
where
Rsc::State: FocusHost,
{
let field = body
.family(Family::Monospace)
.size(BODY_SIZE)
.wrap(false)
.add(rsc);
let field = body.family(MONOSPACE).size(BODY_SIZE).wrap(false).add(rsc);
field
.scrollable(Axis::X, Pin::Start)
.pad(dp(RAW_PAD_DP))