update
This commit is contained in:
+9
-17
@@ -1,5 +1,8 @@
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use gpui::*;
|
||||
use universal_time::{Instant, MonotonicClock, SystemTime, WallClock, define_time_provider};
|
||||
@@ -42,36 +45,29 @@ pub fn run() -> Result<(), JsValue> {
|
||||
// Sets the panic hook and GPUI's console logger
|
||||
gpui_platform::web_init();
|
||||
|
||||
// A single-threaded platform that draws emoji and CJK graphemes missing
|
||||
// from the bundled fonts with the browser's own fonts, plus a fetch-based
|
||||
// HTTP client so remote images and content work like on desktop
|
||||
let platform = std::rc::Rc::new(gpui_web::WebPlatform::new_with_backend_and_font_fallback(
|
||||
false,
|
||||
gpui_web::WebBackendPreference::Auto,
|
||||
gpui_web::CanvasFontFallback::EmojiAndCjk,
|
||||
));
|
||||
let http_client = std::sync::Arc::new(platform.fetch_http_client());
|
||||
|
||||
let http_client = Arc::new(platform.fetch_http_client());
|
||||
|
||||
let app = Application::with_platform(platform)
|
||||
.with_http_client(http_client)
|
||||
.with_assets(assets::CombinedAssets);
|
||||
|
||||
APPLICATION.with(|application| {
|
||||
*application.borrow_mut() = Some(app.run_embedded(|cx| {
|
||||
// Initialize the framework before anything renders
|
||||
gpui_kit::init(cx);
|
||||
|
||||
// The web text system starts with no fonts, and GPUI panics when
|
||||
// it lays out text in a family that does not exist. Inter is both
|
||||
// bundled and named on the theme (including both mode configs, so
|
||||
// theme reloads keep it) before any text is laid out
|
||||
load_embedded_fonts(cx);
|
||||
apply_web_fonts(cx);
|
||||
|
||||
// Initialize the framework before anything renders
|
||||
gpui_kit::init(cx);
|
||||
|
||||
// Initialize settings
|
||||
settings::init(cx);
|
||||
|
||||
// There is no native theme on the web; apply the persisted
|
||||
// appearance directly, then the user's theme tuning
|
||||
apply_appearance(settings::persisted_appearance_mode(), cx);
|
||||
settings::AppSettings::apply_theme_style(cx);
|
||||
|
||||
@@ -121,10 +117,6 @@ fn load_embedded_fonts(cx: &mut App) {
|
||||
.expect("Failed to load bundled fonts");
|
||||
}
|
||||
|
||||
/// Name Inter on the theme and both mode configs so every text run renders in
|
||||
/// it and theme reloads keep it. Without an explicit family the theme falls
|
||||
/// back to `.SystemUIFont`, which the web platform resolves to a family that
|
||||
/// is not bundled
|
||||
fn apply_web_fonts(cx: &mut App) {
|
||||
use gpui_kit::component::Theme;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user