Font menu: a Document filter lists only the families the current document uses

A Document chip beside the star filter lists only the font families that
type in the current document is set in, as the quick filter on the font
browser overview help page describes:
https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/font-options-overview.html

The filter combines with search, script, kind, Variable, favorites, Recent
Fonts and Show Similar Fonts, steers the closed field's wheel, follows
edits and undo while the menu is open, and is shared by every font menu
for the session. Type in hidden, locked and masked objects, symbols,
patterns and graph designs counts; a composite font lists under its own
name; a family the document names but the computer lacks is not listed.
A document without available fonts lists nothing with its own message,
and with no document open the chip is unavailable.
This commit is contained in:
dotCooCoo committed 2026-11-16 08:12:38 -08:00
1 parent a6e94de555
commit 4f750f1cd6
31 files changed
+333 -23

No files matched your search

+121 -20
View File
@@ -4,7 +4,9 @@
//! or reached with ↑/↓ previews its font on the selected text (one live interaction, nothing in
//! the history); a click or Enter applies it as one step, Escape or closing the menu puts the text
//! back. The Glyphs panel and Find Font only pick a font ([`picked`]): nothing is previewed on the
//! document. A star marks a favourite family, and the ★ filter lists only those. The ≈ button
//! document. A star marks a favourite family, and the ★ filter lists only those. The Document
//! filter lists only the families that type in the current document is set in
//! ([`document_families`]), and is unavailable while no document is open. The ≈ button
//! before a family's star (Show Similar Fonts) orders the listed families by how alike they look to
//! it ([`vectorcraft_text::FontDb::similar_families`]), that family first and without the Recent
//! Fonts section, until the ≈ chip under the filters clears it or the menu closes. The Font
@@ -119,10 +121,23 @@ pub struct MenuLook<'a> {
pub wheel_owner: Option<WheelOwner>,
/// The name screen readers give the closed field when no label stands beside it.
pub name: Option<&'a str>,
/// The current document, which the Document filter lists the families of. `None`: no document
/// is open, and the filter is unavailable.
pub document: Option<MenuDocument<'a>>,
}
/// The current document as the Document filter reads it.
#[derive(Clone, Copy, Debug)]
pub struct MenuDocument<'a> {
/// The document's identity and revision: its families are listed again when either changes.
pub uid: u64,
pub revision: u64,
pub doc: &'a vectorcraft_doc::Document,
}
impl Default for MenuLook<'static> {
/// Samples on in the theme's colors, English names, medium rows, no favorites, no wheel.
/// Samples on in the theme's colors, English names, medium rows, no favorites, no wheel, no
/// document.
fn default() -> Self {
Self {
samples: true,
@@ -134,6 +149,7 @@ impl Default for MenuLook<'static> {
wheel: false,
wheel_owner: None,
name: None,
document: None,
}
}
}
@@ -155,6 +171,7 @@ impl<'a> MenuLook<'a> {
wheel: false,
wheel_owner: None,
name: None,
document: app.session.active().map(|state| MenuDocument { uid: state.uid, revision: state.revision, doc: &state.doc }),
}
}
}
@@ -310,8 +327,13 @@ fn remap_highlight(before: &[Row], selected: Option<usize>, after: &[Row]) -> Op
/// What the rows were listed for: the query, the script, kind, font technology (variable only) and
/// favourites filters, Show Font Names in English, the expanded families, favourites, recent
/// history, font list generation and the family Show Similar Fonts orders by.
type RowsKey = (String, usize, Option<FontClass>, bool, bool, bool, Vec<String>, Vec<String>, Vec<String>, u64, Option<String>);
/// history, font list generation, the family Show Similar Fonts orders by, and the document (its
/// uid and revision) while the Document filter lists its families.
type RowsKey = (String, usize, Option<FontClass>, bool, bool, bool, Vec<String>, Vec<String>, Vec<String>, u64, Option<String>, Option<(u64, u64)>);
/// The families a [`MenuState`] found in a document (lowercase), and the document's uid, revision
/// and font list generation they were found for.
type DocumentFonts = ((u64, u64, u64), Arc<HashSet<String>>);
/// The menu's state between frames.
#[derive(Clone, Default)]
@@ -327,12 +349,18 @@ struct MenuState {
highlight: Option<usize>,
query: String,
/// The filters (kept from one opening to the next, and the same in every font menu:
/// [`Filters`]): script (0..[`SCRIPTS`]), kind, font technology (variable fonts only) and
/// favorites only.
/// [`Filters`]): script (0..[`SCRIPTS`]), kind, font technology (variable fonts only),
/// favorites only and the current document's families only.
script: usize,
class: Option<FontClass>,
variable_only: bool,
favorites_only: bool,
document_only: bool,
/// The families of the current document the Document filter last listed.
document_fonts: Option<DocumentFonts>,
/// The Document filter lists nothing because the document's type uses none of the menu's
/// families (none at all, or only missing ones), whatever the other filters.
none_used: bool,
/// Families whose styles are listed (lowercase).
expanded: Vec<String>,
/// Show Similar Fonts: the family the list is ordered by likeness to, until it is cleared or
@@ -366,11 +394,18 @@ struct Filters {
class: Option<FontClass>,
variable_only: bool,
favorites_only: bool,
document_only: bool,
}
impl Filters {
fn of(st: &MenuState) -> Self {
Self { script: st.script, class: st.class, variable_only: st.variable_only, favorites_only: st.favorites_only }
Self {
script: st.script,
class: st.class,
variable_only: st.variable_only,
favorites_only: st.favorites_only,
document_only: st.document_only,
}
}
fn apply(self, st: &mut MenuState) {
@@ -378,9 +413,51 @@ impl Filters {
st.class = self.class;
st.variable_only = self.variable_only;
st.favorites_only = self.favorites_only;
st.document_only = self.document_only;
}
}
/// The families the type in `doc` is set in, lowercase and by the name the menu lists them under
/// ([`vectorcraft_text::FontDb::canonical`]): the runs of every text object in the layers, symbols,
/// patterns and graph designs, hidden, locked and masked ones included, with a composite font named
/// as such. A pattern being edited is read from its editing layer only. Styles no type uses are left
/// out.
fn document_families(db: &vectorcraft_text::FontDb, doc: &vectorcraft_doc::Document) -> HashSet<String> {
// Each name once, so a document with many runs in a few families looks each family up once.
let mut named: HashSet<String> = HashSet::new();
let mut add = |n: &vectorcraft_doc::Node| {
if let vectorcraft_doc::NodeKind::Text(t) = &n.kind {
for r in &t.runs {
if !named.contains(&r.style.font_family) {
named.insert(r.style.font_family.clone());
}
}
}
};
let editing = doc.pattern_edit.as_ref().map(|e| e.pattern.as_str());
let patterns = doc.patterns.iter().filter(|p| Some(p.name.as_str()) != editing).flat_map(|p| p.art.iter().map(|a| &**a));
let designs = doc.graph_designs.iter().map(|g| &*g.art);
for n in doc.layers.iter().map(|l| &**l).chain(doc.symbols.iter().map(|s| &*s.art)).chain(patterns).chain(designs) {
vectorcraft_doc::swatches::walk_with_masks(n, &mut add);
}
named.into_iter().map(|f| db.canonical(&f, "").0.to_lowercase()).collect()
}
/// The families the Document filter lists, when it is on and a document is open: those of
/// `look`'s document, found again only when the document, its revision or the font list changed.
fn used_families(db: &vectorcraft_text::FontDb, st: &mut MenuState, look: MenuLook) -> Option<Arc<HashSet<String>>> {
let document = look.document.filter(|_| st.document_only)?;
let key = (document.uid, document.revision, db.generation());
if let Some((k, families)) = &st.document_fonts
&& *k == key
{
return Some(families.clone());
}
let families = Arc::new(document_families(db, document.doc));
st.document_fonts = Some((key, families.clone()));
Some(families)
}
/// Where the filters every font menu shares are kept ([`Filters`]).
fn filters_id() -> egui::Id {
egui::Id::unique("font-menu-filters")
@@ -448,7 +525,7 @@ pub fn font_menu(
WheelInput::Leave => st.wheel_order = None,
WheelInput::Notches(notches) => {
if st.wheel_order.is_none() {
st.wheel_order = Some(wheel_order(&st, look).into());
st.wheel_order = Some(wheel_order(&mut st, look).into());
}
if let Some(order) = st.wheel_order.as_deref() {
let next = wheel_steps(order, &own, notches);
@@ -488,8 +565,12 @@ pub fn font_menu(
out
}
/// Does the menu list family `f` for search `query` (lowercase) under the filters of `st`?
fn listed(db: &vectorcraft_text::FontDb, f: &str, query: &str, st: &MenuState, look: MenuLook) -> bool {
/// Does the menu list family `f` for search `query` (lowercase) under the filters of `st`, and
/// among `used` (lowercase) while the Document filter lists the document's families?
fn listed(db: &vectorcraft_text::FontDb, f: &str, query: &str, st: &MenuState, look: MenuLook, used: Option<&HashSet<String>>) -> bool {
if used.is_some_and(|used| !used.contains(&f.to_lowercase())) {
return false;
}
let label = db.family_display_name(f, look.english_names);
if !(query.is_empty() || f.to_lowercase().contains(query) || label.to_lowercase().contains(query)) {
return false;
@@ -506,9 +587,10 @@ fn listed(db: &vectorcraft_text::FontDb, f: &str, query: &str, st: &MenuState, l
/// The families the closed field's wheel steps through, in the open menu's order with no search:
/// the recent families first, then the others, under the menu's filters.
fn wheel_order(st: &MenuState, look: MenuLook) -> Vec<String> {
fn wheel_order(st: &mut MenuState, look: MenuLook) -> Vec<String> {
let db = vectorcraft_text::FontDb::global();
let families: Vec<_> = db.menu_family_list().iter().filter(|f| listed(db, f, "", st, look)).cloned().collect();
let used = used_families(db, st, look);
let families: Vec<_> = db.menu_family_list().iter().filter(|f| listed(db, f, "", st, look, used.as_deref())).cloned().collect();
grouped_rows(&families, look.recent, &[], |_| vec![])
.into_iter()
.filter_map(|r| match r {
@@ -1075,7 +1157,7 @@ fn header<'s>(ui: &mut Ui, db: &'s vectorcraft_text::FontDb, state_id: egui::Id,
ui.memory_mut(|m| m.request_focus(field.with("edit")));
}
let query = widgets::search_field(ui, field, tl!("Search")).to_lowercase();
let refilter = filters(ui, st, &t);
let refilter = filters(ui, st, &t, look.document.is_some());
let enter = ui.input(|i| i.key_pressed(egui::Key::Enter));
// The current family by its own name (a document may name it in Japanese: ヒラギノ角ゴシック),
// as it was before any preview.
@@ -1094,9 +1176,12 @@ fn header<'s>(ui: &mut Ui, db: &'s vectorcraft_text::FontDb, state_id: egui::Id,
look.recent.to_vec(),
db.generation(),
st.similar.clone(),
look.document.filter(|_| st.document_only).map(|d| (d.uid, d.revision)),
);
if st.rows_key.as_ref() != Some(&key) {
let families: Vec<_> = db.menu_family_list().iter().filter(|f| listed(db, f, &query, st, look)).cloned().collect();
let used = used_families(db, st, look);
let families: Vec<_> = db.menu_family_list().iter().filter(|f| listed(db, f, &query, st, look, used.as_deref())).cloned().collect();
st.none_used = families.is_empty() && used.is_some_and(|used| !db.menu_family_list().iter().any(|f| used.contains(&f.to_lowercase())));
// Show Similar Fonts orders every listed family by likeness, the recent ones among them.
let rows = match &st.similar {
Some(base) => grouped_rows(&db.similar_families(base, &families), &[], &st.expanded, |f| db.styles(f)),
@@ -1145,7 +1230,9 @@ fn header<'s>(ui: &mut Ui, db: &'s vectorcraft_text::FontDb, state_id: egui::Id,
}
st.header = ui.min_rect().height();
if rows.is_empty() {
widgets::dim_label(ui, tl!("No matching fonts"));
// The Document filter on a document whose type uses none of the listed families (none at
// all, or only missing ones) says so, whatever the other filters.
widgets::dim_label(ui, if st.none_used { tl!("This document uses no available fonts") } else { tl!("No matching fonts") });
}
ui.spacing_mut().item_spacing.y = 0.0;
// The scroll bar beside the rows, not over them: a floating one covered the stars at their
@@ -1160,6 +1247,8 @@ enum Chip {
/// A script ([`SCRIPTS`]).
Script(usize),
Favorites,
/// The families the current document's type uses.
Document,
AnyKind,
Class(FontClass),
/// The Font Technology label, which filters nothing.
@@ -1167,21 +1256,22 @@ enum Chip {
Variable,
}
/// The filters, row by row, the same wherever the menu opens: the scripts; favorites, any kind
/// and the first three kinds; the other kinds; font technology.
/// The filters, row by row, the same wherever the menu opens: the scripts; favorites, the
/// document's fonts, any kind and the first three kinds; the other kinds; font technology.
fn filter_rows() -> [Vec<Chip>; 4] {
let (first, rest) = FontClass::ALL.split_at(3);
[
(0..SCRIPTS).map(Chip::Script).collect(),
[Chip::Favorites, Chip::AnyKind].into_iter().chain(first.iter().copied().map(Chip::Class)).collect(),
[Chip::Favorites, Chip::Document, Chip::AnyKind].into_iter().chain(first.iter().copied().map(Chip::Class)).collect(),
rest.iter().copied().map(Chip::Class).collect(),
vec![Chip::Technology, Chip::Variable],
]
}
/// The filters on their rows ([`filter_rows`]): a row wraps only where the menu is narrower than
/// it. Records in `st` the width of the widest row unwrapped; whether a filter changed.
fn filters(ui: &mut Ui, st: &mut MenuState, t: &Tokens) -> bool {
/// it. The Document filter is unavailable without a `document`. Records in `st` the width of the
/// widest row unwrapped; whether a filter changed.
fn filters(ui: &mut Ui, st: &mut MenuState, t: &Tokens, document: bool) -> bool {
let mut refilter = false;
let mut widest = 0.0_f32;
for row in filter_rows() {
@@ -1194,6 +1284,16 @@ fn filters(ui: &mut Ui, st: &mut MenuState, t: &Tokens) -> bool {
let resp = match chip {
Chip::Script(i) => ui.selectable_label(st.script == i, text(script_label(i))),
Chip::Favorites => ui.selectable_label(st.favorites_only, text("★")).on_hover_text(tl!("Favorites")),
Chip::Document => {
let on = st.document_only && document;
let tip = tl!("Fonts used in this document");
let resp = ui
.add_enabled(document, egui::Button::selectable(on, text(tl!("Document"))))
.on_hover_text(tip)
.on_disabled_hover_text(tip);
resp.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, document, on, tip));
resp
}
Chip::AnyKind => ui.selectable_label(st.class.is_none(), text(tl!("Any Kind"))),
Chip::Class(c) => ui.selectable_label(st.class == Some(c), text(class_label(c))),
Chip::Technology => ui.label(text(tl!("Font Technology")).color(t.text_dim)),
@@ -1206,6 +1306,7 @@ fn filters(ui: &mut Ui, st: &mut MenuState, t: &Tokens) -> bool {
match chip {
Chip::Script(i) => st.script = i,
Chip::Favorites => st.favorites_only = !st.favorites_only,
Chip::Document => st.document_only = !st.document_only,
Chip::AnyKind => st.class = None,
Chip::Class(c) => st.class = if st.class == Some(c) { None } else { Some(c) },
Chip::Technology => continue,
+155 -3
View File
@@ -380,15 +380,15 @@ fn the_wheel_follows_the_menus_order_and_filters() {
}
let recent = vec![names[2].clone()];
let look = super::MenuLook { samples: false, recent: &recent, ..Default::default() };
let order = super::wheel_order(&super::MenuState::default(), look);
let order = super::wheel_order(&mut super::MenuState::default(), look);
assert_eq!(order.first(), Some(&names[2]), "the recent family first");
// Other tests add fonts to the process-wide database meanwhile: compare places, not neighbours.
let at = |f: &String| order.iter().position(|x| x == f);
assert!(matches!((at(&names[0]), at(&names[1])), (Some(a), Some(b)) if 0 < a && a < b), "then the others in the menu's order");
assert_eq!(order.iter().filter(|f| **f == names[2]).count(), 1, "once each");
let favorites = vec![names[0].clone(), names[1].clone()];
let st = super::MenuState { favorites_only: true, ..Default::default() };
let order = super::wheel_order(&st, super::MenuLook { favorites: &favorites, ..look });
let mut st = super::MenuState { favorites_only: true, ..Default::default() };
let order = super::wheel_order(&mut st, super::MenuLook { favorites: &favorites, ..look });
assert_eq!(order, favorites, "the favourites filter");
}
@@ -1131,3 +1131,155 @@ fn show_similar_fonts_orders_the_list_by_likeness() {
frame(vec![], &mut st);
assert_eq!((st.similar.as_deref(), families(&st)), (None, menu_order));
}
/// An app with a new document holding type set in each of `fonts`, one text object each.
fn app_with_type(fonts: &[&str]) -> crate::VectorcraftApp {
let mut app = crate::VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
app.run("file.new", serde_json::json!({})).unwrap();
for (i, font) in fonts.iter().enumerate() {
app.run("text.create", serde_json::json!({"x": 20, "y": 40 + 30 * i, "text": "Type", "font": font})).unwrap();
}
app
}
/// Draws the open menu (its header and rows) for `look` under the filters of `st`, with `events`;
/// returns the shapes drawn.
fn menu_frame(ctx: &egui::Context, st: &mut super::MenuState, look: super::MenuLook, events: Vec<egui::Event>) -> Vec<egui::epaint::ClippedShape> {
let input =
egui::RawInput { events, screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 900.0))), ..Default::default() };
let mut out = ctx.run_ui(input, |ui| {
super::list(ui, egui::Id::unique("document-filter"), st, "Inter", None, look);
});
out.textures_delta.clear();
out.shapes
}
/// The families `st`'s rows list, in their order.
fn listed_families(st: &super::MenuState) -> Vec<String> {
st.rows
.iter()
.filter_map(|r| match r {
Row::Family(f) => Some(f.clone()),
Row::Heading(_) | Row::Style(..) => None,
})
.collect()
}
/// The Document filter's chip lists only the families the document's type uses (hidden and locked
/// type included, a missing family left out), in the menu's order, and lists every family again
/// when it is clicked off.
#[test]
fn the_document_filter_lists_the_families_the_documents_type_uses() {
let mut app = app_with_type(&["Source Serif 4", "Inter"]);
app.run("object.hide", serde_json::json!({})).unwrap();
app.run("text.create", serde_json::json!({"x": 20, "y": 120, "text": "Locked", "font": "Source Sans 3"})).unwrap();
app.run("object.lock", serde_json::json!({})).unwrap();
app.run("text.create", serde_json::json!({"x": 20, "y": 150, "text": "Missing", "font": "Missing Family 7059"})).unwrap();
let db = vectorcraft_text::FontDb::global();
let used = super::document_families(db, &app.session.active().unwrap().doc);
let mut names: Vec<_> = used.iter().cloned().collect();
names.sort();
assert_eq!(names, ["inter", "missing family 7059", "source sans 3", "source serif 4"], "each run's family, as named");
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut st = super::MenuState::default();
let look = super::MenuLook { samples: false, ..super::MenuLook::of(&app) };
for _ in 0..3 {
menu_frame(&ctx, &mut st, look, vec![]);
}
let every = listed_families(&st);
assert!(every.len() > 3, "every family: {every:?}");
let click = |st: &mut super::MenuState, at: egui::Pos2| {
let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
menu_frame(&ctx, st, look, vec![egui::Event::PointerMoved(at), button(true)]);
menu_frame(&ctx, st, look, vec![button(false)]);
menu_frame(&ctx, st, look, vec![])
};
let chip = text_at(&menu_frame(&ctx, &mut st, look, vec![]), |t| t == "Document").expect("the Document chip is drawn");
click(&mut st, chip);
assert!(st.document_only);
let in_menu: Vec<String> = every.iter().filter(|f| ["Inter", "Source Sans 3", "Source Serif 4"].contains(&f.as_str())).cloned().collect();
assert_eq!(listed_families(&st), in_menu, "the document's available families, in the menu's order");
click(&mut st, chip);
assert!(!st.document_only);
assert_eq!(listed_families(&st), every, "every family again");
}
/// Type kept in a graph design counts as the document's type, as type in a symbol does.
#[test]
fn the_document_filter_counts_type_in_graph_designs() {
let mut app = app_with_type(&["Inter"]);
let id = app.run("text.create", serde_json::json!({"x": 20, "y": 90, "text": "Bar", "font": "JetBrains Mono"})).unwrap()["id"].as_u64().unwrap();
let art = app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).cloned().expect("the new type");
app.run("edit.undo", serde_json::json!({})).unwrap();
let mut doc = (*app.session.active().unwrap().doc).clone();
let db = vectorcraft_text::FontDb::global();
assert!(!super::document_families(db, &doc).contains("jetbrains mono"));
doc.graph_designs.push(vectorcraft_doc::GraphDesign { name: "Bars".into(), art: std::sync::Arc::new(art) });
let mut names: Vec<_> = super::document_families(db, &doc).into_iter().collect();
names.sort();
assert_eq!(names, ["inter", "jetbrains mono"]);
}
/// The Document filter combines with the others and with Recent Fonts, follows edits and undo
/// without the menu reopening, and steers the closed field's wheel.
#[test]
fn the_document_filter_combines_with_the_others_and_follows_edits() {
let mut app = app_with_type(&["Inter", "Source Serif 4"]);
let ctx = egui::Context::default();
let mut st = super::MenuState { document_only: true, favorites_only: true, ..Default::default() };
let favorites = vec!["Inter".to_string(), "Source Sans 3".to_string()];
let recent = vec!["Source Sans 3".to_string(), "Source Serif 4".to_string()];
let frames = |app: &crate::VectorcraftApp, st: &mut super::MenuState| {
let look = super::MenuLook { samples: false, favorites: &favorites, recent: &recent, ..super::MenuLook::of(app) };
for _ in 0..2 {
menu_frame(&ctx, st, look, vec![]);
}
};
frames(&app, &mut st);
assert_eq!(listed_families(&st), ["Inter"], "favorites the document uses");
st.favorites_only = false;
frames(&app, &mut st);
assert_eq!(st.rows.first(), Some(&Row::Heading("Recent Fonts")));
assert_eq!(listed_families(&st), ["Source Serif 4", "Inter"], "only the recent family the document uses comes first");
app.run("text.create", serde_json::json!({"x": 20, "y": 120, "text": "New", "font": "Source Sans 3"})).unwrap();
frames(&app, &mut st);
assert_eq!(listed_families(&st), ["Source Sans 3", "Source Serif 4", "Inter"], "an edit lists the new family");
app.run("edit.undo", serde_json::json!({})).unwrap();
frames(&app, &mut st);
assert_eq!(listed_families(&st), ["Source Serif 4", "Inter"], "undo takes it out again");
let look = super::MenuLook { samples: false, recent: &recent, ..super::MenuLook::of(&app) };
assert_eq!(super::wheel_order(&mut st, look), ["Source Serif 4", "Inter"], "the wheel steps through the same families");
}
/// The Document filter on a document without type lists nothing and says why; without a document
/// it is unavailable and lists every family; the filter is shared like the others.
#[test]
fn the_document_filter_on_an_empty_document_or_none() {
let app = app_with_type(&[]);
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut st = super::MenuState { document_only: true, ..Default::default() };
let look = super::MenuLook { samples: false, ..super::MenuLook::of(&app) };
let mut shapes = vec![];
for _ in 0..3 {
shapes = menu_frame(&ctx, &mut st, look, vec![]);
}
assert!(st.rows.is_empty(), "{:?}", st.rows);
assert!(text_at(&shapes, |t| t == "This document uses no available fonts").is_some(), "the filter says the list is empty because of it");
// A search that matches nothing still says so in its own words.
st.document_only = false;
shapes = menu_frame(&ctx, &mut st, look, vec![egui::Event::Text("NoSuchFontFor7059".into())]);
shapes = if st.rows.is_empty() { menu_frame(&ctx, &mut st, look, vec![]) } else { shapes };
assert!(text_at(&shapes, |t| t == "No matching fonts").is_some());
// No document: the filter, kept on, lists every family.
let mut st = super::MenuState { document_only: true, ..Default::default() };
let none = egui::Context::default();
for _ in 0..3 {
menu_frame(&none, &mut st, super::MenuLook { samples: false, ..Default::default() }, vec![]);
}
assert!(st.document_only && !listed_families(&st).is_empty(), "no document: every family");
let mut other = super::MenuState::default();
super::Filters::of(&st).apply(&mut other);
assert!(other.document_only, "every font menu shares the filter");
}
+2
View File
@@ -1290,6 +1290,8 @@ font-technology Variable Променливи
Font List Списък с шрифтове
Show Similar Fonts Показване на подобни шрифтове
Clear Similar Fonts Изчистване на подобните шрифтове
Fonts used in this document Шрифтове, използвани в този документ
This document uses no available fonts Този документ не използва налични шрифтове
Font Preview Size Размер за преглед на шрифта
Font Size Размер на шрифта
Variable Font Променлив шрифт
Can't render this file because it is too large.
+2
View File
@@ -3605,6 +3605,8 @@ theme Appearance Izgled
Font List Lista fontova
Show Similar Fonts Prikaži slične fontove
Clear Similar Fonts Očisti slične fontove
Fonts used in this document Fontovi korišteni u ovom dokumentu
This document uses no available fonts Ovaj dokument ne koristi dostupne fontove
Fonts in Document Fontovi u dokumentu
Refresh Font List Osvježi listu fontova
Replace Font Zamijeni font
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -1807,6 +1807,8 @@ digits Malayalam Malaiàlam
Font List Llista de tipus de lletra
Show Similar Fonts Mostra tipus de lletra semblants
Clear Similar Fonts Esborra els tipus de lletra semblants
Fonts used in this document Tipus de lletra utilitzats en aquest document
This document uses no available fonts Aquest document no utilitza cap tipus de lletra disponible
Font Preview Size Mida de previsualització del tipus de lletra
Font Size Mida del tipus de lletra
Font Style: Estil de tipus de lletra:
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -3708,6 +3708,8 @@ theme Appearance Motiv
Font List Seznam písem
Show Similar Fonts Zobrazit podobná písma
Clear Similar Fonts Zrušit podobná písma
Fonts used in this document Písma použitá v tomto dokumentu
This document uses no available fonts Tento dokument nepoužívá žádná dostupná písma
Fonts in Document Písma v dokumentu
Refresh Font List Obnovit seznam písem
Replace Font Nahradit písmo
Can't render this file because it is too large.
+2
View File
@@ -6105,6 +6105,8 @@ theme Appearance Udseende
Font List Skrifttypeliste
Show Similar Fonts Vis lignende skrifttyper
Clear Similar Fonts Ryd lignende skrifttyper
Fonts used in this document Skrifttyper brugt i dette dokument
This document uses no available fonts Dette dokument bruger ingen tilgængelige skrifttyper
Fonts in Document Skrifttyper i dokumentet
Refresh Font List Opdatér skrifttypeliste
Replace Font Erstat skrifttype
Can't render this file because it is too large.
+2
View File
@@ -1340,6 +1340,8 @@ file-filter Templates Vorlagen
Font List Schriftliste
Show Similar Fonts Ähnliche Schriften anzeigen
Clear Similar Fonts Ähnliche Schriften zurücksetzen
Fonts used in this document In diesem Dokument verwendete Schriften
This document uses no available fonts Dieses Dokument verwendet keine verfügbaren Schriften
Font Preview Size Größe der Schriftvorschau
Font Size Schriftgrad
Variable Font Variable Schrift
Can't render this file because it is too large.
+2
View File
@@ -1275,6 +1275,8 @@ font-technology Variable Μεταβλητές
Font List Λίστα γραμματοσειρών
Show Similar Fonts Εμφάνιση παρόμοιων γραμματοσειρών
Clear Similar Fonts Απαλοιφή παρόμοιων γραμματοσειρών
Fonts used in this document Γραμματοσειρές που χρησιμοποιούνται σε αυτό το έγγραφο
This document uses no available fonts Αυτό το έγγραφο δεν χρησιμοποιεί διαθέσιμες γραμματοσειρές
Font Preview Size Μέγεθος προεπισκόπησης γραμματοσειράς
Font Size Μέγεθος γραμματοσειράς
Variable Font Μεταβλητή γραμματοσειρά
Can't render this file because it is too large.
+2
View File
@@ -1355,6 +1355,8 @@ font-technology Variable Variables
Font List Lista de fuentes
Show Similar Fonts Mostrar fuentes similares
Clear Similar Fonts Borrar fuentes similares
Fonts used in this document Fuentes usadas en este documento
This document uses no available fonts Este documento no usa ninguna fuente disponible
Font Preview Size Tamaño de vista previa de fuente
Font Size Tamaño de fuente
Variable Font Fuente variable
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -3646,6 +3646,8 @@ theme Appearance Ulkoasu
Font List Fonttiluettelo
Show Similar Fonts Näytä samankaltaiset fontit
Clear Similar Fonts Tyhjennä samankaltaiset fontit
Fonts used in this document Tässä asiakirjassa käytetyt fontit
This document uses no available fonts Tämä asiakirja ei käytä saatavilla olevia fontteja
Fonts in Document Asiakirjan fontit
Refresh Font List Päivitä fonttiluettelo
Replace Font Korvaa fontti
Can't render this file because it contains an unexpected character in line 2 and column 73.
+2
View File
@@ -1345,6 +1345,8 @@ font-technology Variable Variables
Font List Liste des polices
Show Similar Fonts Afficher les polices similaires
Clear Similar Fonts Effacer les polices similaires
Fonts used in this document Polices utilisées dans ce document
This document uses no available fonts Ce document n’utilise aucune police disponible
Font Preview Size Taille de l’aperçu des polices
Font Size Taille de police
Variable Font Police variable
Can't render this file because it is too large.
+2
View File
@@ -1460,6 +1460,8 @@
Font List ફોન્ટ યાદી
Show Similar Fonts સમાન ફોન્ટ બતાવો
Clear Similar Fonts સમાન ફોન્ટ સાફ કરો
Fonts used in this document આ દસ્તાવેજમાં વપરાયેલા ફોન્ટ્સ
This document uses no available fonts આ દસ્તાવેજ કોઈ ઉપલબ્ધ ફોન્ટ વાપરતો નથી
Font Preview Size ફોન્ટ પૂર્વાવલોકન સાઇઝ
Font Size ફોન્ટ સાઇઝ
Font Style: ફોન્ટ સ્ટાઇલ:
Can't render this file because it contains an unexpected character in line 72 and column 5.
+2
View File
@@ -2007,6 +2007,8 @@ antiAlias Sharp शार्प
Font List फ़ॉन्ट सूची
Show Similar Fonts समान फ़ॉन्ट दिखाएँ
Clear Similar Fonts समान फ़ॉन्ट साफ़ करें
Fonts used in this document इस डॉक्यूमेंट में उपयोग किए गए फ़ॉन्ट
This document uses no available fonts यह डॉक्यूमेंट कोई उपलब्ध फ़ॉन्ट उपयोग नहीं करता
Font Preview Size फ़ॉन्ट प्रीव्यू साइज़
Font Size फ़ॉन्ट साइज़
Font Size: फ़ॉन्ट साइज़:
Can't render this file because it is too large.
+2
View File
@@ -1680,6 +1680,8 @@ file-filter Templates Sablonok
Font List Betűtípuslista
Show Similar Fonts Hasonló betűtípusok megjelenítése
Clear Similar Fonts Hasonló betűtípusok törlése
Fonts used in this document A dokumentumban használt betűtípusok
This document uses no available fonts A dokumentum nem használ elérhető betűtípust
Font Preview Size Betűtípus-előnézet mérete
Font Size Betűméret
Variable Font Változó betűtípus
Can't render this file because it is too large.
+2
View File
@@ -3382,6 +3382,8 @@ theme Appearance Tampilan
Font List Daftar font
Show Similar Fonts Tampilkan font serupa
Clear Similar Fonts Hapus font serupa
Fonts used in this document Font yang digunakan dalam dokumen ini
This document uses no available fonts Dokumen ini tidak menggunakan font yang tersedia
Fonts in Document Font dalam dokumen
Refresh Font List Segarkan daftar font
Replace Font Ganti font
Can't render this file because it contains an unexpected character in line 2490 and column 5.
+2
View File
@@ -1374,6 +1374,8 @@ file-filter Templates Modelli
Font List Elenco font
Show Similar Fonts Mostra font simili
Clear Similar Fonts Cancella font simili
Fonts used in this document Font usati in questo documento
This document uses no available fonts Questo documento non usa font disponibili
Font Preview Size Dimensione anteprima font
Font Size Dimensione font
Variable Font Font variabile
Can't render this file because it is too large.
+2
View File
@@ -1868,6 +1868,8 @@ antiAlias Sharp シャープ
Font List フォントリスト
Show Similar Fonts 類似フォントを表示
Clear Similar Fonts 類似フォントの表示を解除
Fonts used in this document このドキュメントで使用されているフォント
This document uses no available fonts このドキュメントでは使用可能なフォントが使われていません
Font Preview Size フォントプレビューのサイズ
Font: フォント:
Fonts フォント
Can't render this file because it is too large.
+2
View File
@@ -5362,6 +5362,8 @@ theme Appearance იერსახე
Font List შრიფტების სია
Show Similar Fonts მსგავსი შრიფტების ჩვენება
Clear Similar Fonts მსგავსი შრიფტების გასუფთავება
Fonts used in this document ამ დოკუმენტში გამოყენებული შრიფტები
This document uses no available fonts ეს დოკუმენტი არ იყენებს ხელმისაწვდომ შრიფტებს
Fonts in Document დოკუმენტის შრიფტები
Refresh Font List შრიფტების სიის განახლება
Replace Font შრიფტის ჩანაცვლება
Can't render this file because it is too large.
+2
View File
@@ -1858,6 +1858,8 @@ antiAlias Sharp 날카롭게
Font List 글꼴 목록
Show Similar Fonts 유사한 글꼴 표시
Clear Similar Fonts 유사한 글꼴 지우기
Fonts used in this document 이 문서에서 사용된 글꼴
This document uses no available fonts 이 문서는 사용 가능한 글꼴을 사용하지 않습니다
Font Preview Size 글꼴 미리 보기 크기
Font: 글꼴:
Fonts 글꼴
Can't render this file because it is too large.
+2
View File
@@ -3999,6 +3999,8 @@ theme Appearance Vormgeving
Font List Lettertypelijst
Show Similar Fonts Vergelijkbare lettertypen tonen
Clear Similar Fonts Vergelijkbare lettertypen wissen
Fonts used in this document Lettertypen gebruikt in dit document
This document uses no available fonts Dit document gebruikt geen beschikbare lettertypen
Fonts in Document Lettertypen in document
Refresh Font List Lettertypelijst vernieuwen
Replace Font Lettertype vervangen
Can't render this file because it is too large.
+2
View File
@@ -3587,6 +3587,8 @@ theme Appearance Wygląd
Font List Lista czcionek
Show Similar Fonts Pokaż podobne czcionki
Clear Similar Fonts Wyczyść podobne czcionki
Fonts used in this document Czcionki użyte w tym dokumencie
This document uses no available fonts Ten dokument nie używa żadnych dostępnych czcionek
Fonts in Document Czcionki w dokumencie
Refresh Font List Odśwież listę czcionek
Replace Font Zastąp czcionkę
Can't render this file because it is too large.
+2
View File
@@ -1214,6 +1214,8 @@ antiAlias Sharp Nítido
Font List Lista de Fontes
Show Similar Fonts Mostrar Fontes Semelhantes
Clear Similar Fonts Limpar Fontes Semelhantes
Fonts used in this document Fontes usadas neste documento
This document uses no available fonts Este documento não usa nenhuma fonte disponível
Font Preview Size Tamanho da Visualização da Fonte
Font Size Tamanho da Fonte
Variable Font Fonte Variável
Can't render this file because it is too large.
+2
View File
@@ -1365,6 +1365,8 @@ file-filter Templates Шаблоны
Font List Список шрифтов
Show Similar Fonts Показать похожие шрифты
Clear Similar Fonts Сбросить похожие шрифты
Fonts used in this document Шрифты, используемые в этом документе
This document uses no available fonts В этом документе не используются доступные шрифты
Font Preview Size Размер предварительного просмотра шрифта
Font Size Размер шрифта
Variable Font Вариативный шрифт
Can't render this file because it is too large.
+2
View File
@@ -1308,6 +1308,8 @@ font-technology Variable Variabla
Font List Typsnittslista
Show Similar Fonts Visa liknande typsnitt
Clear Similar Fonts Rensa liknande typsnitt
Fonts used in this document Typsnitt som används i det här dokumentet
This document uses no available fonts Det här dokumentet använder inga tillgängliga typsnitt
Font Preview Size Storlek på typsnittsförhandsgranskning
Font Size Teckenstorlek
Variable Font Variabelt typsnitt
Can't render this file because it is too large.
+2
View File
@@ -1304,6 +1304,8 @@ font-technology Variable Değişken
Font List Yazı Tipi Listesi
Show Similar Fonts Benzer Yazı Tiplerini Göster
Clear Similar Fonts Benzer Yazı Tiplerini Temizle
Fonts used in this document Bu belgede kullanılan yazı tipleri
This document uses no available fonts Bu belge kullanılabilir hiçbir yazı tipini kullanmıyor
Font Preview Size Yazı Tipi Önizleme Boyutu
Font Size Yazı Tipi Boyutu
Font: Yazı tipi:
Can't render this file because it is too large.
+2
View File
@@ -1368,6 +1368,8 @@ file-filter Templates Шаблони
Font List Список шрифтів
Show Similar Fonts Показати схожі шрифти
Clear Similar Fonts Скинути схожі шрифти
Fonts used in this document Шрифти, використані в цьому документі
This document uses no available fonts Цей документ не використовує доступних шрифтів
Font Preview Size Розмір попереднього перегляду шрифту
Font Size Розмір шрифту
Variable Font Варіативний шрифт
Can't render this file because it is too large.
+2
View File
@@ -1591,6 +1591,8 @@ file-filter Templates Mẫu
Font List Danh sách phông
Show Similar Fonts Hiển thị phông tương tự
Clear Similar Fonts Xóa phông tương tự
Fonts used in this document Phông được dùng trong tài liệu này
This document uses no available fonts Tài liệu này không dùng phông nào có sẵn
Font Preview Size Cỡ xem trước phông
Font Size Cỡ chữ
Variable Font Phông chữ biến thiên
Can't render this file because it contains an unexpected character in line 205 and column 5.
+2
View File
@@ -1303,6 +1303,8 @@ file-filter Templates 模板
Font List 字体列表
Show Similar Fonts 显示相似字体
Clear Similar Fonts 清除相似字体
Fonts used in this document 此文档中使用的字体
This document uses no available fonts 此文档未使用任何可用字体
Font Preview Size 字体预览大小
Font Size 字号
Variable Font 可变字体
Can't render this file because it is too large.
+2
View File
@@ -1338,6 +1338,8 @@ file-filter Templates 範本
Font List 字體清單
Show Similar Fonts 顯示相似字體
Clear Similar Fonts 清除相似字體
Fonts used in this document 此文件中使用的字體
This document uses no available fonts 此文件未使用任何可用字體
Font Preview Size 字體預覽大小
Font Size 字體大小
Variable Font 可變字體
Can't render this file because it is too large.
+1
View File
@@ -1800,6 +1800,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- **Fonts:** a font is found by any of its names (family and style in every language of its name table, legacy family/style pairs, PostScript name), so documents from other apps open with the font they name; Find Font and `text.fonts` say for each font whether it was found exactly, by another name, substituted or missing, and how many glyphs are missing. PDF and `.ai` import brings Japanese text back as live type: CID fonts without a ToUnicode map read through the standard CMaps, vertical columns (WMode 1) as vertical type, letter spacing as tracking; a glyph is live type only when the installed font (in the closest style of its family) draws the same glyph, and text in a font that isn't installed comes in as live type shown in the fallback font until the font is installed (exports that draw it — PDF, EPS, EMF/WMF, raster, SVG outlines or embedded fonts — warn that they wrote the fallback font, and Print and Print Preview warn about the type that prints in it; `textAs: outlines` keeps the PDF's embedded glyphs). Two installed versions of one family and style (a font library keeping an old file beside a new one) both load, the first staying the one the family and style resolve to; PDF and `.ai` import tries each version when the glyphs differ, and type set in a version other than that one names it (`CharStyle::font_version`), which layout, the substituted-glyph highlight, Find Font, Package and Document Info follow. Fonts outside the font folders are listed too: those font services such as Adobe Fonts load on Windows, through DirectWrite and, for those only GDI lists, through GDI (#1258), and those apps and font managers register with CoreText on macOS (#579). When a document opens with fonts that aren't available, fonts used only in symbols included, a Missing Fonts dialog lists them after the linked-file questions, with Find Fonts (Type › Find Font on them) and Close. Its Find in Folder… (in Find Font too) searches a folder on several threads, reads only what the font scan reads of font files and skips app packages, the Program Files and ProgramData folders, the system's folders and the app data folders in a home folder; Add Fonts copies the font files the user chooses, suitcase fonts with their resource fork, into VectorCraft's own Fonts folder, which the desktop app and `vectorcraft-cli` read (`text.missingFonts`, `text.findFontFiles`, `text.addFontFiles`). The font scan on Linux also reads the folders fontconfig's configuration lists, such as TeX fonts under `/usr/share/texmf/fonts` (#1548, fixes #1529; not verified on Linux).
A variable font's type gets one slider and field per variation axis under the Character panel's Variable Font button, each named as the font names the axis (Weight, Width), so the type can be set between or past its named instances: the settings stay with the characters (`CharStyle::font_axes`, `text.setFormat {fontAxes}` and `text.setRangeStyle {fontAxes}`, clamped to each axis's range; `text.fontList {family, style}` lists the axes), and layout, outlines, the substituted-glyph highlight and PDF and SVG export (`font-variation-settings`, embedded fonts) use the font instanced at them. Another font or style clears them; legacy `.ai` export writes the style and warns that they are left out.
The font menu's Font Technology › Variable (under the kind filter, as [Find, apply, and adjust variable fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/find-apply-and-adjust-variable-fonts.html) places Variable in the classification filter's Font Technology section) lists only the families with variation axes, a family with a variable file beside static ones included, and works together with the script, kind, ★ and search filters; it stays set from one opening to the next. Measured by `font_menu::tests::the_variable_filter_lists_only_variable_families`, `font_menu::tests::the_variable_filter_is_named_as_fonts_are`, `tests_axes::a_family_with_variation_axes_is_variable` and `tests_sysfonts::a_family_with_a_variable_file_beside_static_ones_is_variable`.
The font menu's Document filter (beside ★) lists only the families that type in the current document is set in, as the quick filter for fonts used in the document does on the [font browser overview](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/font-options-overview.html). It works together with the search, script, kind, Variable and ★ filters, Recent Fonts and Show Similar Fonts, steers the closed field's wheel, follows edits and undo while the menu is open, and is shared by every font menu for the session like the other filters. VectorCraft's own rules: hidden, locked, masked, symbol, pattern and graph design type counts, styles no type uses do not, a composite font lists under its own name, a family the document names but this computer lacks is not listed (Find Font reports it), a document without available fonts lists nothing with its own message, and with no document open the filter is unavailable. Measured by `font_menu::tests::the_document_filter_lists_the_families_the_documents_type_uses`, `font_menu::tests::the_document_filter_combines_with_the_others_and_follows_edits`, `font_menu::tests::the_document_filter_counts_type_in_graph_designs` and `font_menu::tests::the_document_filter_on_an_empty_document_or_none`.
The font database looks up a name that is neither a loaded nor an installed family among the other names of the loaded and installed fonts once for each style it is asked in, and keeps the answer until fonts are added or rescanned. Laying out a story of 1,000 paragraphs set in a font that is not installed, with 400 more fonts loaded, takes a median of 56 to 71 ms instead of 409 to 507 ms on Windows 11 (`CRAFT_FONTS_DIR=<craft-fonts checkout> cargo test --release -p vectorcraft-text --lib missing_font_story_layout_timing -- --ignored --nocapture`).
A font family removed while the app runs leaves the font menus when the app scans the font folders again (when its window comes to the front after a font folder changed, or Refresh Font List), also when type had used it: that type then draws in the fallback font and Find Font lists the font as missing, until the font is installed again and the folders are scanned.
- **Files (M4):**