use super::*;
impl Default for NativeSystemFont {
fn default() -> Self {
Self::deterministic()
}
}
impl NativeSystemFont {
#[must_use]
pub fn system() -> Self {
Self {
info: probe_system_font(),
deterministic_only: false,
}
}
#[must_use]
pub fn deterministic() -> Self {
Self {
info: SystemFontInfo::new(
FontRenderBackend::DeterministicBitmap,
FONT_FAMILY_DETERMINISTIC.to_string(),
true,
false,
),
deterministic_only: true,
}
}
}
impl SystemFontProvider for NativeSystemFont {
fn font_info(&self) -> SystemFontInfo {
self.get_info().clone()
}
fn rasterize(&self, key: GlyphKey) -> Option<RasterizedGlyph> {
if !self.get_deterministic_only()
&& let Some(native_glyph) = rasterize_native_glyph(key)
{
return Some(native_glyph);
}
Some(rasterize_glyph(key))
}
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
impl CoreTextFontCache {
#[must_use]
pub(crate) const fn new() -> Self {
Self {
gray_space: null_mut(),
fonts: Vec::new(),
}
}
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
impl Drop for CoreTextFontCache {
fn drop(&mut self) {
let Self { gray_space, fonts } = self;
release_coretext_cache(*gray_space, fonts);
*gray_space = null_mut();
}
}
#[cfg(target_os = "windows")]
impl Win32FontCache {
#[must_use]
pub(crate) const fn new() -> Self {
Self {
hdc: null_mut(),
fonts: Vec::new(),
raw_buf: Vec::new(),
}
}
}
#[cfg(target_os = "windows")]
impl Drop for Win32FontCache {
fn drop(&mut self) {
let Self { hdc, fonts, .. } = self;
release_win32_cache(*hdc, fonts);
*hdc = null_mut();
}
}