mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-08 03:23:11 +00:00
Fonts: the word "serif" outranks every sans indicator
My own previous commit introduced this: moving the bare "serif" needle after the sans list to let "Microsoft Sans Serif" read as sans also let "gothic" win in "Sweet Gothic Serif", a real serif family, which review caught. The rule is narrower than either ordering. A name holding "serif" is serif, and that outranks the sans indicators; the only exception is the phrase it ends: "sans serif" and "sans-serif" are the name of a sans face. So the phrase is removed before the word is looked for, which keeps both spellings sans and gives every explicitly serif name back. Korean serif names stay ahead of all of it, so "Noto Sans Myungjo" and "Myungjo Gothic" are unchanged.
This commit is contained in:
1 parent
8444abfbca
commit
0d16a04038
2 files changed
+11
-5
No files matched your search
@@ -123,6 +123,12 @@ pub fn sans_by_name(family: &str) -> Option<bool> {
|
||||
if has(&["batang", "myungjo", "myeongjo", "gungsuh", "\u{BC14}\u{D5D5}", "\u{BA85}\u{C870}", "\u{AD81}\u{C11C}"]) {
|
||||
return Some(false);
|
||||
}
|
||||
// Then the word itself, which outranks every sans indicator: "Sweet Gothic Serif" is a serif
|
||||
// family whatever "Gothic" suggests. "Sans serif" and "sans-serif" end with the word and do
|
||||
// not mean it, so the phrase goes before the word is looked for (both noted in review).
|
||||
if lower.replace("sans-serif", "sans").replace("sans serif", "sans").contains("serif") {
|
||||
return Some(false);
|
||||
}
|
||||
if has(&[
|
||||
"dotum",
|
||||
"gothic",
|
||||
@@ -138,11 +144,6 @@ pub fn sans_by_name(family: &str) -> Option<bool> {
|
||||
]) {
|
||||
return Some(true);
|
||||
}
|
||||
// Only now the bare word, which "sans serif" and "sans-serif" end with and do not mean
|
||||
// (noted in review): "Microsoft Sans Serif" is a sans face, and so is the CSS generic.
|
||||
if lower.contains("serif") {
|
||||
return Some(false);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
@@ -191,6 +191,11 @@ fn a_sans_serif_name_is_not_read_as_serif() {
|
||||
// And a Korean serif name still outranks "Sans", which is why it is tested first of all.
|
||||
assert_eq!(sans_by_name("Noto Sans Myungjo"), Some(false));
|
||||
assert_eq!(sans_by_name("Myungjo Gothic"), Some(false));
|
||||
// And the word outranks every sans indicator: Sweet Gothic Serif is a serif family
|
||||
// whatever "Gothic" suggests (noted in review).
|
||||
for serif in ["Sweet Gothic Serif", "Gothic Serif", "Sans Forgetica Serif"] {
|
||||
assert_eq!(sans_by_name(serif), Some(false), "{serif} names itself serif");
|
||||
}
|
||||
// Neither word present, so the caller still decides.
|
||||
assert_eq!(sans_by_name("monospace"), None);
|
||||
assert_eq!(sans_by_name("system-ui"), None);
|
||||
|
||||
Reference in new issue
Block a user