Fixed the multi-lang font issue

This commit is contained in:
The Artifex (4r7if3x) 2023-04-19 17:17:22 +02:00
parent 46978cc31e
commit 337bee90ff
No known key found for this signature in database
GPG key ID: F23C261322667A12
33 changed files with 161 additions and 645 deletions

View file

@ -1,567 +0,0 @@
!
"
#
$
%
&
'
(
)
*
+
,
-
.
/
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
[
\
]
^
_
`
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
{
|
}
¡
¿
Ê
Î
Ö
Ü
à
á
â
ã
ä
ç
è
é
ê
ì
í
î
ñ
ó
ô
õ
ö
ù
ú
û
ü
ă
ą
ć
ę
ğ
İ
ı
ł
ń
ś
Ş
ş
ź
ż
Ș
ș
ț
А
В
Г
Д
Е
З
И
К
Л
М
Н
О
П
Р
С
Т
У
Ф
Ч
Ш
Щ
Я
а
б
в
г
д
е
ж
з
и
й
к
л
м
н
о
п
р
с
т
у
ф
х
ц
ч
ш
щ
ъ
ы
ь
э
ю
я
ё
є
і
ї
⏎
❤
一
中
主
义
了
互
些
交
仅
从
他
以
们
任
会
传
但
体
何
使
侧
信
值
入
其
内
出
击
分
到
前
功
动
包
协
占
即
发
可
右
后
吗
含
启
告
哦
喜
器
图
在
地
址
士
夹
如
始
字
它
完
定
家
将
小
尝
层
已
并
应
开
当
待
志
总
您
情
想
成
我
所
打
报
择
指
按
换
据
接
控
收
数
整
文
新
无
日
时
星
是
显
暂
暗
最
有
未
本
条
果
标
梦
概
欢
正
此
每
没
洋
活
流
浅
测
海
清
滤
潜
点
版
率
生
用
的
皆
监
目
知
确
示
秒
空
站
等
简
类
络
网
置
联
自
色
节
藏
要
览
言
计
议
设
试
详
语
误
请
贴
超
输
达
过
近
还
这
连
退
适
选
通
速
配
里
量
错
间
阈
除
隐
需
面
音
页
题
黑
가
감
값
개
검
것
게
겠
겨
결
계
고
과
관
교
국
그
근
기
까
네
넷
눌
는
능
니
다
당
대
댑
데
뎁
도
되
된
될
됩
두
둘
드
들
따
때
라
랑
래
러
레
려
련
로
료
류
륨
른
를
리
림
링
마
만
말
면
모
몽
문
바
받
발
버
별
보
본
볼
부
분
사
삭
새
생
서
석
선
설
성
세
션
셨
소
속
송
수
숨
스
습
시
신
아
않
알
았
애
어
언
없
었
에
여
연
열
였
오
올
요
용
우
운
워
위
유
으
을
음
의
이
인
일
임
있
자
장
재
적
전
정
제
종
주
줄
중
즐
지
직
찰
찾
체
초
총
최
추
케
콜
크
킷
타
태
택
터
테
토
트
패
페
표
프
플
픽
필
하
한
할
합
해
현
화
확
환
활
효
,

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.

View file

@ -4,18 +4,17 @@ use std::collections::VecDeque;
use iced::alignment::{Horizontal, Vertical};
use iced::widget::{Column, Container};
use iced::{Element, Font};
use iced::Element;
use plotters::style::RGBColor;
use plotters_iced::{Chart, ChartBuilder, ChartWidget, DrawingBackend};
use crate::gui::styles::style_constants::{
get_color_mix_chart, CHARTS_LINE_BORDER, SARASA_MONO_SC_BOLD,
};
use crate::gui::styles::fonts;
use crate::gui::styles::style_constants::{get_color_mix_chart, CHARTS_LINE_BORDER};
use crate::gui::styles::types::palette::to_rgb_color;
use crate::gui::types::message::Message;
use crate::translations::translations::{incoming_translation, outgoing_translation};
use crate::utils::formatted_strings::get_formatted_bytes_string;
use crate::{get_colors, ChartType, Language, StyleType};
use crate::{font_selector, get_colors, ChartType, Language, StyleType};
/// Struct defining the chart to be displayed in gui run page
pub struct TrafficChart {
@ -68,12 +67,10 @@ impl TrafficChart {
pub fn view(&self) -> Element<Message> {
let color_font = self.color_font;
let language = self.language;
Container::new(
Column::new().push(
ChartWidget::new(self).resolve_font(move |_, _| match color_font {
RGBColor(255, 255, 255) => Font::Default, // if white non-bold
_ => SARASA_MONO_SC_BOLD,
}),
ChartWidget::new(self).resolve_font(move |_, _| font_selector!(color_font, language)),
),
)
.align_x(Horizontal::Left)

View file

@ -49,7 +49,8 @@ impl Application for Sniffer {
fn view(&self) -> Element<Message> {
let status = *self.status_pair.0.lock().unwrap();
let style = self.style;
let font = get_font(style);
let language = self.language;
let font = get_font(style, language);
let header = match status {
Status::Init => header(style, false, self.language, self.last_opened_setting),

View file

@ -8,6 +8,7 @@ use iced::{Alignment, Font, Length};
use iced_native::widget::horizontal_space;
use iced_native::widget::tooltip::Position;
use crate::gui::styles::fonts;
use crate::gui::styles::style_constants::{get_font, get_font_headers, FONT_SIZE_FOOTER, ICONS};
use crate::gui::styles::types::element_type::ElementType;
use crate::gui::styles::types::style_tuple::StyleTuple;
@ -22,7 +23,7 @@ pub fn footer(
style: StyleType,
newer_release_available: &Arc<Mutex<Result<bool, String>>>,
) -> Container<'static, Message> {
let font_footer = get_font_headers(style);
let font_footer = get_font_headers(style, language);
let release_details_row =
get_release_details(language, style, font_footer, newer_release_available);
@ -32,13 +33,28 @@ pub fn footer(
.padding([0, 20])
.align_items(Alignment::Center)
.push(release_details_row)
.push(get_button_github(style))
.push(get_button_github(style, language))
.push(
Text::new("Made with ❤ by Giuliano Bellini")
Row::new()
.width(Length::FillPortion(1))
.horizontal_alignment(Horizontal::Right)
.size(FONT_SIZE_FOOTER)
.font(font_footer),
.push(
Text::new("Made with ")
.width(Length::FillPortion(1))
.size(FONT_SIZE_FOOTER)
.font(font_footer)
.horizontal_alignment(Horizontal::Right)
)
.push(
Text::new("❤")
.width(Length::Fixed(14.0))
.size(FONT_SIZE_FOOTER + 4.0)
.font(fonts::NOTO_SANS_SYMBOLS)
)
.push(
Text::new(" by Giuliano Bellini")
.size(FONT_SIZE_FOOTER)
.font(font_footer)
)
);
Container::new(footer_row)
@ -51,7 +67,7 @@ pub fn footer(
))
}
fn get_button_github(style: StyleType) -> Tooltip<'static, Message> {
fn get_button_github(style: StyleType, language: Language) -> Tooltip<'static, Message> {
let content = button(
Text::new('H'.to_string())
.font(ICONS)
@ -65,7 +81,7 @@ fn get_button_github(style: StyleType) -> Tooltip<'static, Message> {
.on_press(Message::OpenGithub(true));
Tooltip::new(content, "GitHub", Position::Top)
.font(get_font(style))
.font(get_font(style, language))
.style(<StyleTuple as Into<iced::theme::Container>>::into(
StyleTuple(style, ElementType::Tooltip),
))
@ -106,7 +122,7 @@ fn get_release_details(
new_version_available_translation(language),
Position::Top,
)
.font(get_font(style))
.font(get_font(style, language))
.style(<StyleTuple as Into<iced::theme::Container>>::into(
StyleTuple(style, ElementType::Tooltip),
));

View file

@ -84,7 +84,7 @@ fn get_button_reset(style: StyleType, language: Language) -> Tooltip<'static, Me
quit_analysis_translation(language),
Position::Right,
)
.font(get_font(style))
.font(get_font(style, language))
.style(<StyleTuple as Into<iced::theme::Container>>::into(
StyleTuple(style, ElementType::Tooltip),
))
@ -108,7 +108,7 @@ pub fn get_button_settings(
.on_press(Message::OpenSettings(open_overlay));
Tooltip::new(content, settings_translation(language), Position::Left)
.font(get_font(style))
.font(get_font(style, language))
.style(<StyleTuple as Into<iced::theme::Container>>::into(
StyleTuple(style, ElementType::Tooltip),
))

View file

@ -86,7 +86,7 @@ fn get_modal_header(
language: Language,
title: String,
) -> Container<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let tooltip = hide_translation(language).to_string();
//tooltip.push_str(" [esc]");
Container::new(
@ -94,7 +94,7 @@ fn get_modal_header(
.push(horizontal_space(Length::FillPortion(1)))
.push(
Text::new(title)
.font(get_font_headers(style))
.font(get_font_headers(style, language))
.size(FONT_SIZE_TITLE)
.width(Length::FillPortion(6))
.horizontal_alignment(Horizontal::Center),

View file

@ -2,7 +2,7 @@ use iced::widget::{Column, Radio, Row, Text};
use iced::{Alignment, Font, Length};
use iced_native::widget::horizontal_space;
use crate::gui::styles::style_constants::{FONT_SIZE_SUBTITLE, FONT_SIZE_TITLE};
use crate::gui::styles::style_constants::{FONT_SIZE_SUBTITLE, FONT_SIZE_TITLE, get_font};
use crate::gui::styles::types::element_type::ElementType;
use crate::gui::styles::types::style_tuple::StyleTuple;
use crate::gui::types::message::Message;
@ -82,7 +82,6 @@ pub fn transport_protocol_radios(
pub fn language_radios(
active: Language,
collection: &[Language],
font: Font,
style: StyleType,
) -> Column<'static, Message> {
let mut ret_val = Column::new().spacing(10);
@ -92,13 +91,13 @@ pub fn language_radios(
.align_items(Alignment::Center)
.push(
Radio::new(
format!("{} ({:?})", option.get_radio_label(), option),
format!("{}", option.get_radio_label()),
*option,
Some(active),
Message::LanguageSelection,
)
.spacing(7)
.font(font)
.font(get_font(style, *option))
.size(15)
.style(<StyleTuple as Into<iced::theme::Radio>>::into(StyleTuple(
style,

View file

@ -18,7 +18,7 @@ pub fn get_settings_tabs(
style: StyleType,
language: Language,
) -> Row<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let mut tabs = Row::new()
.width(Length::Fill)
.align_items(Alignment::Center);
@ -31,6 +31,7 @@ pub fn get_settings_tabs(
actions.get(i).unwrap().clone(),
active,
style,
language,
font,
None,
));
@ -47,7 +48,7 @@ pub fn get_pages_tabs(
language: Language,
unread_notifications: usize,
) -> Row<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let mut tabs = Row::new()
.width(Length::Fill)
.align_items(Alignment::Center);
@ -65,6 +66,7 @@ pub fn get_pages_tabs(
actions.get(i).unwrap().clone(),
active,
style,
language,
font,
unread,
));
@ -78,6 +80,7 @@ fn new_tab(
action: Message,
active: bool,
style: StyleType,
language: Language,
font: Font,
unread: Option<usize>,
) -> Button<'static, Message> {
@ -103,7 +106,7 @@ fn new_tab(
if num > 0 {
let notifications_badge = button(
Text::new(num.to_string())
.font(get_font_headers(style))
.font(get_font_headers(style, language))
.size(19)
.horizontal_alignment(alignment::Horizontal::Center)
.vertical_alignment(alignment::Vertical::Center),

View file

@ -25,7 +25,7 @@ use crate::{AppProtocol, Language, StyleType};
/// Computes the body of gui initial page
pub fn initial_page(sniffer: &Sniffer) -> Container<Message> {
let font = get_font(sniffer.style);
let font = get_font(sniffer.style, sniffer.language);
let col_adapter = get_col_adapter(sniffer, font);
@ -129,7 +129,7 @@ fn button_start(style: StyleType, language: Language) -> Tooltip<'static, Messag
//tooltip.push_str(" [⏎]");
Tooltip::new(content, tooltip, Position::Top)
.gap(5)
.font(get_font(style))
.font(get_font(style, language))
.style(<StyleTuple as Into<iced::theme::Container>>::into(
StyleTuple(style, ElementType::Tooltip),
))

View file

@ -10,7 +10,7 @@
//
// /// Computes the body of gui inspect page
// pub fn inspect_page(sniffer: &Sniffer) -> Container<Message> {
// //let font = get_font(sniffer.style);
// //let font = get_font(sniffer.style, sniffer.language);
//
// let body = Column::new()
// .width(Length::Fill)

View file

@ -32,7 +32,7 @@ use crate::{Language, RunningPage, Sniffer, StyleType};
/// Computes the body of gui notifications page
pub fn notifications_page(sniffer: &Sniffer) -> Container<Message> {
let notifications = sniffer.notifications;
let font = get_font(sniffer.style);
let font = get_font(sniffer.style, sniffer.language);
let mut tab_and_body = Column::new()
.align_items(Alignment::Center)
@ -168,7 +168,7 @@ fn packets_notification_log(
language: Language,
style: StyleType,
) -> Container<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let mut threshold_str = threshold_translation(language);
threshold_str.push_str(&logged_notification.threshold.to_string());
threshold_str.push_str(&format!(" {}", per_second_translation(language)));
@ -236,7 +236,7 @@ fn bytes_notification_log(
language: Language,
style: StyleType,
) -> Container<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let mut threshold_str = threshold_translation(language);
threshold_str.push_str(
&(logged_notification.threshold / logged_notification.byte_multiple.get_multiplier())
@ -317,7 +317,7 @@ fn favorite_notification_log(
language: Language,
style: StyleType,
) -> Container<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let traffic_type = logged_notification.connection.1.traffic_type;
let country = logged_notification.connection.1.country;
let src_str = format!("Src: {}", logged_notification.connection.0.address1);
@ -403,7 +403,7 @@ fn get_button_clear_all(style: StyleType, language: Language) -> Tooltip<'static
Tooltip::new(content, clear_all_translation(language), Position::Top)
.gap(5)
.font(get_font(style))
.font(get_font(style, language))
.style(<StyleTuple as Into<iced::theme::Container>>::into(
StyleTuple(style, ElementType::Tooltip),
))

View file

@ -15,7 +15,7 @@ use thousands::Separable;
use crate::gui::components::radio::{chart_radios, report_radios};
use crate::gui::components::tab::get_pages_tabs;
use crate::gui::styles::style_constants::{get_font, ICONS, SARASA_MONO_SC_BOLD};
use crate::gui::styles::style_constants::{get_font, ICONS};
use crate::gui::styles::types::element_type::ElementType;
use crate::gui::styles::types::style_tuple::StyleTuple;
use crate::gui::types::message::Message;
@ -39,7 +39,7 @@ use crate::{AppProtocol, Language, ReportType, RunningPage, StyleType};
/// Computes the body of gui overview page
pub fn overview_page(sniffer: &Sniffer) -> Container<Message> {
let font = get_font(sniffer.style);
let font = get_font(sniffer.style, sniffer.language);
let mut body = Column::new();
let mut tab_and_body = Column::new().height(Length::Fill);
@ -275,7 +275,7 @@ fn lazy_row_report(
num_favorites: usize,
sniffer: &Sniffer,
) -> Row<'static, Message> {
let font = get_font(sniffer.style);
let font = get_font(sniffer.style, sniffer.language);
let row_radio_report =
report_radios(active_radio_report, font, sniffer.style, sniffer.language);
let mut col_report = Column::new()
@ -308,7 +308,7 @@ fn lazy_row_report(
key_val.1.print_gui()
))
.style(iced::theme::Text::Color(entry_color))
.font(SARASA_MONO_SC_BOLD),
.font(get_font(sniffer.style, sniffer.language)),
);
if key_val.1.country.is_empty() {
entry_row = entry_row
@ -316,7 +316,7 @@ fn lazy_row_report(
Text::new("?")
.width(Length::Fixed(FLAGS_WIDTH))
.style(iced::theme::Text::Color(entry_color))
.font(SARASA_MONO_SC_BOLD),
.font(get_font(sniffer.style, sniffer.language)),
)
.push(Text::new(" "));
} else {
@ -376,7 +376,7 @@ fn lazy_row_report(
}
fn lazy_col_packets(observed: u128, filtered: u128, sniffer: &Sniffer) -> Column<'static, Message> {
let font = get_font(sniffer.style);
let font = get_font(sniffer.style, sniffer.language);
let filtered_bytes =
sniffer.runtime_data.tot_sent_bytes + sniffer.runtime_data.tot_received_bytes;
let mut col_packets = Column::new()

View file

@ -15,15 +15,15 @@ use crate::translations::translations::languages_title_translation;
use crate::{Language, Sniffer};
pub fn settings_language_page(sniffer: &Sniffer) -> Container<Message> {
let font = get_font(sniffer.style);
let font = get_font(sniffer.style, sniffer.language);
let language_active = sniffer.language;
let col_language_radio_1 =
language_radios(language_active, &Language::COL1, font, sniffer.style);
language_radios(language_active, &Language::COL1, sniffer.style);
let col_language_radio_2 =
language_radios(language_active, &Language::COL2, font, sniffer.style);
language_radios(language_active, &Language::COL2, sniffer.style);
let col_language_radio_3 =
language_radios(language_active, &Language::COL3, font, sniffer.style);
language_radios(language_active, &Language::COL3, sniffer.style);
let row_language_radio = Row::new()
.spacing(50)
.push(col_language_radio_1)

View file

@ -30,7 +30,7 @@ use crate::translations::translations::{
use crate::{Language, Sniffer, StyleType};
pub fn settings_notifications_page(sniffer: &Sniffer) -> Container<Message> {
let font = get_font(sniffer.style);
let font = get_font(sniffer.style, sniffer.language);
let mut content = Column::new()
.width(Length::Fill)
.push(settings_header(sniffer.style, sniffer.language))
@ -108,7 +108,7 @@ fn get_packets_notify(
language: Language,
style: StyleType,
) -> Column<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let checkbox = Checkbox::new(
packets_threshold_translation(language),
packets_notification.threshold.is_some(),
@ -183,7 +183,7 @@ fn get_bytes_notify(
language: Language,
style: StyleType,
) -> Column<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let checkbox = Checkbox::new(
bytes_threshold_translation(language),
bytes_notification.threshold.is_some(),
@ -258,7 +258,7 @@ fn get_favorite_notify(
language: Language,
style: StyleType,
) -> Column<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let checkbox = Checkbox::new(
favorite_notification_translation(language),
favorite_notification.notify_on_favorite,
@ -316,7 +316,7 @@ fn input_group_packets(
style: StyleType,
language: Language,
) -> Container<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let curr_threshold_str = &packets_notification.threshold.unwrap().to_string();
let input_row = Row::new()
.spacing(10)
@ -360,7 +360,7 @@ fn input_group_bytes(
style: StyleType,
language: Language,
) -> Container<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let mut info_str = per_second_translation(language).to_string();
info_str.push_str(specify_multiples_translation(language));
let mut curr_threshold_str = (bytes_notification.threshold.unwrap()
@ -401,7 +401,7 @@ fn input_group_bytes(
}
fn volume_slider(language: Language, style: StyleType, volume: u8) -> Container<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
Container::new(
Column::new()
.spacing(5)
@ -442,7 +442,7 @@ fn volume_slider(language: Language, style: StyleType, volume: u8) -> Container<
}
pub fn settings_header(style: StyleType, language: Language) -> Container<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let tooltip = hide_translation(language).to_string();
//tooltip.push_str(" [esc]");
Container::new(
@ -450,7 +450,7 @@ pub fn settings_header(style: StyleType, language: Language) -> Container<'stati
.push(horizontal_space(Length::FillPortion(1)))
.push(
Text::new(settings_translation(language))
.font(get_font_headers(style))
.font(get_font_headers(style, language))
.size(FONT_SIZE_TITLE)
.width(Length::FillPortion(6))
.horizontal_alignment(Horizontal::Center),

View file

@ -18,9 +18,10 @@ use crate::translations::translations::{
};
use crate::StyleType::{Day, DeepSea, MonAmour, Night};
use crate::{Sniffer, StyleType};
use crate::translations::types::language::Language;
pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message> {
let font = get_font(sniffer.style);
let font = get_font(sniffer.style, sniffer.language);
let content = Column::new()
.align_items(Alignment::Center)
.width(Length::Fill)
@ -52,6 +53,7 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message> {
Row::new()
.push(get_palette_container(
sniffer.style,
sniffer.language,
YETI_NIGHT,
"Yeti Night".to_string(),
yeti_night_translation(sniffer.language).to_string(),
@ -60,6 +62,7 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message> {
.push(horizontal_space(Length::Fixed(33.0)))
.push(get_palette_container(
sniffer.style,
sniffer.language,
YETI_DAY,
"Yeti Day".to_string(),
yeti_day_translation(sniffer.language).to_string(),
@ -71,6 +74,7 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message> {
Row::new()
.push(get_palette_container(
sniffer.style,
sniffer.language,
DEEP_SEA,
"Deep Sea".to_string(),
deep_sea_translation(sniffer.language).to_string(),
@ -79,6 +83,7 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message> {
.push(horizontal_space(Length::Fixed(33.0)))
.push(get_palette_container(
sniffer.style,
sniffer.language,
MON_AMOUR,
"Mon Amour".to_string(),
mon_amour_translation(sniffer.language).to_string(),
@ -96,12 +101,13 @@ pub fn settings_style_page(sniffer: &Sniffer) -> Container<Message> {
fn get_palette_container(
style: StyleType,
language: Language,
picture: &[u8],
name: String,
description: String,
on_press: StyleType,
) -> Button<'static, Message> {
let font = get_font(style);
let font = get_font(style, language);
let content = Column::new()
.width(Length::Fill)
.align_items(Alignment::Center)

67
src/gui/styles/fonts.rs Normal file
View file

@ -0,0 +1,67 @@
use iced::Font;
pub const NOTO_SANS_SYMBOLS: Font = Font::External {
name: "noto-sans-symbols",
bytes: include_bytes!("../../../resources/fonts/noto-sans-symbols.ttf"),
};
pub const NOTO_SANS_REGULAR: Font = Font::External {
name: "noto-sans-regular",
bytes: include_bytes!("../../../resources/fonts/noto-sans-regular.ttf"),
};
pub const NOTO_SANS_BOLD: Font = Font::External {
name: "noto-sans-bold",
bytes: include_bytes!("../../../resources/fonts/noto-sans-bold.ttf"),
};
pub const NOTO_NASKH_ARABIC_REGULAR: Font = Font::External {
name: "noto-naskh-arabic-regular",
bytes: include_bytes!("../../../resources/fonts/noto-naskh-arabic-regular.ttf"),
};
pub const NOTO_NASKH_ARABIC_BOLD: Font = Font::External {
name: "noto-naskh-arabic-bold",
bytes: include_bytes!("../../../resources/fonts/noto-naskh-arabic-bold.ttf"),
};
pub const NOTO_SANS_KOREAN_REGULAR: Font = Font::External {
name: "noto-sans-korean-regular",
bytes: include_bytes!("../../../resources/fonts/noto-sans-korean-regular.otf"),
};
pub const NOTO_SANS_KOREAN_BOLD: Font = Font::External {
name: "noto-sans-korean-bold",
bytes: include_bytes!("../../../resources/fonts/noto-sans-korean-bold.otf"),
};
pub const NOTO_SANS_CHINESE_REGULAR: Font = Font::External {
name: "noto-sans-chinese-regular",
bytes: include_bytes!("../../../resources/fonts/noto-sans-chinese-regular.otf"),
};
pub const NOTO_SANS_CHINESE_BOLD: Font = Font::External {
name: "noto-sans-chinese-bold",
bytes: include_bytes!("../../../resources/fonts/noto-sans-chinese-bold.otf"),
};
#[macro_export]
macro_rules! font_selector {
($color:expr, $language:expr) => {
match $color {
// if white non-bold
RGBColor(255, 255, 255) => match $language {
Language::FA => fonts::NOTO_NASKH_ARABIC_REGULAR,
Language::KO => fonts::NOTO_SANS_KOREAN_REGULAR,
Language::ZH => fonts::NOTO_SANS_CHINESE_REGULAR,
_ => fonts::NOTO_SANS_REGULAR,
},
_ => match $language {
Language::FA => fonts::NOTO_NASKH_ARABIC_BOLD,
Language::KO => fonts::NOTO_SANS_KOREAN_BOLD,
Language::ZH => fonts::NOTO_SANS_CHINESE_BOLD,
_ => fonts::NOTO_SANS_BOLD,
}
}
};
}

View file

@ -1,3 +1,4 @@
pub mod fonts;
pub mod button;
pub mod checkbox;
pub mod container;

View file

@ -3,8 +3,10 @@
use iced::{Color, Font};
use plotters::style::RGBColor;
use crate::gui::styles::fonts;
use crate::gui::styles::types::palette::{to_rgb_color, Palette};
use crate::{get_colors, StyleType};
use crate::{font_selector, get_colors, StyleType};
use crate::translations::types::language::Language;
// night theme
const PRIMARY_NIGHT: Color = Color {
@ -161,23 +163,14 @@ pub const MON_AMOUR_STYLE: Palette = Palette {
},
};
pub const SARASA_MONO_SC_BOLD: Font = Font::External {
name: "sarasa-mono-sc-bold",
bytes: include_bytes!("../../../resources/fonts/subset/sarasa-mono-sc-bold.subset.ttf"),
};
pub fn get_font(style: StyleType) -> Font {
match to_rgb_color(get_colors(style).text_body) {
RGBColor(255, 255, 255) => Font::Default,
_ => SARASA_MONO_SC_BOLD,
}
pub fn get_font(style: StyleType, language: Language) -> Font {
let color_font = to_rgb_color(get_colors(style).text_body);
font_selector!(color_font, language)
}
pub fn get_font_headers(style: StyleType) -> Font {
match to_rgb_color(get_colors(style).text_headers) {
RGBColor(255, 255, 255) => Font::Default,
_ => SARASA_MONO_SC_BOLD,
}
pub fn get_font_headers(style: StyleType, language: Language) -> Font {
let color_font = to_rgb_color(get_colors(style).text_headers);
font_selector!(color_font, language)
}
pub fn get_color_mix_chart(style: StyleType) -> f64 {
@ -190,7 +183,7 @@ pub fn get_color_mix_chart(style: StyleType) -> f64 {
//font to display icons
pub const ICONS: Font = Font::External {
name: "icons",
bytes: include_bytes!("../../../resources/fonts/subset/icons.ttf"),
bytes: include_bytes!("../../../resources/fonts/icons.ttf"),
};
// palettes pictures
@ -217,4 +210,4 @@ pub const STARRED: Color = Color {
g: 193.0 / 255.0,
b: 39.0 / 255.0,
a: 1.0,
};
};

View file

@ -117,7 +117,7 @@ pub fn main() -> iced::Result {
newer_release_available1,
),
default_font: Some(include_bytes!(
"../resources/fonts/subset/sarasa-mono-sc-regular.subset.ttf"
"../resources/fonts/noto-sans-regular.ttf"
)),
default_text_size: FONT_SIZE_BODY,
text_multithreading: true,