huozi/layout/
layout_style.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Default, Serialize, Deserialize)]
4#[serde(rename_all = "lowercase")]
5pub enum LayoutDirection {
6    #[default]
7    Horizontal,
8    Vertical,
9}
10
11/// This is the setting of the full text in a `box`, which is also known as `text window`.
12#[derive(Debug, Clone, Serialize, Deserialize)]
13#[serde(rename_all = "camelCase", default)]
14pub struct LayoutStyle {
15    /// the writing direction of the text in the box,
16    /// only `Horizontal` (right-to-left) or `Vertical` (top-to-bottom) is valid.
17    pub direction: LayoutDirection,
18    /// the width of box.
19    pub box_width: f64,
20    /// the height of box.
21    pub box_height: f64,
22    /// the size of the glyph grid which each character be fit to, usually equals to `font_size`.
23    pub glyph_grid_size: f64,
24}
25
26impl Default for LayoutStyle {
27    fn default() -> Self {
28        Self {
29            direction: Default::default(),
30            box_width: 1280.,
31            box_height: 720.,
32            glyph_grid_size: 24.,
33        }
34    }
35}