You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use std::{ format, vec };use font_kit::{error::SelectionError, source::SystemSource};#[tauri::command]asyncfnall_families() -> Vec<std::string::String>{//Create a system font sourcelet source = SystemSource::new();// Get all fonts in the systemlet fonts:Result<Vec<String>,SelectionError> = source.all_families();//return fontifletOk(font) = fonts {
font
}else{vec![]}}
...invoke_handler(tauri::generate_handler![all_families])
...
third step
Used in js.
awaitinvoke('all_families')
The output looks like this
In fact, javascript can also obtain the richer font family that comes with the system. As long as it is webview based on the Chromium kernel, it will be available, but a built-in permission window will pop up, which will be more troublesome.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
first step
Add
font-kit
to yourCargo.toml
.Step 2
Modify your
main.rs
.third step
Used in
js
.The output looks like this
In fact,
javascript
can also obtain the richerfont family
that comes with the system. As long as it iswebview
based on theChromium
kernel, it will be available, but a built-in permission window will pop up, which will be more troublesome.Beta Was this translation helpful? Give feedback.
All reactions