i_slint_compiler/
embedded_resources.rs1#[cfg(feature = "software-renderer")]
5pub use resvg::tiny_skia::IntRect as Rect;
6
7#[derive(Debug, Clone, Copy, Default)]
8pub struct Size {
9 pub width: u32,
10 pub height: u32,
11}
12
13#[derive(Clone, Copy, Debug, strum::Display)]
14pub enum PixelFormat {
15 Rgb,
17 Rgba,
19 RgbaPremultiplied,
21 AlphaMap([u8; 3]),
23}
24
25#[cfg(feature = "software-renderer")]
26#[derive(Debug, Clone)]
27pub struct Texture {
28 pub total_size: Size,
29 pub original_size: Size,
30 pub rect: Rect,
31 pub data: Vec<u8>,
32 pub format: PixelFormat,
33}
34
35#[cfg(feature = "software-renderer")]
36impl Texture {
37 pub fn new_empty() -> Self {
38 Self {
39 total_size: Size::default(),
40 original_size: Size::default(),
41 rect: Rect::from_xywh(0, 0, 1, 1).unwrap(),
42 data: vec![0, 0, 0, 0],
43 format: PixelFormat::Rgba,
44 }
45 }
46}
47
48#[cfg(feature = "software-renderer")]
49#[derive(Debug, Clone, Default)]
50pub struct BitmapGlyph {
51 pub x: i16,
52 pub y: i16,
53 pub width: i16,
54 pub height: i16,
55 pub x_advance: i16,
56 pub data: Vec<u8>,
58}
59
60#[cfg(feature = "software-renderer")]
61#[derive(Debug, Clone)]
62pub struct BitmapGlyphs {
63 pub pixel_size: i16,
64 pub glyph_data: Vec<BitmapGlyph>,
65}
66
67#[cfg(feature = "software-renderer")]
68#[derive(Debug, Clone)]
69pub struct CharacterMapEntry {
70 pub code_point: char,
71 pub glyph_index: u16,
72}
73
74#[cfg(feature = "software-renderer")]
75#[derive(Debug, Clone)]
76pub struct BitmapFont {
77 pub family_name: String,
78 pub character_map: Vec<CharacterMapEntry>,
80 pub units_per_em: f32,
81 pub ascent: f32,
82 pub descent: f32,
83 pub x_height: f32,
84 pub cap_height: f32,
85 pub glyphs: Vec<BitmapGlyphs>,
86 pub weight: u16,
87 pub italic: bool,
88 pub sdf: bool,
90}
91
92#[derive(Debug, Clone)]
93pub enum EmbeddedResourcesKind {
94 ListOnly,
96 RawData,
98 #[cfg(feature = "software-renderer")]
100 TextureData(Texture),
101 #[cfg(feature = "software-renderer")]
103 BitmapFontData(BitmapFont),
104}
105
106#[derive(Debug, Clone)]
107pub struct EmbeddedResources {
108 pub id: usize,
110
111 pub kind: EmbeddedResourcesKind,
112}