新主题
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
//! Shared, validated typography settings for all built-in OBS components.
|
||||
//!
|
||||
//! Font IDs map to fixed frontend font stacks rather than accepting arbitrary
|
||||
//! CSS. This keeps settings portable between OBS hosts and prevents untrusted
|
||||
//! component settings from becoming a CSS injection boundary.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum FontFamilyId {
|
||||
Song,
|
||||
#[default]
|
||||
FangSong,
|
||||
Kai,
|
||||
}
|
||||
|
||||
pub const fn default_font_brightness() -> u16 {
|
||||
130
|
||||
}
|
||||
|
||||
pub fn sanitize_font_brightness(value: u16) -> u16 {
|
||||
value.clamp(70, 180)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn font_ids_are_stable_and_brightness_is_bounded() {
|
||||
assert_eq!(
|
||||
serde_json::to_string(&FontFamilyId::FangSong).unwrap(),
|
||||
"\"fang-song\""
|
||||
);
|
||||
assert_eq!(sanitize_font_brightness(1), 70);
|
||||
assert_eq!(sanitize_font_brightness(u16::MAX), 180);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user