use crate::text::VariationCoords;
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct FontTweak {
pub scale: f32,
pub y_offset_factor: f32,
pub y_offset: f32,
pub hinting: Option<bool>,
pub hinting_target: HintingTarget,
pub subpixel_binning: Option<bool>,
pub coords: VariationCoords,
pub thin_space_width: f32,
pub tab_size: f32,
}
impl Default for FontTweak {
fn default() -> Self {
Self {
scale: 1.0,
y_offset_factor: 0.0,
y_offset: 0.0,
hinting: None,
hinting_target: HintingTarget::default(),
subpixel_binning: None,
coords: VariationCoords::default(),
thin_space_width: 0.5,
tab_size: 4.0,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub enum HintingTarget {
Mono,
Smooth(SmoothHinting),
}
impl Default for HintingTarget {
fn default() -> Self {
Self::Smooth(SmoothHinting::default())
}
}
impl From<HintingTarget> for skrifa::outline::Target {
fn from(hinting_target: HintingTarget) -> Self {
use skrifa::outline::SmoothMode;
match hinting_target {
HintingTarget::Mono => Self::Mono,
HintingTarget::Smooth(SmoothHinting {
light,
symmetric_rendering,
preserve_linear_metrics,
}) => Self::Smooth {
mode: if light {
SmoothMode::Light
} else {
SmoothMode::Normal
},
symmetric_rendering,
preserve_linear_metrics,
},
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
pub struct SmoothHinting {
pub light: bool,
pub symmetric_rendering: bool,
pub preserve_linear_metrics: bool,
}
impl Default for SmoothHinting {
fn default() -> Self {
Self {
light: false,
symmetric_rendering: true,
preserve_linear_metrics: true,
}
}
}