mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Merge pull request #8812 from devius/fonts-georgian
Fonts: draw Georgian with craft-fonts' Noto Sans Georgian, installed Georgian faces, and on the web
This commit is contained in:
4 files changed
+15
-6
No files matched your search
@@ -78,6 +78,9 @@ pub const LAO_FAMILIES: &[&str] = &["Lao Sangam MN", "Lao MN", "Lao UI", "Noto S
|
||||
/// Myanmar/Burmese-capable families: macOS (Myanmar Sangam MN, Myanmar MN), Windows (Myanmar Text)
|
||||
/// and Linux (Noto).
|
||||
pub const MYANMAR_FAMILIES: &[&str] = &["Myanmar Sangam MN", "Myanmar MN", "Myanmar Text", "Noto Sans Myanmar"];
|
||||
/// Georgian-capable families: craft-fonts and Linux (Noto), Windows (Sylfaen), macOS (".SF Georgian",
|
||||
/// a hidden system face). Georgian in a font without Mkhedruli glyphs falls back to these.
|
||||
pub const GEORGIAN_FAMILIES: &[&str] = &["Noto Sans Georgian", "Noto Serif Georgian", "Sylfaen", ".SF Georgian"];
|
||||
/// Indic-script families for document text. Windows has `Nirmala UI` for all nine scripts (from
|
||||
/// Windows 8); macOS has the Kohinoor and Sangam MN families; Linux has Noto Sans. Indic text in a
|
||||
/// font without these glyphs had no candidate to fall back to and drew .notdef boxes (#218).
|
||||
@@ -121,6 +124,7 @@ pub fn fallback_candidates(order: &[crate::cjk::CjkScript; 4]) -> Vec<&'static s
|
||||
v.extend_from_slice(KHMER_FAMILIES);
|
||||
v.extend_from_slice(LAO_FAMILIES);
|
||||
v.extend_from_slice(MYANMAR_FAMILIES);
|
||||
v.extend_from_slice(GEORGIAN_FAMILIES);
|
||||
for fams in INDIC_FAMILIES {
|
||||
for f in *fams {
|
||||
// Nirmala UI covers all nine scripts and is listed by each; probe it once.
|
||||
|
||||
@@ -106,7 +106,7 @@ impl Script {
|
||||
],
|
||||
Hebrew => &["notosanshebrew", "notoserifhebrew", "segoeui", "arialhb", "sfhebrew", "dejavusans", "arial", "freesans", "culmus"],
|
||||
Armenian => &["notosansarmenian", "notoserifarmenian", "segoeui", "sylfaen", "mshtakan", "dejavusans", "freesans"],
|
||||
Georgian => &["notosansgeorgian", "notoserifgeorgian", "segoeui", "sylfaen", "dejavusans", "freesans"],
|
||||
Georgian => &["notosansgeorgian", "notoserifgeorgian", "segoeui", "sylfaen", "sfgeorgian", "dejavusans", "freesans"],
|
||||
Ethiopic => &["notosansethiopic", "notoserifethiopic", "ebrima", "kefa", "abyssinicasil"],
|
||||
Devanagari => &[
|
||||
"notosansdevanagari",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
//!
|
||||
//! Script fallback: the manifest's `scripts` field says which scripts a font is for. The first
|
||||
//! served family listed for a script the bundled fonts don't cover (Arabic, Hebrew, Devanagari,
|
||||
//! Thai, Khmer, Lao, Burmese, Japanese, Chinese, Korean) is that script's fallback: text in that script asks for it
|
||||
//! Thai, Khmer, Lao, Burmese, Georgian, Japanese, Chinese, Korean) is that script's fallback: text in that script asks for it
|
||||
//! ([`request_for_text`], from layout), the font database puts it in the fallback stack once it
|
||||
//! arrives, and the web shell asks up front for the scripts of the browser's languages
|
||||
//! ([`request_for_languages`]). The manifest's SHA-256 becomes the fetch's Subresource Integrity
|
||||
@@ -98,7 +98,7 @@ pub fn is_relative_path(p: &str) -> bool {
|
||||
|
||||
/// The scripts a served font can be the fallback for: those the bundled fonts (Inter, which covers
|
||||
/// Latin, Greek and Cyrillic) lack, as ISO 15924 codes.
|
||||
const FALLBACK_SCRIPTS: &[&str] = &["Arab", "Hebr", "Deva", "Thai", "Khmr", "Laoo", "Mymr", "Jpan", "Hans", "Hant", "Kore"];
|
||||
const FALLBACK_SCRIPTS: &[&str] = &["Arab", "Hebr", "Deva", "Thai", "Khmr", "Laoo", "Mymr", "Geor", "Jpan", "Hans", "Hant", "Kore"];
|
||||
|
||||
/// The script fallbacks in `fonts`: for each script in [`FALLBACK_SCRIPTS`], the first family in
|
||||
/// manifest order that lists it, as `(script, family)` in order of first appearance.
|
||||
@@ -134,6 +134,7 @@ pub fn script_of(c: char, order: &[crate::cjk::CjkScript; 4]) -> Option<&'static
|
||||
0x1780..=0x17FF | 0x19E0..=0x19FF => "Khmr",
|
||||
0x0E80..=0x0EFF => "Laoo",
|
||||
0x1000..=0x109F | 0xA9E0..=0xA9FF | 0xAA60..=0xAA7F => "Mymr",
|
||||
0x10A0..=0x10FF | 0x1C90..=0x1CBF | 0x2D00..=0x2D2F => "Geor",
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -152,6 +153,7 @@ pub fn language_script(tag: &str) -> Option<&'static str> {
|
||||
"km" => "Khmr",
|
||||
"lo" => "Laoo",
|
||||
"my" => "Mymr",
|
||||
"ka" => "Geor",
|
||||
"ja" => "Jpan",
|
||||
"ko" => "Kore",
|
||||
"zh" if rest.iter().any(|r| matches!(*r, "hant" | "tw" | "hk" | "mo")) => "Hant",
|
||||
@@ -474,6 +476,7 @@ mod tests {
|
||||
('ລ', Some("Laoo")),
|
||||
('မ', Some("Mymr")),
|
||||
('ၡ', Some("Mymr")),
|
||||
('ა', Some("Geor")),
|
||||
('あ', Some("Jpan")),
|
||||
('한', Some("Kore")),
|
||||
] {
|
||||
@@ -496,6 +499,7 @@ mod tests {
|
||||
("km-KH", Some("Khmr")),
|
||||
("lo", Some("Laoo")),
|
||||
("my-MM", Some("Mymr")),
|
||||
("ka-GE", Some("Geor")),
|
||||
("ja-JP", Some("Jpan")),
|
||||
("zh-CN", Some("Hans")),
|
||||
("zh-TW", Some("Hant")),
|
||||
|
||||
@@ -2248,12 +2248,13 @@ fn craft_fonts_cover_japanese_without_system_fonts() {
|
||||
assert!(craft_family_of(&l).is_empty());
|
||||
}
|
||||
|
||||
/// Chinese, Arabic and Thai set in Inter fall back to the craft font for their script when the
|
||||
/// build has one (Noto Sans CJK SC, Noto Sans Arabic and Noto Sans Thai in newer craft-fonts).
|
||||
/// Chinese, Arabic, Thai and Georgian set in Inter fall back to the craft font for their script when
|
||||
/// the build has one (Noto Sans CJK SC, Noto Sans Arabic, Noto Sans Thai and Noto Sans Georgian in
|
||||
/// newer craft-fonts).
|
||||
#[test]
|
||||
fn craft_fonts_cover_their_other_scripts_without_system_fonts() {
|
||||
let mut e = TextEngine::new();
|
||||
for (script, text) in [("Hans", "中文图层"), ("Arab", "مرحبا"), ("Thai", "ภาษาไทย")] {
|
||||
for (script, text) in [("Hans", "中文图层"), ("Arab", "مرحبا"), ("Thai", "ภาษาไทย"), ("Geor", "ქართული შრე")] {
|
||||
if !crate::CRAFT_FONTS.iter().any(|f| f.scripts.contains(&script)) {
|
||||
eprintln!("skipping {script}: built without a craft font for it (set CRAFT_FONTS_DIR to a craft-fonts checkout)");
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user