zng_view_api/
font.rs

1//! Font types.
2
3use serde::{Deserialize, Serialize};
4use zng_unit::Px;
5
6use crate::{config::FontAntiAliasing, declare_id};
7
8declare_id! {
9    /// Font resource in a renderer cache.
10    ///
11    /// The View Process defines the ID.
12    pub struct FontFaceId(_);
13
14    /// Sized font in a renderer.
15    ///
16    /// The View Process defines the ID.
17    pub struct FontId(_);
18}
19
20/// Extra font options.
21#[derive(Default, Debug, PartialEq, Clone, Deserialize, Serialize)]
22pub struct FontOptions {
23    /// Font render mode.
24    ///
25    /// Default value must be already resolved here, it falls back to Subpixel.
26    pub aa: FontAntiAliasing,
27
28    /// If synthetic bold is enabled.
29    pub synthetic_bold: bool,
30    /// If synthetic skew is enabled.
31    pub synthetic_oblique: bool,
32}
33
34/// Extra font options send with text glyphs.
35pub type GlyphOptions = FontOptions;
36
37/// Font feature name, `*b"hlig"` for example.
38pub type FontVariationName = [u8; 4];
39
40/// Glyph index with position.
41#[repr(C)]
42#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)]
43pub struct GlyphInstance {
44    /// Glyph id.
45    pub index: GlyphIndex,
46    /// Glyph position.
47    pub point: euclid::Point2D<f32, Px>,
48}
49
50/// Glyph index in a font.
51pub type GlyphIndex = u32;