fonts: implement roberto's typography for notedeck
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
91
src/fonts.rs
91
src/fonts.rs
@@ -1,5 +1,23 @@
|
||||
use egui::{FontData, FontDefinitions, FontFamily, FontTweak};
|
||||
use egui::{FontData, FontDefinitions, FontTweak};
|
||||
use std::collections::BTreeMap;
|
||||
use tracing::debug;
|
||||
|
||||
pub enum NamedFontFamily {
|
||||
Medium,
|
||||
}
|
||||
|
||||
impl NamedFontFamily {
|
||||
pub fn as_str(self) -> &'static str {
|
||||
match self {
|
||||
//Self::Bold => "bold",
|
||||
Self::Medium => "medium",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_family(self) -> egui::FontFamily {
|
||||
egui::FontFamily::Name(self.as_str().into())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup_fonts(ctx: &egui::Context) {
|
||||
let mut fonts = FontDefinitions::default();
|
||||
@@ -18,7 +36,7 @@ pub fn setup_fonts(ctx: &egui::Context) {
|
||||
// Put my font first (highest priority):
|
||||
fonts
|
||||
.families
|
||||
.get_mut(&FontFamily::Proportional)
|
||||
.get_mut(&egui::FontFamily::Proportional)
|
||||
.unwrap()
|
||||
.insert(0, our_font);
|
||||
|
||||
@@ -35,6 +53,39 @@ pub fn setup_gossip_fonts(ctx: &egui::Context) {
|
||||
let mut font_data: BTreeMap<String, FontData> = BTreeMap::new();
|
||||
let mut families = BTreeMap::new();
|
||||
|
||||
font_data.insert(
|
||||
"Onest".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../assets/fonts/onest/OnestRegular1602-hint.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"OnestMedium".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../assets/fonts/onest/OnestMedium1602-hint.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSans".to_owned(),
|
||||
FontData::from_static(include_bytes!("../assets/fonts/DejaVuSansSansEmoji.ttf")),
|
||||
);
|
||||
/*
|
||||
font_data.insert(
|
||||
"OnestBold".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../assets/fonts/onest/OnestBold1602-hint.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSansBold".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../assets/fonts/DejaVuSans-Bold-SansEmoji.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSans".to_owned(),
|
||||
FontData::from_static(include_bytes!("../assets/fonts/DejaVuSansSansEmoji.ttf")),
|
||||
@@ -45,11 +96,7 @@ pub fn setup_gossip_fonts(ctx: &egui::Context) {
|
||||
"../assets/fonts/DejaVuSans-Bold-SansEmoji.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"NotoSansCJK".to_owned(),
|
||||
FontData::from_static(include_bytes!("../assets/fonts/NotoSansCJK-Regular.ttc")),
|
||||
);
|
||||
*/
|
||||
|
||||
font_data.insert(
|
||||
"Inconsolata".to_owned(),
|
||||
@@ -63,9 +110,14 @@ pub fn setup_gossip_fonts(ctx: &egui::Context) {
|
||||
),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"NotoSansCJK".to_owned(),
|
||||
FontData::from_static(include_bytes!("../assets/fonts/NotoSansCJK-Regular.ttc")),
|
||||
);
|
||||
|
||||
// Some good looking emojis. Use as first priority:
|
||||
font_data.insert(
|
||||
"NotoEmoji-Regular".to_owned(),
|
||||
"NotoEmoji".to_owned(),
|
||||
FontData::from_static(include_bytes!("../assets/fonts/NotoEmoji-Regular.ttf")).tweak(
|
||||
FontTweak {
|
||||
scale: 1.1, // make them a touch larger
|
||||
@@ -76,23 +128,28 @@ pub fn setup_gossip_fonts(ctx: &egui::Context) {
|
||||
),
|
||||
);
|
||||
|
||||
let mut proportional = vec!["DejaVuSans".to_owned(), "NotoEmoji-Regular".to_owned()];
|
||||
//if cfg!(feature = "lang-cjk") {
|
||||
proportional.push("NotoSansCJK".to_owned());
|
||||
//}
|
||||
let mut proportional = vec![
|
||||
"Onest".to_owned(),
|
||||
"DejaVuSans".to_owned(),
|
||||
"NotoEmoji".to_owned(),
|
||||
"NotoSansCJK".to_owned(),
|
||||
];
|
||||
|
||||
families.insert(FontFamily::Proportional, proportional);
|
||||
families.insert(egui::FontFamily::Proportional, proportional);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Monospace,
|
||||
vec!["Inconsolata".to_owned(), "NotoEmoji-Regular".to_owned()],
|
||||
egui::FontFamily::Monospace,
|
||||
vec!["Inconsolata".to_owned(), "NotoEmoji".to_owned()],
|
||||
);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Name("Bold".into()),
|
||||
vec!["DejaVuSansBold".to_owned()],
|
||||
egui::FontFamily::Name(NamedFontFamily::Medium.as_str().into()),
|
||||
//egui::FontFamily::Name("bold".into()),
|
||||
vec!["OnestMedium".to_owned(), "NotoEmoji".to_owned()],
|
||||
);
|
||||
|
||||
debug!("fonts: {:?}", families);
|
||||
|
||||
let defs = FontDefinitions {
|
||||
font_data,
|
||||
families,
|
||||
|
||||
Reference in New Issue
Block a user