Bundle and use Inconsolata v2.012

There's a newer version of the font available but ligatures seem
broken googlefonts/Inconsolata#58 and googlefonts/Inconsolata#52.

As part of this commit I also upgraded rust-embed to use the new
exclusion feature, which allows us to skip embedding OS files like
`.DS_Store`.
This commit is contained in:
Antonio Scandurra
2021-09-04 17:02:20 +02:00
parent 0e4f77750a
commit 00f6bdcb24
16 changed files with 65 additions and 26 deletions
+4 -1
View File
@@ -4,11 +4,14 @@ use rust_embed::RustEmbed;
#[derive(RustEmbed)]
#[folder = "assets"]
#[exclude = "*.DS_Store"]
pub struct Assets;
impl AssetSource for Assets {
fn load(&self, path: &str) -> Result<std::borrow::Cow<[u8]>> {
Self::get(path).ok_or_else(|| anyhow!("could not find asset at path \"{}\"", path))
Self::get(path)
.map(|f| f.data)
.ok_or_else(|| anyhow!("could not find asset at path \"{}\"", path))
}
fn list(&self, path: &str) -> Vec<std::borrow::Cow<'static, str>> {
+3 -2
View File
@@ -47,7 +47,8 @@ impl Language {
impl LanguageRegistry {
pub fn new() -> Self {
let grammar = tree_sitter_rust::language();
let rust_config = toml::from_slice(&LanguageDir::get("rust/config.toml").unwrap()).unwrap();
let rust_config =
toml::from_slice(&LanguageDir::get("rust/config.toml").unwrap().data).unwrap();
let rust_language = Language {
config: rust_config,
grammar,
@@ -84,7 +85,7 @@ impl LanguageRegistry {
fn load_query(grammar: tree_sitter::Language, path: &str) -> Query {
Query::new(
grammar,
str::from_utf8(LanguageDir::get(path).unwrap().as_ref()).unwrap(),
str::from_utf8(&LanguageDir::get(path).unwrap().data).unwrap(),
)
.unwrap()
}
+11 -3
View File
@@ -2,12 +2,14 @@
#![allow(non_snake_case)]
use fs::OpenOptions;
use gpui::AssetSource;
use log::LevelFilter;
use parking_lot::Mutex;
use simplelog::SimpleLogger;
use std::{fs, path::PathBuf, sync::Arc};
use zed::{
self, assets,
self,
assets::Assets,
channel::ChannelList,
chat_panel, editor, file_finder,
fs::RealFs,
@@ -20,9 +22,15 @@ use zed::{
fn main() {
init_logger();
let app = gpui::App::new(assets::Assets).unwrap();
let app = gpui::App::new(Assets).unwrap();
let embedded_fonts = Assets
.list("fonts")
.into_iter()
.map(|f| Arc::new(Assets.load(&f).unwrap().to_vec()))
.collect();
app.platform().fonts().add_fonts(embedded_fonts).unwrap();
let themes = settings::ThemeRegistry::new(assets::Assets, app.font_cache());
let themes = settings::ThemeRegistry::new(Assets, app.font_cache());
let (settings_tx, settings) = settings::channel(&app.font_cache(), &themes).unwrap();
let languages = Arc::new(language::LanguageRegistry::new());
languages.set_theme(&settings.borrow().theme.syntax);
+2 -2
View File
@@ -37,8 +37,8 @@ impl Settings {
pub fn new(font_cache: &FontCache, theme: Arc<Theme>) -> Result<Self> {
Ok(Self {
buffer_font_family: font_cache.load_family(&["Fira Code", "Monaco"])?,
buffer_font_size: 14.0,
buffer_font_family: font_cache.load_family(&["Inconsolata"])?,
buffer_font_size: 16.,
tab_size: 4,
theme,
})