11use anyhow:: { Context , Result } ;
22use log:: { error, info} ;
33use std:: path:: Path ;
4+ #[ cfg( any( target_os = "linux" , target_os = "macos" ) ) ]
45use std:: process:: Command ;
56
67pub async fn install_font ( font_path : & Path ) -> Result < ( ) > {
@@ -50,8 +51,7 @@ pub async fn install_fonts_from_directory(dir_path: &Path) -> Result<(usize, usi
5051async fn install_font_windows ( font_path : & Path ) -> Result < ( ) > {
5152 use std:: fs;
5253 use windows_sys:: Win32 :: System :: Registry :: {
53- RegCloseKey , RegCreateKeyExW , RegSetValueExW , HKEY , HKEY_LOCAL_MACHINE , KEY_SET_VALUE ,
54- REG_OPTION_NON_VOLATILE , REG_SZ ,
54+ RegCloseKey , RegCreateKeyW , RegSetValueExW , HKEY , HKEY_LOCAL_MACHINE , KEY_SET_VALUE , REG_SZ ,
5555 } ;
5656
5757 info ! ( "Installing font on Windows: {:?}" , font_path) ;
@@ -77,19 +77,7 @@ async fn install_font_windows(font_path: &Path) -> Result<()> {
7777 let mut key: HKEY = 0 ;
7878 let subkey = "SOFTWARE\\ Microsoft\\ Windows NT\\ CurrentVersion\\ Fonts" ;
7979 let subkey_wide: Vec < u16 > = subkey. encode_utf16 ( ) . chain ( std:: iter:: once ( 0 ) ) . collect ( ) ;
80- let status = unsafe {
81- RegCreateKeyExW (
82- HKEY_LOCAL_MACHINE ,
83- subkey_wide. as_ptr ( ) ,
84- 0 ,
85- std:: ptr:: null_mut ( ) ,
86- REG_OPTION_NON_VOLATILE ,
87- KEY_SET_VALUE ,
88- std:: ptr:: null ( ) ,
89- & mut key,
90- std:: ptr:: null_mut ( ) ,
91- )
92- } ;
80+ let status = unsafe { RegCreateKeyW ( HKEY_LOCAL_MACHINE , subkey_wide. as_ptr ( ) , & mut key) } ;
9381 if status != 0 {
9482 return Err ( anyhow:: anyhow!( "Failed to open fonts registry key: {}" , status) ) ;
9583 }
0 commit comments