pretext_egui/
advanced_types.rs1use pretext::{BidiDirection, PretextGlyphRun, PretextStyle};
2
3use crate::glyph_atlas::GlyphSceneBuilder;
4use crate::{BaselineMetrics, BaselineMode, EguiPretextPaintOptions};
5
6#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
8pub enum EmojiAssetId {
9 Rocket,
10 PartyPopper,
11 CheckMark,
12}
13
14#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
16pub enum SvgAssetId {
17 OpenAiLogo,
18 ClaudeLogo,
19 Emoji(EmojiAssetId),
20}
21
22#[derive(Clone, Copy)]
24pub struct EmojiOverlayOptions<'a> {
25 pub style: &'a PretextStyle,
26 pub slot_height: f32,
27 pub padding_x: f32,
28 pub padding_y: f32,
29 pub slack_x: f32,
30 pub slack_y: f32,
31 pub baseline_mode: BaselineMode,
32}
33
34#[derive(Clone, Copy, Debug, PartialEq)]
36pub struct EmojiOverlay {
37 pub start: f32,
38 pub end: f32,
39 pub emoji_id: EmojiAssetId,
40}
41
42#[derive(Clone, Debug, PartialEq)]
44pub struct EmojiOverlayRun {
45 pub line_offset: f32,
46 pub width: f32,
47 pub direction: BidiDirection,
48 pub baseline_metrics: BaselineMetrics,
49 pub emojis: Vec<EmojiOverlay>,
50}
51
52#[derive(Clone, Copy)]
54pub struct PositionedTextRunRef<'a> {
55 pub x: f32,
56 pub y: f32,
57 pub text: &'a str,
58 pub glyph_runs: &'a [PretextGlyphRun],
59 pub emoji_overlays: &'a [EmojiOverlayRun],
60}
61
62#[derive(Clone)]
64pub struct StyledPositionedTextRunRef<'a, 'b> {
65 pub x: f32,
66 pub y: f32,
67 pub text: &'a str,
68 pub glyph_runs: &'a [PretextGlyphRun],
69 pub emoji_overlays: &'a [EmojiOverlayRun],
70 pub options: EguiPretextPaintOptions<'b>,
71}
72
73#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
75pub enum AtlasWarmupBucket {
76 CommonSans,
77 CommonSerif,
78 SerifDisplay,
79 Mono,
80 Arabic,
81 Cjk,
82 Myanmar,
83}
84
85#[derive(Clone)]
86pub(crate) struct PendingFallbackText {
87 pub(crate) origin: egui::Pos2,
88 pub(crate) text: String,
89 pub(crate) fallback_align: egui::Align2,
90 pub(crate) fallback_font: egui::FontId,
91 pub(crate) color: egui::Color32,
92}
93
94#[derive(Clone)]
95pub(crate) struct PendingEmojiPaint {
96 pub(crate) line_left: f32,
97 pub(crate) slot_top: f32,
98 pub(crate) overlay_runs: Vec<EmojiOverlayRun>,
99 pub(crate) emoji_size: f32,
100 pub(crate) slot_height: f32,
101}
102
103pub struct PretextFragmentPainter {
105 pub(crate) scene: GlyphSceneBuilder,
106 pub(crate) pending_fallbacks: Vec<PendingFallbackText>,
107 pub(crate) pending_emoji: Vec<PendingEmojiPaint>,
108}