Make CosmicTextSystem Linux-only (#14728)

Since `WindowsDispatcher` requires a minimum Windows version of Windows
10 Fall Creators Update (10.0.16299), and the `alacritty_terminal`
dependency relies on conPTY, an API introduced in the same version,
additionally, `DirectWriteTextSystem` also relies on Windows 10 Fall
Creators Update (10.0.16299), so it seems reasonable to make
`CosmicTextSystem` Linux-only. And we can use `DirectWriteTextSystem` on
the Windows platform exclusively. I hope this approach makes sense.

Release Notes:

- N/A
This commit is contained in:
张小白 2024-07-26 01:40:49 +08:00 committed by GitHub
parent a60b3b9389
commit 82d6ad4616
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 11 additions and 28 deletions

View file

@ -49,7 +49,7 @@ pub(crate) struct WindowsPlatform {
icon: HICON,
background_executor: BackgroundExecutor,
foreground_executor: ForegroundExecutor,
text_system: Arc<dyn PlatformTextSystem>,
text_system: Arc<DirectWriteTextSystem>,
clipboard_hash_format: u32,
clipboard_metadata_format: u32,
}
@ -90,13 +90,8 @@ impl WindowsPlatform {
let dispatcher = Arc::new(WindowsDispatcher::new());
let background_executor = BackgroundExecutor::new(dispatcher.clone());
let foreground_executor = ForegroundExecutor::new(dispatcher);
let text_system = if let Some(direct_write) = DirectWriteTextSystem::new().log_err() {
log::info!("Using direct write text system.");
Arc::new(direct_write) as Arc<dyn PlatformTextSystem>
} else {
log::info!("Using cosmic text system.");
Arc::new(CosmicTextSystem::new()) as Arc<dyn PlatformTextSystem>
};
let text_system =
Arc::new(DirectWriteTextSystem::new().expect("Error creating DirectWriteTextSystem"));
let icon = load_icon().unwrap_or_default();
let state = RefCell::new(WindowsPlatformState::new());
let raw_window_handles = RwLock::new(SmallVec::new());