mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Load the Noto Sans font from the nodejs printer demo
This commit is contained in:
parent
1b870959e6
commit
2fdaa44d51
3 changed files with 25 additions and 4 deletions
|
@ -566,10 +566,22 @@ fn singleshot_timer(mut cx: FunctionContext) -> JsResult<JsValue> {
|
|||
Ok(JsUndefined::new().upcast())
|
||||
}
|
||||
|
||||
fn register_font_from_path(mut cx: FunctionContext) -> JsResult<JsValue> {
|
||||
let path = cx.argument::<JsString>(0)?.value();
|
||||
|
||||
match sixtyfps_interpreter::register_font_from_path(&path) {
|
||||
Ok(_) => Ok(JsUndefined::new().upcast()),
|
||||
Err(load_err) => {
|
||||
return cx.throw_error(format!("error loading font {}: {}", path, load_err));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
register_module!(mut m, {
|
||||
m.export_function("load", load)?;
|
||||
m.export_function("mock_elapsed_time", mock_elapsed_time)?;
|
||||
m.export_function("singleshot_timer", singleshot_timer)?;
|
||||
m.export_function("register_font_from_path", register_font_from_path)?;
|
||||
Ok(())
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue