1
0
Fork 0

Make registering Vizia's default fonts optional

This commit is contained in:
Robbert van der Helm 2022-11-06 14:02:48 +01:00
parent 6f7780bdeb
commit c6a2be41f4
3 changed files with 50 additions and 0 deletions

View file

@ -20,6 +20,10 @@ code then it will not be listed here.
call `nih_plug_vizia::assets::register_noto_sans_light()` for the default
theming to work. All of the plugins in this repo also use
`nih_plug_vizia::assets::register_noto_sans_thin()` as a title font.
- Additionally, the Vizia fork has been updated to not register _any_ default
fonts for the same reason. If you previously relied on Vizia's default Roboto
font, then you must now call `nih_plug_vizia::vizia_assets::register_roboto()`
at the start of your process function.
## [2022-10-23]

View file

@ -16,6 +16,7 @@ use vizia::prelude::*;
pub use vizia;
pub mod assets;
pub mod vizia_assets;
pub mod widgets;
/// Create an [`Editor`] instance using a [`vizia`][::vizia] GUI. The [`ViziaState`] passed to this

View file

@ -0,0 +1,45 @@
//! Registration functions for Vizia's built-in fonts. These are not enabled by default in
//! `nih_plug_vizia` to save on binary size.
use vizia::prelude::*;
// This module provides a re-export and simple font wrappers around the re-exported fonts.
pub use vizia::fonts;
/// The font name for the Roboto (Regular) font, needs to be registered using [`register_roboto()`]
/// first.
pub const ROBOTO: &str = "roboto";
/// The font name for the Roboto Bold font, needs to be registered using [`register_roboto_bold()`]
/// first.
pub const ROBOTO_BOLD: &str = "roboto-bold";
/// The font name for the icon font (Entypo), needs to be registered using [`register_icons()`]
/// first.
pub const ICONS: &str = "icons";
/// The font name for the emoji font (Open Sans Eomji), needs to be registered using
/// [`register_emoji()`] first.
pub const EMOJI: &str = "emoji";
/// The font name for the arabic font (Amiri Regular), needs to be registered using
/// [`register_arabic()`] first.
pub const ARABIC: &str = "arabic";
/// The font name for the material font (Material Icons), needs to be registered using
/// [`register_material()`] first.
pub const MATERIAL: &str = "material";
pub fn register_roboto(cx: &mut Context) {
cx.add_font_mem(ROBOTO, fonts::ROBOTO_REGULAR);
}
pub fn register_roboto_bold(cx: &mut Context) {
cx.add_font_mem(ROBOTO_BOLD, fonts::ROBOTO_BOLD);
}
pub fn register_icons(cx: &mut Context) {
cx.add_font_mem(ICONS, fonts::ENTYPO);
}
pub fn register_emoji(cx: &mut Context) {
cx.add_font_mem(EMOJI, fonts::OPEN_SANS_EMOJI);
}
pub fn register_arabic(cx: &mut Context) {
cx.add_font_mem(ARABIC, fonts::AMIRI_REGULAR);
}
pub fn register_material(cx: &mut Context) {
cx.add_font_mem(MATERIAL, fonts::MATERIAL_ICONS_REGULAR);
}