Skip to content

Commit

Permalink
#248: Use Noto Sans font by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mtkennerly committed Aug 1, 2023
1 parent 2ce18b5 commit 6631a81
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 21 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
This means that several translations are now properly supported:
Simplified Chinese, Japanese, Korean, and Thai.

Ludusavi now bundles and uses the Noto Sans font for consistency,
but some languages will still depend on your system fonts.

Unfortunately, there are still technical limitations with Arabic,
so that translation remains experimental via the config file.
* Fixed:
Expand Down
Binary file added assets/NotoSans-Regular.ttf
Binary file not shown.
2 changes: 2 additions & 0 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod button;
mod common;
mod editor;
mod file_tree;
mod font;
mod game_list;
mod icon;
mod modal;
Expand All @@ -28,6 +29,7 @@ pub fn run(flags: Flags) {

settings.window.min_size = Some((800, 600));
settings.exit_on_close_request = false;
settings.default_font = font::TEXT;
settings.window.icon = match image::load_from_memory(include_bytes!("../assets/icon.png")) {
Ok(buffer) => {
let buffer = buffer.to_rgba8();
Expand Down
6 changes: 4 additions & 2 deletions src/gui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,8 +1137,10 @@ impl Application for App {

log::debug!("Config on startup: {config:?}");

let mut commands =
vec![iced::font::load(std::borrow::Cow::Borrowed(crate::gui::icon::ICONS_DATA)).map(|_| Message::Ignore)];
let mut commands = vec![
iced::font::load(std::borrow::Cow::Borrowed(crate::gui::font::TEXT_DATA)).map(|_| Message::Ignore),
iced::font::load(std::borrow::Cow::Borrowed(crate::gui::font::ICONS_DATA)).map(|_| Message::Ignore),
];
if flags.update_manifest {
commands.push(Command::perform(
async move {
Expand Down
17 changes: 17 additions & 0 deletions src/gui/font.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use iced::{font, Font};

pub const TEXT_DATA: &[u8] = include_bytes!("../../assets/NotoSans-Regular.ttf");
pub const TEXT: Font = Font {
family: font::Family::Name("Noto Sans"),
weight: font::Weight::Normal,
stretch: font::Stretch::Normal,
monospaced: false,
};

pub const ICONS_DATA: &[u8] = include_bytes!("../../assets/MaterialIcons-Regular.ttf");
pub const ICONS: Font = Font {
family: font::Family::Name("Material Icons"),
weight: font::Weight::Normal,
stretch: font::Stretch::Normal,
monospaced: false,
};
23 changes: 6 additions & 17 deletions src/gui/icon.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
use iced::{alignment, font, Font};
use iced::alignment;

use crate::gui::widget::{text, Text};

pub const ICONS_DATA: &[u8] = include_bytes!("../../assets/MaterialIcons-Regular.ttf");
// pub const ICONS: Font = Font::External {
// name: "Material Icons",
// bytes: include_bytes!("../../assets/MaterialIcons-Regular.ttf"),
// };
pub const ICONS: Font = Font {
// name: "Material Icons",
// bytes: include_bytes!("../../assets/MaterialIcons-Regular.ttf"),
family: font::Family::Name("Material Icons"),
weight: font::Weight::Normal,
stretch: font::Stretch::Normal,
monospaced: false,
use crate::gui::{
font,
widget::{text, Text},
};

pub enum Icon {
Expand Down Expand Up @@ -87,7 +76,7 @@ impl Icon {

pub fn text(self) -> Text<'static> {
text(self.as_char().to_string())
.font(ICONS)
.font(font::ICONS)
.size(20)
.width(60)
.height(20)
Expand All @@ -98,7 +87,7 @@ impl Icon {

pub fn text_small(self) -> Text<'static> {
text(self.as_char().to_string())
.font(ICONS)
.font(font::ICONS)
.size(15)
.width(15)
.height(15)
Expand Down
2 changes: 1 addition & 1 deletion src/gui/popup_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ pub fn draw<Renderer>(
// content: &Renderer::ARROW_DOWN_ICON.to_string(),
content: &crate::gui::icon::Icon::MoreVert.as_char().to_string(),
// font: Renderer::ICON_FONT,
font: crate::gui::icon::ICONS,
font: crate::gui::font::ICONS,
size: bounds.height * icon_size * 1.5,
bounds: Rectangle {
// x: bounds.x + bounds.width - f32::from(padding.horizontal()),
Expand Down
2 changes: 1 addition & 1 deletion src/gui/shortcuts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ impl TextHistories {
| UndoSubject::CustomGameFile(_, _)
| UndoSubject::BackupFilterIgnoredPath(_)
| UndoSubject::RcloneExecutable => (!path_appears_valid(&current)).then_some(text_input::Icon {
font: crate::gui::icon::ICONS,
font: crate::gui::font::ICONS,
code_point: crate::gui::icon::Icon::Error.as_char(),
size: None,
spacing: 5.0,
Expand Down

0 comments on commit 6631a81

Please sign in to comment.