i18n: bundle Japanese font fallback and translate vertical controls

This commit is contained in:
midasdf authored and Brandon Thomas committed 2026-10-05 17:32:47 -04:00
1 parent 1adcf69521
commit 3ef82f850c
9 files changed
+161

No files matched your search

+2
View File
@@ -27,6 +27,8 @@ Generated-in-code art is original and has no file to list: the UI icon set (`cra
| `assets/fonts/SourceSerif4-It.ttf` | Frank Grießhammer / Adobe (released as open source) | https://github.com/adobe-fonts/source-serif | OFL-1.1 (`assets/fonts/OFL-SourceSerif4.txt`) | Open-source typeface |
| `assets/fonts/SourceSerif4-Regular.ttf` | Frank Grießhammer / Adobe (released as open source) | https://github.com/adobe-fonts/source-serif | OFL-1.1 (`assets/fonts/OFL-SourceSerif4.txt`) | Open-source typeface |
| `assets/fonts/SourceSerif4-Semibold.ttf` | Frank Grießhammer / Adobe (released as open source) | https://github.com/adobe-fonts/source-serif | OFL-1.1 (`assets/fonts/OFL-SourceSerif4.txt`) | Open-source typeface |
| `assets/fonts/ShipporiMincho-Regular.ttf` | The Shippori Mincho Project Authors (FONTDASU) | https://github.com/google/fonts/tree/9710da1eacb3be272583c3224dcb70f9da6eadbb/ofl/shipporimincho | OFL-1.1 (`assets/fonts/OFL-ShipporiMincho.txt`) | Japanese UI and document fallback; SHA-256 `769b5269f0f9bc6534b352c0e6bd856a566e03ff788f107191c2d835863570b2` |
| `assets/fonts/OFL-ShipporiMincho.txt` | The Shippori Mincho Project Authors (FONTDASU) | https://github.com/google/fonts/blob/9710da1eacb3be272583c3224dcb70f9da6eadbb/ofl/shipporimincho/OFL.txt | OFL-1.1 | Licence for Shippori Mincho |
| `docs/images/page-2.png` | DesignCraft contributors | screenshot/render of DesignCraft itself (sample document generated in code) | MIT OR Apache-2.0 | Original; no Adobe UI |
| `docs/images/page-3.png` | DesignCraft contributors | screenshot/render of DesignCraft itself (sample document generated in code) | MIT OR Apache-2.0 | Original; no Adobe UI |
| `docs/images/page-4.png` | DesignCraft contributors | screenshot/render of DesignCraft itself (sample document generated in code) | MIT OR Apache-2.0 | Original; no Adobe UI |
+4
View File
@@ -24,3 +24,7 @@ Rust dependencies (vello_cpu, kurbo, skrifa, harfrust, image, egui, eframe, …)
licensed (MIT/Apache-2.0/BSD/ISC/Zlib) and fetched through crates.io.
No Adobe icons, images or artwork are included.
Shippori Mincho: Copyright 2021 The Shippori Mincho Project Authors
(https://github.com/fontdasu/ShipporiMincho). SIL Open Font License 1.1;
see assets/fonts/OFL-ShipporiMincho.txt.
+2
View File
@@ -211,3 +211,5 @@ same references), and from the app's JSON control channel. See [docs/agents.md](
| M12 | Interactive & digital (EPUB, HTML, interactive PDF) | started (EPUB, PDF links/bookmarks) |
| M13 | Automation (scripts, batch) | |
| M14 | 1.0 polish & packaging | |
- Japanese UI/document fallback: bundled OFL Shippori Mincho supplies Japanese glyphs on native and web without OS fonts. Story Direction, Horizontal/Vertical, Tate-Chu-Yoko, Ruby and Kenten menu labels are translated in all four non-English interface languages. Vertical metrics and warichu remain open.
+93
View File
@@ -0,0 +1,93 @@
Copyright 2021 The Shippori Mincho Project Authors (https://github.com/fontdasu/ShipporiMincho)
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file not shown.
+1
View File
@@ -33,6 +33,7 @@ static BUNDLED: &[&[u8]] = &[
include_bytes!("../../../assets/fonts/Inter-Medium.ttf"),
include_bytes!("../../../assets/fonts/Inter-SemiBold.ttf"),
include_bytes!("../../../assets/fonts/JetBrainsMono-Regular.ttf"),
include_bytes!("../../../assets/fonts/ShipporiMincho-Regular.ttf"),
];
#[derive(Clone)]
+16
View File
@@ -247,4 +247,20 @@ mod tests {
assert!(face.ascent > 0.0 && face.descent > 0.0 && face.cap_height > face.x_height);
assert!(feature("abc").is_none());
}
#[test]
fn japanese_fallback_is_bundled_and_has_vertical_forms() {
// Inspect the bundled face directly so this test cannot pass through an OS fallback.
let data = include_bytes!("../../../assets/fonts/ShipporiMincho-Regular.ttf");
let font = skrifa::FontRef::new(data).unwrap();
for ch in "日本語縦書き横書きルビ、。「」".chars() {
assert_ne!(font.charmap().map(ch).unwrap_or_default(), skrifa::GlyphId::NOTDEF);
}
let face = FontDb::global().face("Shippori Mincho", "Regular");
assert_eq!(face.family, "Shippori Mincho");
let horizontal = shape(&face, "「」、。", &[], |c| c);
let vertical = shape(&face, "「」、。", &[feature("vert").unwrap(), feature("vrt2").unwrap()], |c| c);
assert_eq!(horizontal.len(), vertical.len());
assert!(horizontal.iter().zip(&vertical).any(|(h, v)| h.gid != v.gid));
}
}
+20
View File
@@ -59,6 +59,12 @@ const TABLE: &[(&str, [&str; 4])] = &[
],
),
// Type.
("Story Direction", ["Textrichtung", "Sens du texte", "Dirección del texto", "組み方向"]),
("Horizontal", ["Horizontal", "Horizontal", "Horizontal", "横書き"]),
("Vertical", ["Vertikal", "Vertical", "Vertical", "縦書き"]),
("Tate-Chu-Yoko", ["Tate-Chu-Yoko", "Tate-Chu-Yoko", "Tate-Chu-Yoko", "縦中横"]),
("Ruby…", ["Ruby …", "Ruby…", "Ruby…", "ルビ…"]),
("Kenten", ["Kenten", "Kenten", "Kenten", "圏点"]),
("Font", ["Schriftart", "Police", "Fuente", "フォント"]),
("Size", ["Schriftgrad", "Corps", "Tamaño", "サイズ"]),
("Character", ["Zeichen", "Caractère", "Carácter", "文字"]),
@@ -161,4 +167,18 @@ mod tests {
assert!(t.iter().all(|x| !x.is_empty()), "{en}");
}
}
#[test]
fn japanese_vertical_type_commands_are_translated() {
for (en, ja) in [
("Story Direction", "組み方向"),
("Horizontal", "横書き"),
("Vertical", "縦書き"),
("Tate-Chu-Yoko", "縦中横"),
("Ruby…", "ルビ…"),
("Kenten", "圏点"),
] {
assert_eq!(tr("ja", en), ja);
}
}
}
+23
View File
@@ -253,9 +253,13 @@ pub fn install_fonts(ctx: &egui::Context) {
add(&mut fonts, "ui", include_bytes!("../../../assets/fonts/SourceSans3-Regular.ttf"));
add(&mut fonts, "ui-semibold", include_bytes!("../../../assets/fonts/SourceSans3-Semibold.ttf"));
add(&mut fonts, "mono", include_bytes!("../../../assets/fonts/JetBrainsMono-Regular.ttf"));
add(&mut fonts, "japanese", include_bytes!("../../../assets/fonts/ShipporiMincho-Regular.ttf"));
fonts.families.entry(FontFamily::Proportional).or_default().insert(0, "ui".into());
fonts.families.entry(FontFamily::Monospace).or_default().insert(0, "mono".into());
fonts.families.insert(FontFamily::Name("semibold".into()), vec!["ui-semibold".into(), "ui".into()]);
for stack in fonts.families.values_mut() {
stack.push("japanese".into());
}
ctx.set_fonts(fonts);
}
@@ -323,3 +327,22 @@ impl Tokens {
ctx.data(|d| d.get_temp::<Tokens>(egui::Id::NULL)).unwrap_or_else(|| Tokens::for_brightness(Brightness::Dark))
}
}
#[cfg(test)]
mod japanese_font_tests {
#[test]
fn japanese_ui_glyphs_are_available_in_every_family() {
let ctx = egui::Context::default();
super::install_fonts(&ctx);
let mut output = ctx.run_ui(egui::RawInput::default(), |_| {});
output.textures_delta.clear();
ctx.fonts_mut(|fonts| {
for family in [egui::FontFamily::Proportional, egui::FontFamily::Monospace, egui::FontFamily::Name("semibold".into())] {
let font = egui::FontId::new(13.0, family);
for ch in "日本語縦書き横書き組み方向ルビ圏点".chars() {
assert!(fonts.has_glyph(&font, ch), "missing {ch} in {font:?}");
}
}
});
}
}