Add the ability to load application fonts by path

The viewer command line tool also gains the ability to specify them via `--app-font=/path/to/font.ttf` , which can be specified multiple times.
This commit is contained in:
Simon Hausmann 2021-02-17 14:16:02 +01:00
parent 09ea6572e4
commit 45fe6c3e8d
7 changed files with 84 additions and 0 deletions

View file

@ -178,6 +178,15 @@ pub fn register_application_font_from_memory(
sixtyfps_rendering_backend_default::backend().register_application_font_from_memory(data)
}
/// This function can be used to register a custom TrueType font with SixtyFPS,
/// for use with the `font-family` property. The provided path must refer to a valid TrueType
/// font.
pub fn register_application_font_from_path<P: AsRef<std::path::Path>>(
path: P,
) -> Result<(), Box<dyn std::error::Error>> {
sixtyfps_rendering_backend_default::backend().register_application_font_from_path(path.as_ref())
}
// FIXME: this should not be in this namespace
// but the name is `sixtyfps::StateInfo` in builtin.60
#[doc(hidden)]