diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index 28102fdb..d41dfd3c 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -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] diff --git a/nih_plug_vizia/src/lib.rs b/nih_plug_vizia/src/lib.rs index f0633dfa..d0b676aa 100644 --- a/nih_plug_vizia/src/lib.rs +++ b/nih_plug_vizia/src/lib.rs @@ -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 diff --git a/nih_plug_vizia/src/vizia_assets.rs b/nih_plug_vizia/src/vizia_assets.rs new file mode 100644 index 00000000..3772c48a --- /dev/null +++ b/nih_plug_vizia/src/vizia_assets.rs @@ -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); +}