mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 13:08:32 +00:00
Font menu: a Recently Added filter lists the families installed in the last 30 days, newest first
The font menu's Recently Added chip, on its own row under Font Technology, lists only the installed families with a font file created in the last 30 days, the newest at the top. It combines with the search, script, kind, Variable, star and Document filters, lists the recently used families in the same order without the Recent Fonts section, leaves Show Similar Fonts to order only these families, steers the closed field's wheel, and is shared by every font menu for the session. The font scan keeps each file's creation time, and FontDb::recently_added(now) dates a family by its newest file at or before `now`, the 30th day included. Files without a creation time or dated in the future do not count, and families added at the same instant are in name order. The open menu lists a family no longer once its 30 days end.
This commit is contained in:
@@ -17,6 +17,7 @@ use crate::GlyphImage;
|
||||
use crate::colr::ColourContent;
|
||||
use vectorcraft_doc::color::Color;
|
||||
|
||||
mod added;
|
||||
mod alternates;
|
||||
mod build;
|
||||
mod cache;
|
||||
@@ -33,6 +34,9 @@ mod stylistic_sets;
|
||||
mod traits;
|
||||
mod wanted;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) use added::recently_added_of;
|
||||
pub use added::{RECENTLY_ADDED_WITHIN, RecentlyAdded};
|
||||
pub use alternates::GlyphAlternate;
|
||||
pub(crate) use alternates::listed;
|
||||
pub use build::style_weight;
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
//! Recently added fonts: the installed families with a font file created on this computer in the
|
||||
//! last 30 days ([`FontDb::recently_added`]).
|
||||
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use super::FontDb;
|
||||
|
||||
/// How long a family counts as recently added after its newest font file was created: 30 days.
|
||||
pub const RECENTLY_ADDED_WITHIN: Duration = Duration::from_secs(30 * 24 * 60 * 60);
|
||||
|
||||
/// The installed families added recently ([`FontDb::recently_added`]).
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct RecentlyAdded {
|
||||
/// The families by their catalog names, the one with the newest font file first. Families
|
||||
/// whose newest files were created at the same instant are in name order, case ignored.
|
||||
pub families: Vec<String>,
|
||||
/// The list is the same for every time from the one asked for up to this instant, and is to be
|
||||
/// asked for again from it on: when a listed family's newest file turns
|
||||
/// [`RECENTLY_ADDED_WITHIN`] old, or when a file dated after the time asked for starts to
|
||||
/// count. `None`: the list stays as it is until fonts are installed or removed.
|
||||
pub recheck_at: Option<SystemTime>,
|
||||
}
|
||||
|
||||
impl FontDb {
|
||||
/// The installed families with a font file created within [`RECENTLY_ADDED_WITHIN`] before
|
||||
/// `now`, the boundary included, newest first. A family's date is that of its newest font file
|
||||
/// created at or before `now`. A file without a creation time (the file system keeps none)
|
||||
/// or dated after `now` does not count, so a family with no other file is left out. The
|
||||
/// creation time is when the file was made on this computer: copying a font in or installing
|
||||
/// it makes a new file, while a font kept elsewhere and linked or activated by a font manager
|
||||
/// is dated by the file the link leads to. Fonts loaded from bytes and the bundled fonts are
|
||||
/// never listed. Empty on wasm, which has no installed fonts.
|
||||
pub fn recently_added(&self, now: SystemTime) -> RecentlyAdded {
|
||||
let catalog = self.read_catalog();
|
||||
recently_added_of(catalog.values().map(|c| (c.name.as_str(), c.faces.iter().map(|f| f.created))), now)
|
||||
}
|
||||
}
|
||||
|
||||
/// [`FontDb::recently_added`] of `families`, each a name with the creation times of its faces'
|
||||
/// files (`None`: unknown).
|
||||
pub(crate) fn recently_added_of<'a, T>(families: impl IntoIterator<Item = (&'a str, T)>, now: SystemTime) -> RecentlyAdded
|
||||
where
|
||||
T: IntoIterator<Item = Option<SystemTime>>,
|
||||
{
|
||||
let mut dated: Vec<(SystemTime, &str)> = Vec::new();
|
||||
let mut recheck_at: Option<SystemTime> = None;
|
||||
let mut sooner = |t: SystemTime| recheck_at = Some(recheck_at.map_or(t, |r| r.min(t)));
|
||||
for (name, times) in families {
|
||||
let mut newest: Option<SystemTime> = None;
|
||||
for t in times.into_iter().flatten() {
|
||||
if t > now {
|
||||
sooner(t);
|
||||
} else if newest.is_none_or(|n| t > n) {
|
||||
newest = Some(t);
|
||||
}
|
||||
}
|
||||
let Some(newest) = newest else { continue };
|
||||
match newest.checked_add(RECENTLY_ADDED_WITHIN) {
|
||||
Some(leaves) if leaves < now => {}
|
||||
Some(leaves) => {
|
||||
sooner(leaves);
|
||||
dated.push((newest, name));
|
||||
}
|
||||
None => dated.push((newest, name)),
|
||||
}
|
||||
}
|
||||
dated.sort_by(|a, b| b.0.cmp(&a.0).then_with(|| a.1.to_lowercase().cmp(&b.1.to_lowercase())).then_with(|| a.1.cmp(b.1)));
|
||||
RecentlyAdded { families: dated.into_iter().map(|(_, name)| name.to_string()).collect(), recheck_at }
|
||||
}
|
||||
@@ -24,6 +24,9 @@ pub(super) struct CatalogFace {
|
||||
/// Weight and italic as the style lists them (by its name, or a named instance's axes).
|
||||
pub(super) weight: f32,
|
||||
pub(super) italic: bool,
|
||||
/// When the file was created ([`FontDb::recently_added`]); `None` when the file system keeps
|
||||
/// no creation time.
|
||||
pub(super) created: Option<std::time::SystemTime>,
|
||||
}
|
||||
|
||||
/// The installed fonts by ASCII-lowercased family name (lookups ignore ASCII case, as
|
||||
|
||||
@@ -419,6 +419,8 @@ impl FontDb {
|
||||
if !named && !is_font_file(&p) && !crate::suitcase::is_suitcase(&p) {
|
||||
continue;
|
||||
}
|
||||
// The file's creation time, once for all its faces (a collection holds several).
|
||||
let created = std::fs::metadata(&p).and_then(|m| m.created()).ok();
|
||||
for FaceStyle { family, native_family, style, keys, weight, italic, traits, .. } in file_face_names(&p) {
|
||||
for (k, a) in Alias::of(&family, &style, &keys) {
|
||||
aliases.entry(k).or_default().push(a);
|
||||
@@ -440,7 +442,7 @@ impl FontDb {
|
||||
entry.native = native_family;
|
||||
}
|
||||
let (weight, italic) = (weight.unwrap_or_else(|| style_weight(&style)), italic || style_italic(&style));
|
||||
entry.faces.push(CatalogFace { style, path: p.clone(), weight, italic });
|
||||
entry.faces.push(CatalogFace { style, path: p.clone(), weight, italic, created });
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@ pub use features::{
|
||||
};
|
||||
pub use fontdb::{
|
||||
CompositeCoverage, FALLBACK_FAMILY, FontClass, FontDb, FontFace, FontLikeness, FontMatch, FontTraits, GlyphAlternate, GlyphCategory,
|
||||
GlyphCategoryKind, GlyphOrigin, IcfMargins, JoiningPosition, LentCompositeFonts, PlatformFontFiles, StylisticSet, Substitution, SubstitutionKind,
|
||||
WantedFont, WantedFonts, app_font_dir, is_font_file, is_suitcase, set_app_font_dir, set_platform_font_files, set_user_font_dirs,
|
||||
set_user_font_dirs_confined, style_weight, system_font_dirs, user_font_dirs,
|
||||
GlyphCategoryKind, GlyphOrigin, IcfMargins, JoiningPosition, LentCompositeFonts, PlatformFontFiles, RECENTLY_ADDED_WITHIN, RecentlyAdded,
|
||||
StylisticSet, Substitution, SubstitutionKind, WantedFont, WantedFonts, app_font_dir, is_font_file, is_suitcase, set_app_font_dir,
|
||||
set_platform_font_files, set_user_font_dirs, set_user_font_dirs_confined, style_weight, system_font_dirs, user_font_dirs,
|
||||
};
|
||||
pub use hyphen::{hyphenation_exceptions, set_hyphenation_exceptions};
|
||||
pub use layout::{envelope_ink, layout_inputs, register_envelope_ink};
|
||||
|
||||
@@ -26,6 +26,7 @@ mod kept_layouts;
|
||||
mod kerning_before;
|
||||
mod ligature_carets;
|
||||
mod path_joins;
|
||||
mod recently_added;
|
||||
mod ruby;
|
||||
mod scripts;
|
||||
mod shape_plans;
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
//! Recently added fonts ([`FontDb::recently_added`]): which installed families count, in which
|
||||
//! order, and until when, at a time the tests choose.
|
||||
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use crate::fontdb::recently_added_of;
|
||||
use crate::*;
|
||||
|
||||
const DAY: Duration = Duration::from_secs(24 * 60 * 60);
|
||||
|
||||
/// A fixed instant the tests count from.
|
||||
fn now() -> SystemTime {
|
||||
SystemTime::UNIX_EPOCH + Duration::from_secs(1_800_000_000)
|
||||
}
|
||||
|
||||
/// `days` days (and `secs` seconds) before [`now`].
|
||||
fn ago(days: u32, secs: u64) -> Option<SystemTime> {
|
||||
now().checked_sub(DAY * days + Duration::from_secs(secs))
|
||||
}
|
||||
|
||||
/// [`recently_added_of`] for families with these creation times, at `at`.
|
||||
fn added(families: &[(&str, &[Option<SystemTime>])], at: SystemTime) -> RecentlyAdded {
|
||||
recently_added_of(families.iter().map(|(name, times)| (*name, times.iter().copied())), at)
|
||||
}
|
||||
|
||||
/// A family counts for 30 days after its newest file was created, the 30th day's last instant
|
||||
/// included; the newest comes first.
|
||||
#[test]
|
||||
fn families_added_in_the_last_30_days_are_listed_newest_first() {
|
||||
let families: &[(&str, &[Option<SystemTime>])] =
|
||||
&[("Older", &[ago(29, 0)]), ("Boundary", &[ago(30, 0)]), ("Expired", &[ago(30, 1)]), ("Newest", &[ago(0, 5)]), ("Middle", &[ago(3, 0)])];
|
||||
let list = added(families, now());
|
||||
assert_eq!(list.families, ["Newest", "Middle", "Older", "Boundary"]);
|
||||
assert_eq!(list.recheck_at, Some(now()), "Boundary leaves after this instant");
|
||||
// A day and a second later, the two oldest have left, without the files changing.
|
||||
let later = added(families, now() + DAY + Duration::from_secs(1));
|
||||
assert_eq!(later.families, ["Newest", "Middle"]);
|
||||
assert_eq!(later.recheck_at, ago(3, 0).map(|t| t + RECENTLY_ADDED_WITHIN));
|
||||
}
|
||||
|
||||
/// A family is dated by its newest file at or before the time asked for. Files without a creation
|
||||
/// time, or dated after that time, do not count, and a family with no other file is left out until
|
||||
/// its future-dated file's time comes.
|
||||
#[test]
|
||||
fn a_family_is_dated_by_its_newest_valid_file() {
|
||||
let future = now() + DAY;
|
||||
let families: &[(&str, &[Option<SystemTime>])] = &[
|
||||
("Several", &[ago(40, 0), ago(2, 0), None, Some(future)]),
|
||||
("Unknown", &[None, None]),
|
||||
("Future", &[Some(future)]),
|
||||
("Old", &[ago(31, 0)]),
|
||||
("One", &[ago(1, 0)]),
|
||||
];
|
||||
let list = added(families, now());
|
||||
assert_eq!(list.families, ["One", "Several"]);
|
||||
assert_eq!(list.recheck_at, Some(future), "the future-dated files count from their time on");
|
||||
assert_eq!(added(families, future).families, ["Future", "Several", "One"]);
|
||||
assert!(added(&[("Unknown", &[None])], now()).recheck_at.is_none());
|
||||
}
|
||||
|
||||
/// Families added at the same instant are in name order, case ignored, whatever order the
|
||||
/// catalog gives them in.
|
||||
#[test]
|
||||
fn families_added_at_the_same_instant_are_in_name_order() {
|
||||
let t = ago(1, 0);
|
||||
let families: &[(&str, &[Option<SystemTime>])] = &[("delta", &[t]), ("Bravo", &[t]), ("alpha", &[t]), ("Charlie", &[t])];
|
||||
assert_eq!(added(families, now()).families, ["alpha", "Bravo", "Charlie", "delta"]);
|
||||
let reversed: Vec<_> = families.iter().rev().copied().collect();
|
||||
assert_eq!(added(&reversed, now()).families, ["alpha", "Bravo", "Charlie", "delta"]);
|
||||
}
|
||||
|
||||
/// Nothing installed, or nothing dated: an empty list with nothing to recheck.
|
||||
#[test]
|
||||
fn no_dated_families_list_nothing() {
|
||||
assert_eq!(added(&[], now()), RecentlyAdded::default());
|
||||
assert_eq!(FontDb::with_font_dirs(vec![]).recently_added(now()), RecentlyAdded::default(), "the bundled fonts are not installed fonts");
|
||||
}
|
||||
@@ -298,6 +298,30 @@ fn rescanning_drops_loaded_fonts_removed_since() {
|
||||
assert_eq!(db.outline(&again, glyph).elements(), db.outline(&face, glyph).elements());
|
||||
}
|
||||
|
||||
/// The scan dates each installed family by its font files' creation times: a family installed
|
||||
/// just now is recently added for 30 days, and leaves the list when its files are removed and the
|
||||
/// folders scanned again. Where the file system keeps no creation time, nothing is listed.
|
||||
#[test]
|
||||
fn installed_fonts_are_recently_added_by_their_files_creation_time() {
|
||||
let dir = font_dir("recently-added");
|
||||
let regular = dir.join("Sysfont-Regular.ttf");
|
||||
let created = std::fs::metadata(®ular).and_then(|m| m.created()).ok();
|
||||
let db = FontDb::with_font_dirs(vec![dir.clone()]);
|
||||
let now = std::time::SystemTime::now();
|
||||
let list = db.recently_added(now);
|
||||
let Some(created) = created else {
|
||||
assert_eq!(list, RecentlyAdded::default(), "no creation times: nothing is dated");
|
||||
return;
|
||||
};
|
||||
assert_eq!(list.families, [FAMILY]);
|
||||
assert!(list.recheck_at.is_some_and(|t| t >= created + RECENTLY_ADDED_WITHIN), "{list:?}");
|
||||
assert!(db.recently_added(now + RECENTLY_ADDED_WITHIN + std::time::Duration::from_secs(60)).families.is_empty(), "31 days on");
|
||||
std::fs::remove_file(®ular).unwrap();
|
||||
std::fs::remove_file(dir.join("Sub/Sysfont-Bold.TTF")).unwrap();
|
||||
assert_eq!(db.load_system_fonts(), 0);
|
||||
assert_eq!(db.recently_added(now), RecentlyAdded::default(), "removed fonts leave the list");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_background_scan_serves_the_first_lookup() {
|
||||
let dir = font_dir("background");
|
||||
|
||||
+153
-21
@@ -6,13 +6,15 @@
|
||||
//! 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 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
|
||||
//! ([`document_families`]), and is unavailable while no document is open. The Recently Added
|
||||
//! filter lists only the installed families with a font file created in the last 30 days, the
|
||||
//! newest first and without the Recent Fonts section ([`vectorcraft_text::FontDb::recently_added`]).
|
||||
//! 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
|
||||
//! Technology filter's Variable lists only variable font families. Preferences › Type › Enable
|
||||
//! in-menu font previews and Font Preview Size turn the samples off or size the rows. The menu lays
|
||||
//! out its filters on the same four rows wherever it opens. However narrow its field, it opens at
|
||||
//! out its filters on the same five rows wherever it opens. However narrow its field, it opens at
|
||||
//! least wide enough for those rows and for a family name up to 220 points wide with its sample
|
||||
//! beside it, up to 60% of the window; each sample fills its row's height. Recently used families
|
||||
//! appear first, in the order they were last applied, within the same search and filters as the
|
||||
@@ -124,6 +126,8 @@ pub struct MenuLook<'a> {
|
||||
/// 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 time the Recently Added filter counts back from. `None`: the system clock.
|
||||
pub clock: Option<std::time::SystemTime>,
|
||||
}
|
||||
|
||||
/// The current document as the Document filter reads it.
|
||||
@@ -161,7 +165,7 @@ impl PartialEq for DocumentKey {
|
||||
|
||||
impl Default for MenuLook<'static> {
|
||||
/// Samples on in the theme's colors, English names, medium rows, no favorites, no wheel, no
|
||||
/// document.
|
||||
/// document, the system clock.
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
samples: true,
|
||||
@@ -174,6 +178,7 @@ impl Default for MenuLook<'static> {
|
||||
wheel_owner: None,
|
||||
name: None,
|
||||
document: None,
|
||||
clock: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -199,6 +204,7 @@ impl<'a> MenuLook<'a> {
|
||||
.session
|
||||
.active()
|
||||
.map(|state| MenuDocument { uid: state.uid, doc: state.interaction.as_ref().map_or(&state.doc, |interaction| &interaction.doc) }),
|
||||
clock: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,9 +360,47 @@ 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, the family Show Similar Fonts orders by, and the document version
|
||||
/// 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<DocumentKey>);
|
||||
/// history, font list generation, the family Show Similar Fonts orders by, the document version
|
||||
/// while the Document filter lists its families, and the recently added families while the
|
||||
/// Recently Added filter lists them.
|
||||
type RowsKey = (
|
||||
String,
|
||||
usize,
|
||||
Option<FontClass>,
|
||||
bool,
|
||||
bool,
|
||||
bool,
|
||||
Vec<String>,
|
||||
Vec<String>,
|
||||
Vec<String>,
|
||||
u64,
|
||||
Option<String>,
|
||||
(Option<DocumentKey>, Option<Arc<AddedFonts>>),
|
||||
);
|
||||
|
||||
/// The installed families the Recently Added filter lists: each one's place in the list
|
||||
/// (lowercase name to place, newest first), and the instant from which they are to be found again
|
||||
/// ([`vectorcraft_text::RecentlyAdded::recheck_at`]).
|
||||
#[derive(Debug, Default, PartialEq, Eq)]
|
||||
struct AddedFonts {
|
||||
place: HashMap<String, usize>,
|
||||
recheck_at: Option<std::time::SystemTime>,
|
||||
}
|
||||
|
||||
impl AddedFonts {
|
||||
fn of(list: &vectorcraft_text::RecentlyAdded) -> Self {
|
||||
Self { place: list.families.iter().enumerate().map(|(i, f)| (f.to_lowercase(), i)).collect(), recheck_at: list.recheck_at }
|
||||
}
|
||||
|
||||
/// Orders `families` (the listed ones) newest first.
|
||||
fn order(&self, families: &mut [String]) {
|
||||
families.sort_by_cached_key(|f| self.place.get(&f.to_lowercase()).copied().unwrap_or(usize::MAX));
|
||||
}
|
||||
}
|
||||
|
||||
/// The recently added families a [`MenuState`] found, and the database and font list generation
|
||||
/// they were found in ([`vectorcraft_text::FontDb::id`], [`vectorcraft_text::FontDb::generation`]).
|
||||
type RecentlyAddedFonts = ((u64, u64), Arc<AddedFonts>);
|
||||
|
||||
/// The families a [`MenuState`] found in a document (lowercase), and the document version and font
|
||||
/// list generation they were found for.
|
||||
@@ -377,12 +421,15 @@ struct MenuState {
|
||||
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),
|
||||
/// favorites only and the current document's families only.
|
||||
/// favorites only, the current document's families only and recently added families only.
|
||||
script: usize,
|
||||
class: Option<FontClass>,
|
||||
variable_only: bool,
|
||||
favorites_only: bool,
|
||||
document_only: bool,
|
||||
added_only: bool,
|
||||
/// The recently added families the Recently Added filter last listed.
|
||||
added: Option<RecentlyAddedFonts>,
|
||||
/// 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
|
||||
@@ -422,6 +469,7 @@ struct Filters {
|
||||
variable_only: bool,
|
||||
favorites_only: bool,
|
||||
document_only: bool,
|
||||
added_only: bool,
|
||||
}
|
||||
|
||||
impl Filters {
|
||||
@@ -432,6 +480,7 @@ impl Filters {
|
||||
variable_only: st.variable_only,
|
||||
favorites_only: st.favorites_only,
|
||||
document_only: st.document_only,
|
||||
added_only: st.added_only,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,6 +490,7 @@ impl Filters {
|
||||
st.variable_only = self.variable_only;
|
||||
st.favorites_only = self.favorites_only;
|
||||
st.document_only = self.document_only;
|
||||
st.added_only = self.added_only;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -485,6 +535,41 @@ fn used_families(db: &vectorcraft_text::FontDb, st: &mut MenuState, look: MenuLo
|
||||
Some(families)
|
||||
}
|
||||
|
||||
/// The time the Recently Added filter counts back from: `look`'s clock, else the system clock. On
|
||||
/// wasm, which has no installed fonts to date, the Unix epoch.
|
||||
fn added_clock(look: MenuLook) -> std::time::SystemTime {
|
||||
look.clock.unwrap_or_else(|| {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
std::time::SystemTime::now()
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
std::time::SystemTime::UNIX_EPOCH
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// The families the Recently Added filter lists, when it is on: those `db` dates within
|
||||
/// [`vectorcraft_text::RECENTLY_ADDED_WITHIN`] before `look`'s clock, found again only when the
|
||||
/// font list changed or the clock reached the instant the list may change at.
|
||||
fn added_families(db: &vectorcraft_text::FontDb, st: &mut MenuState, look: MenuLook) -> Option<Arc<AddedFonts>> {
|
||||
if !st.added_only {
|
||||
return None;
|
||||
}
|
||||
let now = added_clock(look);
|
||||
let key = (db.id(), db.generation());
|
||||
if let Some((k, added)) = &st.added
|
||||
&& *k == key
|
||||
&& added.recheck_at.is_none_or(|t| now < t)
|
||||
{
|
||||
return Some(added.clone());
|
||||
}
|
||||
let added = Arc::new(AddedFonts::of(&db.recently_added(now)));
|
||||
st.added = Some((key, added.clone()));
|
||||
Some(added)
|
||||
}
|
||||
|
||||
/// Where the filters every font menu shares are kept ([`Filters`]).
|
||||
fn filters_id() -> egui::Id {
|
||||
egui::Id::unique("font-menu-filters")
|
||||
@@ -592,12 +677,24 @@ pub fn font_menu(
|
||||
out
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
/// Does the menu list family `f` for search `query` (lowercase) under the filters of `st`, among
|
||||
/// `used` (lowercase) while the Document filter lists the document's families, and among `added`
|
||||
/// while the Recently Added filter lists the recently added ones?
|
||||
fn listed(
|
||||
db: &vectorcraft_text::FontDb,
|
||||
f: &str,
|
||||
query: &str,
|
||||
st: &MenuState,
|
||||
look: MenuLook,
|
||||
used: Option<&HashSet<String>>,
|
||||
added: Option<&AddedFonts>,
|
||||
) -> bool {
|
||||
if used.is_some_and(|used| !used.contains(&f.to_lowercase())) {
|
||||
return false;
|
||||
}
|
||||
if added.is_some_and(|added| !added.place.contains_key(&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;
|
||||
@@ -613,12 +710,22 @@ 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.
|
||||
/// the recent families first, then the others, under the menu's filters; with Recently Added, the
|
||||
/// newest first.
|
||||
fn wheel_order(st: &mut MenuState, look: MenuLook) -> Vec<String> {
|
||||
let db = vectorcraft_text::FontDb::global();
|
||||
wheel_order_in(vectorcraft_text::FontDb::global(), st, look)
|
||||
}
|
||||
|
||||
/// [`wheel_order`] of the families in `db`.
|
||||
fn wheel_order_in(db: &vectorcraft_text::FontDb, st: &mut MenuState, look: MenuLook) -> Vec<String> {
|
||||
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![])
|
||||
let added = added_families(db, st, look);
|
||||
let mut families: Vec<_> =
|
||||
db.menu_family_list().iter().filter(|f| listed(db, f, "", st, look, used.as_deref(), added.as_deref())).cloned().collect();
|
||||
if let Some(added) = &added {
|
||||
added.order(&mut families);
|
||||
}
|
||||
grouped_rows(&families, if added.is_some() { &[] } else { look.recent }, &[], |_| vec![])
|
||||
.into_iter()
|
||||
.filter_map(|r| match r {
|
||||
Row::Family(f) => Some(f),
|
||||
@@ -1185,6 +1292,13 @@ fn header<'s>(ui: &mut Ui, db: &'s vectorcraft_text::FontDb, state_id: egui::Id,
|
||||
}
|
||||
let query = widgets::search_field(ui, field, tl!("Search")).to_lowercase();
|
||||
let refilter = filters(ui, st, &t, look.document.is_some());
|
||||
let added = added_families(db, st, look);
|
||||
// On the system clock, the list is drawn again when a family's 30 days end.
|
||||
if let (Some(at), None) = (added.as_ref().and_then(|a| a.recheck_at), look.clock)
|
||||
&& let Ok(wait) = at.duration_since(added_clock(look))
|
||||
{
|
||||
ui.ctx().request_repaint_after(wait);
|
||||
}
|
||||
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.
|
||||
@@ -1203,16 +1317,26 @@ 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.key()),
|
||||
(look.document.filter(|_| st.document_only).map(|d| d.key()), added.clone()),
|
||||
);
|
||||
if st.rows_key.as_ref() != Some(&key) {
|
||||
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();
|
||||
let mut families: Vec<_> =
|
||||
db.menu_family_list().iter().filter(|f| listed(db, f, &query, st, look, used.as_deref(), added.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())));
|
||||
// Recently Added lists every family it finds once, newest first: the recent ones among
|
||||
// them, without the Recent Fonts section.
|
||||
let recent = match &added {
|
||||
Some(added) => {
|
||||
added.order(&mut families);
|
||||
&[]
|
||||
}
|
||||
None => look.recent,
|
||||
};
|
||||
// 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)),
|
||||
None => grouped_rows(&families, look.recent, &st.expanded, |f| db.styles(f)),
|
||||
None => grouped_rows(&families, recent, &st.expanded, |f| db.styles(f)),
|
||||
};
|
||||
// Filter changes (including un-starring a favourite) may remove rows; expanding
|
||||
// another family or a background font scan can insert rows before the highlight.
|
||||
@@ -1276,6 +1400,8 @@ enum Chip {
|
||||
Favorites,
|
||||
/// The families the current document's type uses.
|
||||
Document,
|
||||
/// The families installed in the last 30 days.
|
||||
Added,
|
||||
AnyKind,
|
||||
Class(FontClass),
|
||||
/// The Font Technology label, which filters nothing.
|
||||
@@ -1284,14 +1410,16 @@ enum Chip {
|
||||
}
|
||||
|
||||
/// 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] {
|
||||
/// document's fonts, any kind and the first three kinds; the other kinds; font technology; the
|
||||
/// recently added fonts.
|
||||
fn filter_rows() -> [Vec<Chip>; 5] {
|
||||
let (first, rest) = FontClass::ALL.split_at(3);
|
||||
[
|
||||
(0..SCRIPTS).map(Chip::Script).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],
|
||||
vec![Chip::Added],
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1321,6 +1449,9 @@ fn filters(ui: &mut Ui, st: &mut MenuState, t: &Tokens, document: bool) -> bool
|
||||
resp.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, document, on, tip));
|
||||
resp
|
||||
}
|
||||
Chip::Added => {
|
||||
ui.selectable_label(st.added_only, text(tl!("Recently Added"))).on_hover_text(tl!("Fonts added in the last 30 days"))
|
||||
}
|
||||
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)),
|
||||
@@ -1334,6 +1465,7 @@ fn filters(ui: &mut Ui, st: &mut MenuState, t: &Tokens, document: bool) -> bool
|
||||
Chip::Script(i) => st.script = i,
|
||||
Chip::Favorites => st.favorites_only = !st.favorites_only,
|
||||
Chip::Document => st.document_only = !st.document_only,
|
||||
Chip::Added => st.added_only = !st.added_only,
|
||||
Chip::AnyKind => st.class = None,
|
||||
Chip::Class(c) => st.class = if st.class == Some(c) { None } else { Some(c) },
|
||||
Chip::Technology => continue,
|
||||
|
||||
@@ -1314,3 +1314,122 @@ fn the_document_filter_on_an_empty_document_or_none() {
|
||||
super::Filters::of(&st).apply(&mut other);
|
||||
assert!(other.document_only, "every font menu shares the filter");
|
||||
}
|
||||
|
||||
/// A fixed time the Recently Added tests count from.
|
||||
fn clock() -> std::time::SystemTime {
|
||||
std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs(1_800_000_000)
|
||||
}
|
||||
|
||||
const DAY: std::time::Duration = std::time::Duration::from_secs(24 * 60 * 60);
|
||||
|
||||
/// The Recently Added filter's list of `families` (newest first), as found in `db`, to be found
|
||||
/// again from `recheck_at` on.
|
||||
fn added_in(db: &vectorcraft_text::FontDb, families: &[&str], recheck_at: Option<std::time::SystemTime>) -> Option<super::RecentlyAddedFonts> {
|
||||
let list = vectorcraft_text::RecentlyAdded { families: families.iter().map(|f| f.to_string()).collect(), recheck_at };
|
||||
// The font folders' first scan changes the generation: it runs before the generation is read.
|
||||
db.family_list();
|
||||
Some(((db.id(), db.generation()), std::sync::Arc::new(super::AddedFonts::of(&list))))
|
||||
}
|
||||
|
||||
/// Draws the open menu of the families in `db` twice for `look` under the filters of `st`, with
|
||||
/// `events` in the first pass; returns the shapes of the second.
|
||||
fn settle_menu_of(
|
||||
ctx: &egui::Context,
|
||||
db: &vectorcraft_text::FontDb,
|
||||
st: &mut super::MenuState,
|
||||
look: super::MenuLook,
|
||||
events: Vec<egui::Event>,
|
||||
) -> Vec<egui::epaint::ClippedShape> {
|
||||
let area = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 900.0));
|
||||
let mut shapes = vec![];
|
||||
for events in [events, vec![]] {
|
||||
let mut out = ctx.run_ui(egui::RawInput { events, screen_rect: Some(area), ..Default::default() }, |ui| {
|
||||
let _ = super::list_of(ui, db, egui::Id::unique("recently-added"), st, "Inter", None, look);
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
shapes = out.shapes;
|
||||
}
|
||||
shapes
|
||||
}
|
||||
|
||||
/// The Recently Added filter lists only the families added recently, the newest first and without
|
||||
/// the Recent Fonts section, the recent family among them; it combines with the ★ filter and the
|
||||
/// search, Show Similar Fonts orders what it lists, and the closed field's wheel follows its order.
|
||||
#[test]
|
||||
fn the_recently_added_filter_lists_new_families_newest_first() {
|
||||
// The bundled fonts alone: fonts that tests running alongside add stay out of the rows.
|
||||
let db = vectorcraft_text::FontDb::with_font_dirs(vec![]);
|
||||
let ctx = egui::Context::default();
|
||||
let recent = vec!["Inter".to_string()];
|
||||
let favorites = vec!["Inter".to_string(), "Source Serif 4".to_string()];
|
||||
let look = super::MenuLook { samples: false, recent: &recent, clock: Some(clock()), ..Default::default() };
|
||||
let newest_first = ["Source Serif 4", "JetBrains Mono", "Inter"];
|
||||
let mut st = super::MenuState { added_only: true, added: added_in(&db, &newest_first, None), ..Default::default() };
|
||||
settle_menu_of(&ctx, &db, &mut st, look, vec![]);
|
||||
assert_eq!(listed_families(&st), newest_first, "newest first, the recent family among them");
|
||||
assert!(!st.rows.iter().any(|r| matches!(r, Row::Heading(_))), "no Recent Fonts section: {:?}", st.rows);
|
||||
assert_eq!(super::wheel_order_in(&db, &mut st, look), newest_first, "the wheel steps through the same families");
|
||||
st.favorites_only = true;
|
||||
settle_menu_of(&ctx, &db, &mut st, super::MenuLook { favorites: &favorites, ..look }, vec![]);
|
||||
assert_eq!(listed_families(&st), ["Source Serif 4", "Inter"], "only the favorites among them");
|
||||
st.favorites_only = false;
|
||||
st.similar = Some("Inter".into());
|
||||
settle_menu_of(&ctx, &db, &mut st, look, vec![]);
|
||||
let listed: Vec<String> = newest_first.iter().map(|f| f.to_string()).collect();
|
||||
assert_eq!(listed_families(&st), db.similar_families("Inter", &listed), "Show Similar Fonts orders only these");
|
||||
st.similar = None;
|
||||
settle_menu_of(&ctx, &db, &mut st, look, vec![]);
|
||||
assert_eq!(listed_families(&st), newest_first, "newest first again once it is cleared");
|
||||
settle_menu_of(&ctx, &db, &mut st, look, vec![egui::Event::Text("mono".into())]);
|
||||
assert_eq!(listed_families(&st), ["JetBrains Mono"], "the search narrows the list");
|
||||
}
|
||||
|
||||
/// A family leaves the list when its 30 days end, while the menu is open; with none left the
|
||||
/// filter stays on and the menu says nothing matches. Its chip turns it off, and every font menu
|
||||
/// shares it.
|
||||
#[test]
|
||||
fn the_recently_added_filter_drops_families_as_their_30_days_end() {
|
||||
let db = vectorcraft_text::FontDb::with_font_dirs(vec![]);
|
||||
let ctx = egui::Context::default();
|
||||
crate::theme::install_fonts(&ctx);
|
||||
let look = super::MenuLook { samples: false, clock: Some(clock()), ..Default::default() };
|
||||
let mut st = super::MenuState { added_only: true, added: added_in(&db, &["Inter"], Some(clock() + DAY)), ..Default::default() };
|
||||
settle_menu_of(&ctx, &db, &mut st, look, vec![]);
|
||||
assert_eq!(listed_families(&st), ["Inter"]);
|
||||
let mut other = super::MenuState::default();
|
||||
super::Filters::of(&st).apply(&mut other);
|
||||
assert!(other.added_only, "every font menu shares the filter");
|
||||
let later = super::MenuLook { clock: Some(clock() + DAY), ..look };
|
||||
let shapes = settle_menu_of(&ctx, &db, &mut st, later, vec![]);
|
||||
assert!(st.rows.is_empty(), "{:?}", st.rows);
|
||||
assert!(st.added_only, "the filter stays on");
|
||||
assert!(text_at(&shapes, |t| t == "No matching fonts").is_some(), "the menu says nothing matches");
|
||||
let chip = text_at(&shapes, |t| t == "Recently Added").expect("the Recently Added chip is drawn");
|
||||
let button = |pressed| egui::Event::PointerButton { pos: chip, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
|
||||
settle_menu_of(&ctx, &db, &mut st, later, vec![egui::Event::PointerMoved(chip), button(true)]);
|
||||
settle_menu_of(&ctx, &db, &mut st, later, vec![button(false)]);
|
||||
assert!(!st.added_only, "the chip turns the filter off");
|
||||
assert!(listed_families(&st).len() > 1, "every family: {:?}", st.rows);
|
||||
}
|
||||
|
||||
/// A font file installed just now is recently added by its creation time, and no longer 31 days
|
||||
/// later. Where the file system keeps no creation time, the filter lists nothing.
|
||||
#[test]
|
||||
fn the_recently_added_filter_lists_a_font_installed_just_now() {
|
||||
let dir = std::env::temp_dir().join(format!("vc-font-menu-recently-added-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let file = dir.join("SourceSerif4-Regular.ttf");
|
||||
std::fs::copy(std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets/fonts/SourceSerif4-Regular.ttf"), &file).unwrap();
|
||||
let dated = std::fs::metadata(&file).and_then(|m| m.created()).is_ok();
|
||||
let db = vectorcraft_text::FontDb::with_font_dirs(vec![dir.clone()]);
|
||||
let ctx = egui::Context::default();
|
||||
let now = std::time::SystemTime::now();
|
||||
let mut st = super::MenuState { added_only: true, ..Default::default() };
|
||||
settle_menu_of(&ctx, &db, &mut st, super::MenuLook { samples: false, clock: Some(now), ..Default::default() }, vec![]);
|
||||
let expected: &[&str] = if dated { &["Source Serif 4"] } else { &[] };
|
||||
assert_eq!(listed_families(&st), expected);
|
||||
settle_menu_of(&ctx, &db, &mut st, super::MenuLook { samples: false, clock: Some(now + DAY * 31), ..Default::default() }, vec![]);
|
||||
assert!(st.rows.is_empty(), "31 days later: {:?}", st.rows);
|
||||
std::fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
|
||||
@@ -1292,6 +1292,8 @@ font-technology Variable Променливи
|
||||
Clear Similar Fonts Изчистване на подобните шрифтове
|
||||
Fonts used in this document Шрифтове, използвани в този документ
|
||||
This document uses no available fonts Този документ не използва налични шрифтове
|
||||
Recently Added Наскоро добавени
|
||||
Fonts added in the last 30 days Шрифтове, добавени през последните 30 дни
|
||||
Font Preview Size Размер за преглед на шрифта
|
||||
Font Size Размер на шрифта
|
||||
Variable Font Променлив шрифт
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -3614,6 +3614,8 @@ theme Appearance Izgled
|
||||
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
|
||||
Recently Added Nedavno dodani
|
||||
Fonts added in the last 30 days Fontovi dodani u posljednjih 30 dana
|
||||
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.
|
@@ -1809,6 +1809,8 @@ digits Malayalam Malaiàlam
|
||||
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
|
||||
Recently Added Afegits recentment
|
||||
Fonts added in the last 30 days Tipus de lletra afegits en els darrers 30 dies
|
||||
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.
|
@@ -3717,6 +3717,8 @@ theme Appearance Motiv
|
||||
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
|
||||
Recently Added Nedávno přidané
|
||||
Fonts added in the last 30 days Písma přidaná za posledních 30 dní
|
||||
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.
|
@@ -6114,6 +6114,8 @@ theme Appearance Udseende
|
||||
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
|
||||
Recently Added Nyligt tilføjet
|
||||
Fonts added in the last 30 days Skrifttyper tilføjet inden for de sidste 30 dage
|
||||
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.
|
@@ -1342,6 +1342,8 @@ file-filter Templates Vorlagen
|
||||
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
|
||||
Recently Added Kürzlich hinzugefügt
|
||||
Fonts added in the last 30 days In den letzten 30 Tagen hinzugefügte 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.
|
@@ -1277,6 +1277,8 @@ font-technology Variable Μεταβλητές
|
||||
Clear Similar Fonts Απαλοιφή παρόμοιων γραμματοσειρών
|
||||
Fonts used in this document Γραμματοσειρές που χρησιμοποιούνται σε αυτό το έγγραφο
|
||||
This document uses no available fonts Αυτό το έγγραφο δεν χρησιμοποιεί διαθέσιμες γραμματοσειρές
|
||||
Recently Added Πρόσφατες προσθήκες
|
||||
Fonts added in the last 30 days Γραμματοσειρές που προστέθηκαν τις τελευταίες 30 ημέρες
|
||||
Font Preview Size Μέγεθος προεπισκόπησης γραμματοσειράς
|
||||
Font Size Μέγεθος γραμματοσειράς
|
||||
Variable Font Μεταβλητή γραμματοσειρά
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1357,6 +1357,8 @@ font-technology Variable Variables
|
||||
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
|
||||
Recently Added Añadidas recientemente
|
||||
Fonts added in the last 30 days Fuentes añadidas en los últimos 30 días
|
||||
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.
|
@@ -3655,6 +3655,8 @@ theme Appearance Ulkoasu
|
||||
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
|
||||
Recently Added Äskettäin lisätyt
|
||||
Fonts added in the last 30 days Viimeisten 30 päivän aikana lisätyt fontit
|
||||
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.
|
@@ -1347,6 +1347,8 @@ font-technology Variable Variables
|
||||
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
|
||||
Recently Added Ajoutées récemment
|
||||
Fonts added in the last 30 days Polices ajoutées au cours des 30 derniers jours
|
||||
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.
|
@@ -1462,6 +1462,8 @@
|
||||
Clear Similar Fonts સમાન ફોન્ટ સાફ કરો
|
||||
Fonts used in this document આ દસ્તાવેજમાં વપરાયેલા ફોન્ટ્સ
|
||||
This document uses no available fonts આ દસ્તાવેજ કોઈ ઉપલબ્ધ ફોન્ટ વાપરતો નથી
|
||||
Recently Added તાજેતરમાં ઉમેરેલા
|
||||
Fonts added in the last 30 days છેલ્લા 30 દિવસમાં ઉમેરેલા ફોન્ટ્સ
|
||||
Font Preview Size ફોન્ટ પૂર્વાવલોકન સાઇઝ
|
||||
Font Size ફોન્ટ સાઇઝ
|
||||
Font Style: ફોન્ટ સ્ટાઇલ:
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 72 and column 5.
|
@@ -2009,6 +2009,8 @@ antiAlias Sharp शार्प
|
||||
Clear Similar Fonts समान फ़ॉन्ट साफ़ करें
|
||||
Fonts used in this document इस डॉक्यूमेंट में उपयोग किए गए फ़ॉन्ट
|
||||
This document uses no available fonts यह डॉक्यूमेंट कोई उपलब्ध फ़ॉन्ट उपयोग नहीं करता
|
||||
Recently Added हाल में जोड़े गए
|
||||
Fonts added in the last 30 days पिछले 30 दिनों में जोड़े गए फ़ॉन्ट
|
||||
Font Preview Size फ़ॉन्ट प्रीव्यू साइज़
|
||||
Font Size फ़ॉन्ट साइज़
|
||||
Font Size: फ़ॉन्ट साइज़:
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1682,6 +1682,8 @@ file-filter Templates Sablonok
|
||||
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
|
||||
Recently Added Nemrég hozzáadott
|
||||
Fonts added in the last 30 days Az elmúlt 30 napban hozzáadott betűtípusok
|
||||
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.
|
@@ -3391,6 +3391,8 @@ theme Appearance Tampilan
|
||||
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
|
||||
Recently Added Baru ditambahkan
|
||||
Fonts added in the last 30 days Font yang ditambahkan dalam 30 hari terakhir
|
||||
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 2495 and column 5.
|
@@ -1376,6 +1376,8 @@ file-filter Templates Modelli
|
||||
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
|
||||
Recently Added Aggiunti di recente
|
||||
Fonts added in the last 30 days Font aggiunti negli ultimi 30 giorni
|
||||
Font Preview Size Dimensione anteprima font
|
||||
Font Size Dimensione font
|
||||
Variable Font Font variabile
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1871,6 +1871,8 @@ antiAlias Sharp シャープ
|
||||
Clear Similar Fonts 類似フォントの表示を解除
|
||||
Fonts used in this document このドキュメントで使用されているフォント
|
||||
This document uses no available fonts このドキュメントでは使用可能なフォントが使われていません
|
||||
Recently Added 最近追加
|
||||
Fonts added in the last 30 days 過去 30 日間に追加されたフォント
|
||||
Font Preview Size フォントプレビューのサイズ
|
||||
Font: フォント:
|
||||
Fonts フォント
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -5371,6 +5371,8 @@ theme Appearance იერსახე
|
||||
Clear Similar Fonts მსგავსი შრიფტების გასუფთავება
|
||||
Fonts used in this document ამ დოკუმენტში გამოყენებული შრიფტები
|
||||
This document uses no available fonts ეს დოკუმენტი არ იყენებს ხელმისაწვდომ შრიფტებს
|
||||
Recently Added ახლახან დამატებული
|
||||
Fonts added in the last 30 days ბოლო 30 დღეში დამატებული შრიფტები
|
||||
Fonts in Document დოკუმენტის შრიფტები
|
||||
Refresh Font List შრიფტების სიის განახლება
|
||||
Replace Font შრიფტის ჩანაცვლება
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1861,6 +1861,8 @@ antiAlias Sharp 날카롭게
|
||||
Clear Similar Fonts 유사한 글꼴 지우기
|
||||
Fonts used in this document 이 문서에서 사용된 글꼴
|
||||
This document uses no available fonts 이 문서는 사용 가능한 글꼴을 사용하지 않습니다
|
||||
Recently Added 최근 추가됨
|
||||
Fonts added in the last 30 days 최근 30일 동안 추가된 글꼴
|
||||
Font Preview Size 글꼴 미리 보기 크기
|
||||
Font: 글꼴:
|
||||
Fonts 글꼴
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -4008,6 +4008,8 @@ theme Appearance Vormgeving
|
||||
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
|
||||
Recently Added Recent toegevoegd
|
||||
Fonts added in the last 30 days Lettertypen die in de afgelopen 30 dagen zijn toegevoegd
|
||||
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.
|
@@ -3596,6 +3596,8 @@ theme Appearance Wygląd
|
||||
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
|
||||
Recently Added Ostatnio dodane
|
||||
Fonts added in the last 30 days Czcionki dodane w ciągu ostatnich 30 dni
|
||||
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.
|
@@ -1216,6 +1216,8 @@ antiAlias Sharp Nítido
|
||||
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
|
||||
Recently Added Adicionadas recentemente
|
||||
Fonts added in the last 30 days Fontes adicionadas nos últimos 30 dias
|
||||
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.
|
@@ -1367,6 +1367,8 @@ file-filter Templates Шаблоны
|
||||
Clear Similar Fonts Сбросить похожие шрифты
|
||||
Fonts used in this document Шрифты, используемые в этом документе
|
||||
This document uses no available fonts В этом документе не используются доступные шрифты
|
||||
Recently Added Недавно добавленные
|
||||
Fonts added in the last 30 days Шрифты, добавленные за последние 30 дней
|
||||
Font Preview Size Размер предварительного просмотра шрифта
|
||||
Font Size Размер шрифта
|
||||
Variable Font Вариативный шрифт
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1310,6 +1310,8 @@ font-technology Variable Variabla
|
||||
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
|
||||
Recently Added Nyligen tillagda
|
||||
Fonts added in the last 30 days Typsnitt som lagts till de senaste 30 dagarna
|
||||
Font Preview Size Storlek på typsnittsförhandsgranskning
|
||||
Font Size Teckenstorlek
|
||||
Variable Font Variabelt typsnitt
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1306,6 +1306,8 @@ font-technology Variable Değişken
|
||||
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
|
||||
Recently Added Son eklenenler
|
||||
Fonts added in the last 30 days Son 30 günde eklenen yazı tipleri
|
||||
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.
|
@@ -1370,6 +1370,8 @@ file-filter Templates Шаблони
|
||||
Clear Similar Fonts Скинути схожі шрифти
|
||||
Fonts used in this document Шрифти, використані в цьому документі
|
||||
This document uses no available fonts Цей документ не використовує доступних шрифтів
|
||||
Recently Added Нещодавно додані
|
||||
Fonts added in the last 30 days Шрифти, додані за останні 30 днів
|
||||
Font Preview Size Розмір попереднього перегляду шрифту
|
||||
Font Size Розмір шрифту
|
||||
Variable Font Варіативний шрифт
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1593,6 +1593,8 @@ file-filter Templates Mẫu
|
||||
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
|
||||
Recently Added Mới thêm gần đây
|
||||
Fonts added in the last 30 days Phông được thêm trong 30 ngày qua
|
||||
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.
|
@@ -1305,6 +1305,8 @@ file-filter Templates 模板
|
||||
Clear Similar Fonts 清除相似字体
|
||||
Fonts used in this document 此文档中使用的字体
|
||||
This document uses no available fonts 此文档未使用任何可用字体
|
||||
Recently Added 最近添加
|
||||
Fonts added in the last 30 days 最近 30 天内添加的字体
|
||||
Font Preview Size 字体预览大小
|
||||
Font Size 字号
|
||||
Variable Font 可变字体
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -1340,6 +1340,8 @@ file-filter Templates 範本
|
||||
Clear Similar Fonts 清除相似字體
|
||||
Fonts used in this document 此文件中使用的字體
|
||||
This document uses no available fonts 此文件未使用任何可用字體
|
||||
Recently Added 最近新增
|
||||
Fonts added in the last 30 days 最近 30 天內新增的字體
|
||||
Font Preview Size 字體預覽大小
|
||||
Font Size 字體大小
|
||||
Variable Font 可變字體
|
||||
|
||||
|
Can't render this file because it is too large.
|
@@ -983,18 +983,19 @@ impl Drawn {
|
||||
fn filter_rows(&self) -> Vec<(f32, f32)> {
|
||||
use crate::i18n::{current, t, tr_ctx};
|
||||
let variable = tr_ctx(current(), "font-technology", "Variable");
|
||||
[(t("All Scripts"), t("Thai")), ("★", t("Rounded")), (t("Script / Brush"), t("Decorative")), (t("Font Technology"), variable)]
|
||||
let added = t("Recently Added");
|
||||
[(t("All Scripts"), t("Thai")), ("★", t("Rounded")), (t("Script / Brush"), t("Decorative")), (t("Font Technology"), variable), (added, added)]
|
||||
.map(|(first, last)| (self.text(first).center().y, self.text(last).center().y))
|
||||
.to_vec()
|
||||
}
|
||||
|
||||
/// The filters lie on their four rows, none wrapped.
|
||||
/// The filters lie on their five rows, none wrapped.
|
||||
fn assert_filter_rows(&self) {
|
||||
let rows = self.filter_rows();
|
||||
for (i, (first, last)) in rows.iter().enumerate() {
|
||||
assert!((first - last).abs() < 1.0, "filter row {i} wraps: its first chip at {first}, its last at {last}");
|
||||
}
|
||||
assert!(rows.windows(2).all(|w| w[1].0 > w[0].0 + 4.0), "four rows of filters, in order: {rows:?}");
|
||||
assert!(rows.windows(2).all(|w| w[1].0 > w[0].0 + 4.0), "five rows of filters, in order: {rows:?}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1149,7 +1150,7 @@ fn a_narrow_field_opens_a_menu_wide_enough_for_the_filters_and_names() {
|
||||
}
|
||||
}
|
||||
|
||||
/// In every UI language the filters keep their four rows unwrapped when the window has room for
|
||||
/// In every UI language the filters keep their five rows unwrapped when the window has room for
|
||||
/// them: the longest translated labels set the menu's width.
|
||||
#[test]
|
||||
fn the_filter_rows_stay_whole_in_every_language() {
|
||||
|
||||
@@ -1827,6 +1827,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
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 menu's Recently Added filter (on its own row under Font Technology) lists only the installed families added in the last 30 days, the newest at the top, as the [user guide](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=479) and the [font browser overview](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/font-options-overview.html) describe it (`vectorcraft_text::FontDb::recently_added`). It works together with the search, script, kind, Variable, ★ and Document filters, lists only the families every active filter matches, steers the closed field's wheel, and is shared by every font menu for the session like the other filters. VectorCraft's own rules: a family is dated by the creation time of its newest font file on this computer (a file the file system keeps no creation time for, or one dated in the future, does not count), the 30th day is included, families added at the same instant are in name order, the recently used families appear in that order without the Recent Fonts section, Show Similar Fonts orders only the families the filter lists, a family leaves the list when its 30 days end while the menu is open, an empty list keeps the filter on and says no fonts match, and fonts bundled with the app or loaded from documents are never listed. Measured by `font_menu::tests::the_recently_added_filter_lists_new_families_newest_first`, `font_menu::tests::the_recently_added_filter_drops_families_as_their_30_days_end`, `font_menu::tests::the_recently_added_filter_lists_a_font_installed_just_now`, `tests_recently_added::families_added_in_the_last_30_days_are_listed_newest_first`, `tests_recently_added::a_family_is_dated_by_its_newest_valid_file` and `tests_sysfonts::installed_fonts_are_recently_added_by_their_files_creation_time`.
|
||||
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):**
|
||||
|
||||
Reference in New Issue
Block a user