Compare commits

..
3 changed files with 42 additions and 14 deletions

No files matched your search

-5
View File
@@ -136,11 +136,6 @@ image = (
# RAEA_GOAL_RENDER 0: a render here ends without raea goal check's render moment, which the box that sent it runs
# on the export it gets back (server/offload.ts), beside the project's brief.ts
.env({"WGPU_BACKEND": "vulkan", "NVIDIA_DRIVER_CAPABILITIES": "all", "RAEA_CLIP_CHECK": "0", "RAEA_AUDIO_MUTE": "1", "RAEA_GOAL_RENDER": "0",
# every font family a cut names, fetched from Google Fonts by name the first time and cached (raea-sys-fonts
# google.rs), not only those a composition loadFont()s: a box's cuts name the brand kit's families (Inter,
# Nunito, Roboto Slab), which drew in DejaVu Sans with font-missing on every cut (12-06, Shane: "can't it
# download fonts as needed")
"RAEA_PAGE_GOOGLE_FONTS": "1",
"RAEA_MODELS": "/models/raea", "RAEA_FEED_MODELS": "/models/feed", "RAEA_LIBRARY_MODELS": "/models/library",
# a render's sound pass, for a sound its project's store doesn't have yet: TokenSynth as
# deploy/modal/tokensynth.py installs it, its notes on the GPU (CR25); a model the volume doesn't have fails
-8
View File
@@ -399,11 +399,3 @@ exit 0
}
console.log("ok the box image's SDK overlays are the repo's files")
}
// the farm's renders fetch every font family a cut names from Google Fonts, so a brand kit's family is drawn, not DejaVu
// Sans (12-06)
{
const farm = readFileSync(new URL("../deploy/modal/farm.py", import.meta.url), "utf8")
assert.match(farm, /"RAEA_PAGE_GOOGLE_FONTS": "1"/)
console.log("ok the farm's renders fetch the fonts a cut names")
}
+42 -1
View File
@@ -122,8 +122,36 @@ pub fn load_now(family: &str) -> usize {
faces.len()
}
/// A family's Latin faces from Google Fonts, or none
/// A family's Latin faces from Google Fonts; for a family Google doesn't have, its free stand-in's (`stand_in`); or none
fn fetch(family: &str) -> Vec<(Bytes, f32, bool)> {
let faces = fetch_google(family);
if !faces.is_empty() {
return faces;
}
match stand_in(family) {
Some(s) => {
bevy::log::info!("raea-page: {family:?} isn't on Google Fonts: drawn in {s:?}, its closest free family");
fetch_google(s)
}
None => faces,
}
}
/// The free family a page's font is drawn in where Google Fonts hasn't got it and the machine hasn't either (12-06: box
/// cuts named "Inter Display" and "Helvetica Neue", and drew in DejaVu Sans on the farm): a size of a Google family by
/// its own name, or a licensed face's closest free one on its metrics (Arimo is Arial's and Helvetica's)
pub fn stand_in(family: &str) -> Option<&'static str> {
let f = family.trim().trim_matches(|c| c == '"' || c == '\'').to_ascii_lowercase();
match f.as_str() {
"inter display" | "inter var" | "inter variable" => Some("Inter"),
"helvetica neue" | "helvetica" | "arial" | "helveticaneue" => Some("Arimo"),
"sf pro" | "sf pro display" | "sf pro text" => Some("Inter"),
_ => None,
}
}
/// A family's Latin faces from Google Fonts, or none
fn fetch_google(family: &str) -> Vec<(Bytes, f32, bool)> {
let url = format!("https://fonts.googleapis.com/css?family={}:{WEIGHTS}", family.replace(' ', "+"));
let css = match raea_io_net::cache::read(&url).and_then(|b| String::from_utf8(b).map_err(|e| e.to_string())) {
Ok(css) => css,
@@ -165,3 +193,16 @@ pub fn face_now(family: &str, url: &str) -> usize {
LOADED.lock().unwrap().push(key);
1
}
#[cfg(test)]
mod tests {
use super::stand_in;
#[test]
fn a_family_google_has_not_got_draws_in_its_free_stand_in() {
assert_eq!(stand_in("Inter Display"), Some("Inter"));
assert_eq!(stand_in("\"Helvetica Neue\""), Some("Arimo"));
assert_eq!(stand_in("Arial"), Some("Arimo"));
assert_eq!(stand_in("Roboto Slab"), None);
}
}