mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-30 00:41:42 +00:00
Simplify font handling, get at least some emojis rendering (even if b/w)
This commit is contained in:
parent
1d4e65a963
commit
65306f93f3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
fonts/Inconsolata-Regular.ttf
Normal file
BIN
fonts/Inconsolata-Regular.ttf
Normal file
Binary file not shown.
9
fonts/LICENSES/emoji-icon-font-mit-license.txt
Normal file
9
fonts/LICENSES/emoji-icon-font-mit-license.txt
Normal file
@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014 John Slegers
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
BIN
fonts/NotoEmoji-Regular.ttf
Normal file
BIN
fonts/NotoEmoji-Regular.ttf
Normal file
Binary file not shown.
20
fonts/README.txt
Normal file
20
fonts/README.txt
Normal file
@ -0,0 +1,20 @@
|
||||
Tools to manage these
|
||||
fc-query shows range of font, and other details
|
||||
font-manager to see all the glyphs at all the unicode codepoints
|
||||
pyftsubset to suck a subset of a font out into your own font file
|
||||
|
||||
pyftsubset INPUT.ttf --unicodes=U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116 \
|
||||
--output-file=OUTPUT.woff2
|
||||
--flavor=woff2
|
||||
|
||||
pyftmerge input1.ttf input2.ttf > output.ttf
|
||||
|
||||
|
||||
NotoColorEmoji
|
||||
1F004 - 1F1FC (emojis)
|
||||
|
||||
DejaVuSans (book)
|
||||
0000 - FFFD (lower stuff)
|
||||
|
||||
|
||||
pyftsubset noto/NotoColorEmoji.ttf --unicodes="1F000-1FFFF" --layout-features='*' --symbol-cmap --legacy-cmap --no-notdef-glyph --no-notdef-outline --output-file=EmojiOnly.ttf
|
BIN
fonts/emoji-icon-font.ttf
Normal file
BIN
fonts/emoji-icon-font.ttf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -12,8 +12,7 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
|
||||
ui.add_space(15.0);
|
||||
|
||||
ui.label(
|
||||
RichText::new(&app.about.name)
|
||||
.text_style(TextStyle::Name("Bold".into()))
|
||||
RichText::new(&app.about.name).strong()
|
||||
);
|
||||
|
||||
ui.add_space(15.0);
|
||||
|
@ -3,7 +3,7 @@ use crate::comms::BusMessage;
|
||||
use crate::globals::{Globals, GLOBALS};
|
||||
use crate::ui::widgets::CopyButton;
|
||||
use eframe::egui;
|
||||
use egui::{Align, Color32, Context, Layout, RichText, ScrollArea, TextStyle, Ui, Vec2};
|
||||
use egui::{Align, Color32, Context, Layout, RichText, ScrollArea, Ui, Vec2};
|
||||
use nostr_types::{EventKind, Id};
|
||||
|
||||
pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Frame, ui: &mut Ui) {
|
||||
@ -150,7 +150,7 @@ fn render_post(
|
||||
ui.horizontal(|ui| {
|
||||
if let Some(person) = maybe_person {
|
||||
if let Some(name) = &person.name {
|
||||
ui.label(RichText::new(name).text_style(TextStyle::Name("Bold".into())));
|
||||
ui.label(RichText::new(name).strong());
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ fn render_post(
|
||||
ui.with_layout(Layout::right_to_left(Align::TOP), |ui| {
|
||||
ui.label(
|
||||
RichText::new(crate::date_ago::date_ago(event.created_at))
|
||||
.text_style(TextStyle::Name("Oblique".into()))
|
||||
.italics()
|
||||
.weak(),
|
||||
);
|
||||
|
||||
@ -186,20 +186,17 @@ fn render_post(
|
||||
if *ch == '+' {
|
||||
ui.label(
|
||||
RichText::new(format!("{} {}", ch, count))
|
||||
.text_style(TextStyle::Name("Bold".into()))
|
||||
.strong()
|
||||
.color(Color32::DARK_GREEN),
|
||||
);
|
||||
} else if *ch == '-' {
|
||||
ui.label(
|
||||
RichText::new(format!("{} {}", ch, count))
|
||||
.text_style(TextStyle::Name("Bold".into()))
|
||||
.strong()
|
||||
.color(Color32::DARK_RED),
|
||||
);
|
||||
} else {
|
||||
ui.label(
|
||||
RichText::new(format!("{} {}", ch, count))
|
||||
.text_style(TextStyle::Name("Bold".into())),
|
||||
);
|
||||
ui.label(RichText::new(format!("{} {}", ch, count)).strong());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -2,7 +2,7 @@ use super::{GossipUi, Page};
|
||||
use crate::comms::BusMessage;
|
||||
use crate::globals::GLOBALS;
|
||||
use eframe::egui;
|
||||
use egui::{Context, RichText, ScrollArea, TextEdit, TextStyle, TopBottomPanel, Ui, Vec2};
|
||||
use egui::{Context, RichText, ScrollArea, TextEdit, TopBottomPanel, Ui, Vec2};
|
||||
|
||||
pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Frame, ui: &mut Ui) {
|
||||
TopBottomPanel::top("people_menu").show(ctx, |ui| {
|
||||
@ -123,10 +123,7 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, _frame: &mut eframe::Fra
|
||||
ui.label(RichText::new(GossipUi::hex_pubkey_short(&person.pubkey)).weak());
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(
|
||||
RichText::new(person.name.as_deref().unwrap_or(""))
|
||||
.text_style(TextStyle::Name("Bold".into())),
|
||||
);
|
||||
ui.label(RichText::new(person.name.as_deref().unwrap_or("")).strong());
|
||||
|
||||
ui.add_space(24.0);
|
||||
|
||||
|
260
src/ui/style.rs
260
src/ui/style.rs
@ -1,8 +1,6 @@
|
||||
use eframe::{egui, epaint};
|
||||
use egui::style::{Selection, Visuals, Widgets};
|
||||
use egui::{
|
||||
Color32, FontData, FontDefinitions, FontFamily, FontId, FontTweak, Rounding, Stroke, TextStyle,
|
||||
};
|
||||
use egui::{Color32, FontData, FontDefinitions, FontFamily, FontId, Rounding, Stroke, TextStyle};
|
||||
use epaint::Shadow;
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@ -119,262 +117,66 @@ pub(super) fn text_styles() -> BTreeMap<TextStyle, FontId> {
|
||||
TextStyle::Heading,
|
||||
FontId {
|
||||
size: 16.0,
|
||||
family: FontFamily::Name("BoldOblique".into()),
|
||||
},
|
||||
);
|
||||
|
||||
text_styles.insert(
|
||||
TextStyle::Name("Bold".into()),
|
||||
FontId {
|
||||
size: 14.0,
|
||||
family: FontFamily::Name("Bold".into()),
|
||||
},
|
||||
);
|
||||
|
||||
text_styles.insert(
|
||||
TextStyle::Name("Oblique".into()),
|
||||
FontId {
|
||||
size: 14.0,
|
||||
family: FontFamily::Name("Oblique".into()),
|
||||
},
|
||||
);
|
||||
|
||||
text_styles.insert(
|
||||
TextStyle::Name("MonoBold".into()),
|
||||
FontId {
|
||||
size: 14.0,
|
||||
family: FontFamily::Name("MonoBold".into()),
|
||||
},
|
||||
);
|
||||
|
||||
text_styles.insert(
|
||||
TextStyle::Name("MonoOblique".into()),
|
||||
FontId {
|
||||
size: 14.0,
|
||||
family: FontFamily::Name("MonoOblique".into()),
|
||||
},
|
||||
);
|
||||
|
||||
text_styles.insert(
|
||||
TextStyle::Name("MonoBoldOblique".into()),
|
||||
FontId {
|
||||
size: 14.0,
|
||||
family: FontFamily::Name("MonoBoldOblique".into()),
|
||||
family: FontFamily::Proportional,
|
||||
},
|
||||
);
|
||||
|
||||
text_styles
|
||||
}
|
||||
|
||||
/*
|
||||
* We configure their font families
|
||||
* Proportional
|
||||
* Monospace
|
||||
* We define the following Font Families:
|
||||
* Bold,
|
||||
* Oblique,
|
||||
* BoldOblique
|
||||
* MonoBold,
|
||||
* MonoOblique
|
||||
* MonoBoldOblique
|
||||
*/
|
||||
pub(super) fn font_definitions() -> FontDefinitions {
|
||||
let mut font_data: BTreeMap<String, FontData> = BTreeMap::new();
|
||||
let mut families = BTreeMap::new();
|
||||
|
||||
// Good Looking Emojis
|
||||
font_data.insert(
|
||||
"NotoColorEmoji".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/noto/NotoColorEmoji.ttf")).tweak(
|
||||
"DejaVuSans".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/DejaVuSans.ttf")),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"Inconsolata".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/Inconsolata-Regular.ttf")),
|
||||
);
|
||||
|
||||
// Some good looking emojis. Use as first priority:
|
||||
font_data.insert(
|
||||
"NotoEmoji-Regular".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/NotoEmoji-Regular.ttf")), /*.tweak(
|
||||
FontTweak {
|
||||
scale: 0.81, // make it smaller
|
||||
y_offset_factor: -0.2, // move it up
|
||||
y_offset: 0.0,
|
||||
},
|
||||
),
|
||||
)*/
|
||||
);
|
||||
|
||||
// Proportional Regular
|
||||
|
||||
// Bigger emojis, and more. <http://jslegers.github.io/emoji-icon-font/>:
|
||||
font_data.insert(
|
||||
"DejaVuSansRegular".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/DejaVuSans/DejaVuSans.ttf")),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"NotoSansRegular".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/noto/NotoSans-Regular.ttf")),
|
||||
"emoji-icon-font".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/emoji-icon-font.ttf")), /*.tweak(
|
||||
FontTweak {
|
||||
scale: 0.88, // make it smaller
|
||||
y_offset_factor: 0.07, // move it down slightly
|
||||
y_offset: 0.0,
|
||||
},
|
||||
)*/
|
||||
);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Proportional,
|
||||
vec![
|
||||
"DejaVuSansRegular".to_owned(),
|
||||
"NotoColorEmoji".to_owned(),
|
||||
"NotoSansRegular".to_owned(),
|
||||
"DejaVuSans".to_owned(),
|
||||
"NotoEmoji-Regular".to_owned(),
|
||||
"emoji-icon-font".to_owned(),
|
||||
],
|
||||
);
|
||||
|
||||
// Proportional Bold
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSansBold".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/DejaVuSans/DejaVuSans-Bold.ttf")),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"NotoSansBold".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/noto/NotoSans-Bold.ttf")),
|
||||
);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Name("Bold".into()),
|
||||
vec![
|
||||
"DejaVuSansBold".to_owned(),
|
||||
"NotoColorEmoji".to_owned(),
|
||||
"NotoSansBold".to_owned(),
|
||||
],
|
||||
);
|
||||
|
||||
// Proportional Oblique
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSansOblique".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../../fonts/DejaVuSans/DejaVuSans-Oblique.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"NotoSansOblique".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/noto/NotoSans-Italic.ttf")),
|
||||
);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Name("Oblique".into()),
|
||||
vec![
|
||||
"DejaVuSansOblique".to_owned(),
|
||||
"NotoColorEmoji".to_owned(),
|
||||
"NotoSansOblique".to_owned(),
|
||||
],
|
||||
);
|
||||
|
||||
// Proportional Bold Oblique
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSansBoldOblique".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../../fonts/DejaVuSans/DejaVuSans-BoldOblique.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"NotoSansBoldOblique".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/noto/NotoSans-BoldItalic.ttf")),
|
||||
);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Name("BoldOblique".into()),
|
||||
vec![
|
||||
"DejaVuSansBoldOblique".to_owned(),
|
||||
"NotoColorEmoji".to_owned(),
|
||||
"NotoSansBoldOblique".to_owned(),
|
||||
],
|
||||
);
|
||||
|
||||
// Monospace Regular
|
||||
|
||||
font_data.insert(
|
||||
"InconsolataRegular".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../../fonts/inconsolata/Inconsolata-SemiCondensedLight.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSansMonoRegular".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/DejaVuSans/DejaVuSansMono.ttf")),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"NotoSansMonoRegular".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/noto/NotoSansMono-Regular.ttf")),
|
||||
);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Monospace,
|
||||
vec![
|
||||
"InconsolataRegular".to_owned(),
|
||||
"DejaVuSansMonoRegular".to_owned(),
|
||||
"NotoColorEmoji".to_owned(),
|
||||
"NotoSansMonoRegular".to_owned(),
|
||||
],
|
||||
);
|
||||
|
||||
// Monospace Bold
|
||||
|
||||
font_data.insert(
|
||||
"InconsolataBold".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../../fonts/inconsolata/Inconsolata-SemiCondensedSemiBold.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSansMonoBold".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../../fonts/DejaVuSans/DejaVuSansMono-Bold.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
font_data.insert(
|
||||
"NotoSansMonoBold".to_owned(),
|
||||
FontData::from_static(include_bytes!("../../fonts/noto/NotoSansMono-Bold.ttf")),
|
||||
);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Name("MonoBold".into()),
|
||||
vec![
|
||||
"InconsolataBold".to_owned(),
|
||||
"DejaVuSansMonoBold".to_owned(),
|
||||
"NotoColorEmoji".to_owned(),
|
||||
"NotoSansMonoBold".to_owned(),
|
||||
],
|
||||
);
|
||||
|
||||
// Monospace Oblique
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSansMonoOblique".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../../fonts/DejaVuSans/DejaVuSansMono-Oblique.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Name("MonoOblique".into()),
|
||||
vec![
|
||||
"DejaVuSansMonoOblique".to_owned(),
|
||||
"NotoColorEmoji".to_owned(),
|
||||
"NotoSansMonoRegular".to_owned(), // they don't have an oblique
|
||||
],
|
||||
);
|
||||
|
||||
// Monospace Bold Oblique
|
||||
|
||||
font_data.insert(
|
||||
"DejaVuSansMonoBoldOblique".to_owned(),
|
||||
FontData::from_static(include_bytes!(
|
||||
"../../fonts/DejaVuSans/DejaVuSansMono-BoldOblique.ttf"
|
||||
)),
|
||||
);
|
||||
|
||||
families.insert(
|
||||
FontFamily::Name("MonoBoldOblique".into()),
|
||||
vec![
|
||||
"DejaVuSansMonoBoldOblique".to_owned(),
|
||||
"NotoColorEmoji".to_owned(),
|
||||
"NotoSansMonoBold".to_owned(), // they don't have a bold oblique
|
||||
"Inconsolata".to_owned(),
|
||||
"NotoEmoji-Regular".to_owned(),
|
||||
"emoji-icon-font".to_owned(),
|
||||
],
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user