i_slint_compiler/
embedded_resources.rs1#[cfg(feature = "renderer-software")]
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 = "renderer-software")]
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 = "renderer-software")]
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 = "renderer-software")]
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 = "renderer-software")]
61#[derive(Debug, Clone)]
62pub struct BitmapGlyphs {
63 pub pixel_size: i16,
64 pub glyph_data: Vec<BitmapGlyph>,
65}
66
67#[cfg(feature = "renderer-software")]
68#[derive(Debug, Clone)]
69pub struct CharacterMapEntry {
70 pub code_point: char,
71 pub glyph_index: u16,
72}
73
74#[cfg(feature = "renderer-software")]
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 FileData,
98 DataUriPayload(Vec<u8>, String),
100 #[cfg(feature = "renderer-software")]
102 TextureData(Texture),
103 #[cfg(feature = "renderer-software")]
105 BitmapFontData(BitmapFont),
106 #[cfg(feature = "slint-sc")]
109 StaticPixels(image::RgbaImage),
110}
111
112#[derive(Debug, Clone)]
113pub struct EmbeddedResources {
114 pub path: Option<smol_str::SmolStr>,
116
117 pub kind: EmbeddedResourcesKind,
118}
119
120#[derive(
122 Debug,
123 Clone,
124 Copy,
125 Hash,
126 PartialEq,
127 Eq,
128 derive_more::Into,
129 derive_more::From,
130 derive_more::Display,
131)]
132pub struct EmbeddedResourcesIdx(pub usize);