Link to more fonts
This commit is contained in:
parent
5b526216f1
commit
c4c100920e
1 changed files with 13 additions and 14 deletions
|
|
@ -34,21 +34,11 @@ fn main() {
|
||||||
&[WindowFlag::Resizable]
|
&[WindowFlag::Resizable]
|
||||||
).unwrap();
|
).unwrap();
|
||||||
|
|
||||||
let mut font_system = FontSystem::new();
|
|
||||||
|
|
||||||
font_system.add(
|
|
||||||
Font::new(include_bytes!("../../../res/Fira/FiraSans-Regular.otf"), 0).unwrap()
|
|
||||||
);
|
|
||||||
font_system.add(
|
|
||||||
Font::new(include_bytes!("../../../res/Fira/FiraMono-Regular.otf"), 0).unwrap()
|
|
||||||
);
|
|
||||||
|
|
||||||
let mut font_datas = Vec::new();
|
let mut font_datas = Vec::new();
|
||||||
for (font_path, font_index) in &[
|
for (font_path, font_index) in &[
|
||||||
("/usr/share/fonts/truetype/freefont/FreeSans.ttf", 0),
|
("/usr/share/fonts/truetype/noto/NotoSansArabic-Regular.ttf", 0),
|
||||||
("/usr/share/fonts/truetype/freefont/FreeSerif.ttf", 0),
|
|
||||||
("/usr/share/fonts/truetype/freefont/FreeMono.ttf", 0),
|
|
||||||
("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", 2 /* simplified chinese */),
|
("/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", 2 /* simplified chinese */),
|
||||||
|
("/usr/share/fonts/truetype/noto/NotoColorEmoji.ttf", 0),
|
||||||
] {
|
] {
|
||||||
match fs::read(font_path) {
|
match fs::read(font_path) {
|
||||||
Ok(font_data) => font_datas.push((font_path, font_data, *font_index)),
|
Ok(font_data) => font_datas.push((font_path, font_data, *font_index)),
|
||||||
|
|
@ -58,6 +48,15 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut font_system = FontSystem::new();
|
||||||
|
|
||||||
|
font_system.add(
|
||||||
|
Font::new(include_bytes!("../../../res/Fira/FiraSans-Regular.otf"), 0).unwrap()
|
||||||
|
);
|
||||||
|
font_system.add(
|
||||||
|
Font::new(include_bytes!("../../../res/Fira/FiraMono-Regular.otf"), 0).unwrap()
|
||||||
|
);
|
||||||
|
|
||||||
for (font_path, font_data, font_index) in &font_datas {
|
for (font_path, font_data, font_index) in &font_datas {
|
||||||
match Font::new(font_data, *font_index) {
|
match Font::new(font_data, *font_index) {
|
||||||
Some(font) => font_system.add(font),
|
Some(font) => font_system.add(font),
|
||||||
|
|
@ -68,9 +67,9 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "mono")]
|
#[cfg(feature = "mono")]
|
||||||
let font_pattern = &["Mono"];
|
let font_pattern = &["Mono", "Emoji"];
|
||||||
#[cfg(not(feature = "mono"))]
|
#[cfg(not(feature = "mono"))]
|
||||||
let font_pattern = &["Sans", "Serif"];
|
let font_pattern = &["Sans", "Serif", "Emoji"];
|
||||||
|
|
||||||
let font_matches = font_system.matches(font_pattern).unwrap();
|
let font_matches = font_system.matches(font_pattern).unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue