formatting

macos-click-through
keith 5 years ago
parent e8263f1f19
commit e9715535f8

@ -176,7 +176,10 @@ pub fn build_collection_by_font_name(
stretch: Stretch::NORMAL, stretch: Stretch::NORMAL,
}; };
let gui_fonts = fallback_list.iter().map(|fallback_item| fallback_item.as_ref()).chain(iter::once(SYSTEM_DEFAULT_FONT)); let gui_fonts = fallback_list
.iter()
.map(|fallback_item| fallback_item.as_ref())
.chain(iter::once(SYSTEM_DEFAULT_FONT));
for font_name in gui_fonts { for font_name in gui_fonts {
if let Some(family) = loader.get_or_load(font_name, false) { if let Some(family) = loader.get_or_load(font_name, false) {
@ -248,7 +251,6 @@ impl CachingShaper {
let mut loader = FontLoader::new(); let mut loader = FontLoader::new();
let font_set = FontSet::new(&options.fallback_list, &mut loader); let font_set = FontSet::new(&options.fallback_list, &mut loader);
CachingShaper { CachingShaper {
options, options,
font_set, font_set,

@ -2,41 +2,40 @@
pub struct FontOptions { pub struct FontOptions {
previous_guifont_setting: Option<String>, previous_guifont_setting: Option<String>,
pub fallback_list: Vec<String>, pub fallback_list: Vec<String>,
pub size: f32 pub size: f32,
} }
impl FontOptions { impl FontOptions {
pub fn new(name: String, size: f32) -> FontOptions { pub fn new(name: String, size: f32) -> FontOptions {
FontOptions { FontOptions {
previous_guifont_setting: None, previous_guifont_setting: None,
fallback_list: vec!(name), fallback_list: vec![name],
size size,
} }
} }
pub fn update(self: &mut FontOptions, guifont_setting: &str) -> bool { pub fn update(self: &mut FontOptions, guifont_setting: &str) -> bool {
if self.previous_guifont_setting.is_some() && if self.previous_guifont_setting.is_some()
guifont_setting == self.previous_guifont_setting.as_ref().unwrap() { && guifont_setting == self.previous_guifont_setting.as_ref().unwrap()
{
return false; return false;
} }
self.previous_guifont_setting = Some(guifont_setting.to_string()); self.previous_guifont_setting = Some(guifont_setting.to_string());
let mut parts = guifont_setting let mut parts = guifont_setting.split(':').filter(|part| !part.is_empty());
.split(':')
.filter(|part| !part.is_empty());
let mut updated = false; let mut updated = false;
if let Some(parts) = parts.next() { if let Some(parts) = parts.next() {
let parsed_fallback_list: Vec<String> = parts let parsed_fallback_list: Vec<String> = parts
.split(',') .split(',')
.filter(|fallback| !fallback.is_empty()) .filter(|fallback| !fallback.is_empty())
.map(|fallback| fallback.to_string()) .map(|fallback| fallback.to_string())
.collect(); .collect();
if parsed_fallback_list.len() > 0 && self.fallback_list != parsed_fallback_list { if parsed_fallback_list.len() > 0 && self.fallback_list != parsed_fallback_list {
self.fallback_list = parsed_fallback_list; self.fallback_list = parsed_fallback_list;
updated = true; updated = true;
} }
} }
for part in parts { for part in parts {

@ -6,11 +6,11 @@ use skulpin::skia_safe::{colors, dash_path_effect, Budgeted, Canvas, Paint, Rect
use skulpin::CoordinateSystemHelper; use skulpin::CoordinateSystemHelper;
mod caching_shaper; mod caching_shaper;
pub mod font_options;
pub mod cursor_renderer; pub mod cursor_renderer;
pub mod font_options;
pub use font_options::*;
pub use caching_shaper::CachingShaper; pub use caching_shaper::CachingShaper;
pub use font_options::*;
use crate::editor::{Style, EDITOR}; use crate::editor::{Style, EDITOR};
use cursor_renderer::CursorRenderer; use cursor_renderer::CursorRenderer;
@ -163,7 +163,7 @@ impl Renderer {
editor.build_draw_commands(), editor.build_draw_commands(),
editor.default_style.clone(), editor.default_style.clone(),
editor.cursor.clone(), editor.cursor.clone(),
editor.guifont.clone() editor.guifont.clone(),
) )
}; };

Loading…
Cancel
Save