motion-canvas-rs 0.1.2

A high-performance vector animation engine inspired by Motion Canvas, built on Vello and Typst.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
//! Code highlighting and animation module.
//!
//! Credits: The token-based animation logic and diffing approach is inspired by
//! [shiki-magic-move](https://github.com/shikijs/shiki-magic-move).

use crate::engine::animation::{Node, Signal, Tweenable};
use crate::engine::font::FontManager;
use glam::Vec2;
use lazy_static::lazy_static;
use similar::TextDiff;
use skrifa::instance::{LocationRef, Size};
use skrifa::MetadataProvider;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use syntect::easy::HighlightLines;
use syntect::highlighting::ThemeSet;
use syntect::parsing::SyntaxSet;
use vello::kurbo::{Affine, BezPath};
use vello::peniko::{Brush, Color, Fill};
use vello::Scene;

lazy_static! {
    static ref SYNTAX_SET: SyntaxSet = SyntaxSet::load_defaults_newlines();
    static ref THEME_SET: ThemeSet = ThemeSet::load_defaults();
    static ref GLOBAL_CODE_CACHE: Mutex<HashMap<CodeCacheKey, Arc<Vec<Token>>>> =
        Mutex::new(HashMap::new());
}

const DEFAULT_FONT_SIZE: f32 = 24.0;
const DEFAULT_THEME: &str = "base16-ocean.dark";
const DEFAULT_FONT_FAMILY: &str = "Fira Code";
const DEFAULT_LANGUAGE: &str = "rust";
const DEFAULT_OPACITY: f32 = 1.0;
const DEFAULT_DIM_OPACITY: f32 = 0.2;
const LINE_HEIGHT_MULTIPLIER: f32 = 1.5;
const ADVANCE_FALLBACK_FACTOR: f32 = 0.6;

#[derive(Hash, Eq, PartialEq, Clone)]
struct CodeCacheKey {
    code: String,
    font_size_bits: u32,
    language: String,
    theme: String,
    font_family: String,
}

#[derive(Clone, Debug, PartialEq)]
pub struct Token {
    pub text: String,
    pub color: Color,
    pub pos: Vec2,
    pub size: f32,
    pub glyphs: Vec<(Affine, BezPath)>,
    pub width: f32,
    pub line_index: usize,
}

#[derive(Clone, Debug, PartialEq)]
pub struct CodeTransition {
    pub from_tokens: Vec<Token>,
    pub to_tokens: Vec<Token>,
    pub progress: f32,
    pub matches: Vec<(usize, usize)>, // (from_idx, to_idx)
    pub from_selection: Vec<usize>,
    pub to_selection: Vec<usize>,
}

#[derive(Clone, Debug, PartialEq)]
pub struct CodeValue {
    pub text: String,
    pub tokens: Vec<Token>,
    pub transition: Option<CodeTransition>,
    pub selection: Vec<usize>,
}

impl CodeValue {
    pub fn new(text: String, node: &CodeNode) -> Self {
        let text = strip_common_indent(&text);
        let tokens = node.tokenize(&text);
        CodeValue {
            text,
            tokens,
            transition: None,
            selection: Vec::new(),
        }
    }
}

fn strip_common_indent(text: &str) -> String {
    let lines: Vec<&str> = text.lines().collect();
    if lines.is_empty() {
        return text.to_string();
    }

    let min_indent = lines
        .iter()
        .filter(|l| !l.trim().is_empty())
        .map(|l| l.chars().take_while(|c| c.is_whitespace()).count())
        .min()
        .unwrap_or(0);

    if min_indent == 0 {
        return text.to_string();
    }

    lines
        .iter()
        .map(|l| {
            if l.trim().is_empty() {
                ""
            } else {
                &l[min_indent..]
            }
        })
        .collect::<Vec<&str>>()
        .join("\n")
}

impl Default for CodeValue {
    fn default() -> Self {
        Self {
            text: String::new(),
            tokens: Vec::new(),
            transition: None,
            selection: Vec::new(),
        }
    }
}

impl Tweenable for CodeValue {
    fn interpolate(a: &Self, b: &Self, t: f32) -> Self {
        if t <= 0.0 {
            return a.clone();
        }
        if t >= 1.0 {
            return b.clone();
        }

        // If both text and highlights are identical, no need to transition
        if a.text == b.text && a.selection == b.selection {
            return b.clone();
        }

        // Find matches between a and b tokens using similar crate
        // We include color in the key to distinguish tokens better
        let a_toks: Vec<String> = a
            .tokens
            .iter()
            .map(|t| format!("{}{:?}", t.text, t.color))
            .collect();
        let b_toks: Vec<String> = b
            .tokens
            .iter()
            .map(|t| format!("{}{:?}", t.text, t.color))
            .collect();

        // similar::diff_slices works best with &[&str]
        let a_tok_refs: Vec<&str> = a_toks.iter().map(|s| s.as_str()).collect();
        let b_tok_refs: Vec<&str> = b_toks.iter().map(|s| s.as_str()).collect();

        let diff = TextDiff::configure()
            .algorithm(similar::Algorithm::Patience)
            .diff_slices(&a_tok_refs, &b_tok_refs);
        let mut matches = Vec::new();

        for op in diff.ops() {
            match *op {
                similar::DiffOp::Equal {
                    old_index,
                    new_index,
                    len,
                } => {
                    for i in 0..len {
                        matches.push((old_index + i, new_index + i));
                    }
                }
                _ => {}
            }
        }

        CodeValue {
            text: b.text.clone(),
            tokens: b.tokens.clone(),
            transition: Some(CodeTransition {
                from_tokens: a.tokens.clone(),
                to_tokens: b.tokens.clone(),
                progress: t,
                matches,
                from_selection: a.selection.clone(),
                to_selection: b.selection.clone(),
            }),
            selection: b.selection.clone(),
        }
    }
}

pub struct CodeNode {
    pub transform: Signal<Affine>,
    pub code: Signal<CodeValue>,
    pub font_size: Signal<f32>,
    pub opacity: Signal<f32>,
    pub dim_opacity: Signal<f32>,
    pub language: String,
    pub theme: String,
    pub font_family: String,
}

impl Default for CodeNode {
    fn default() -> Self {
        let node = Self {
            transform: Signal::new(Affine::IDENTITY),
            code: Signal::new(CodeValue::default()),
            font_size: Signal::new(DEFAULT_FONT_SIZE),
            opacity: Signal::new(DEFAULT_OPACITY),
            dim_opacity: Signal::new(DEFAULT_DIM_OPACITY),
            language: DEFAULT_LANGUAGE.to_string(),
            theme: DEFAULT_THEME.to_string(),
            font_family: DEFAULT_FONT_FAMILY.to_string(),
        };
        // Initialize with empty code
        let val = CodeValue::new("".to_string(), &node);
        node.code.set(val);
        node
    }
}

impl Clone for CodeNode {
    fn clone(&self) -> Self {
        Self {
            transform: self.transform.clone(),
            code: self.code.clone(),
            font_size: self.font_size.clone(),
            opacity: self.opacity.clone(),
            dim_opacity: self.dim_opacity.clone(),
            language: self.language.clone(),
            theme: self.theme.clone(),
            font_family: self.font_family.clone(),
        }
    }
}

impl CodeNode {
    pub fn new(pos: Vec2, code: &str, lang: &str) -> Self {
        Self::default()
            .with_position(pos)
            .with_language(lang)
            .with_code(code)
    }

    pub fn with_transform(mut self, transform: Affine) -> Self {
        self.transform = Signal::new(transform);
        self
    }

    pub fn with_position(mut self, position: Vec2) -> Self {
        self.transform = Signal::new(Affine::translate((position.x as f64, position.y as f64)));
        self
    }

    pub fn with_rotation(mut self, angle: f32) -> Self {
        let current = self.transform.get();
        let coeffs = current.as_coeffs();
        let tx = coeffs[4];
        let ty = coeffs[5];
        self.transform = Signal::new(Affine::translate((tx, ty)) * Affine::rotate(angle as f64));
        self
    }

    pub fn with_scale(mut self, scale: f32) -> Self {
        let current = self.transform.get();
        let coeffs = current.as_coeffs();
        let tx = coeffs[4];
        let ty = coeffs[5];
        self.transform = Signal::new(Affine::translate((tx, ty)) * Affine::scale(scale as f64));
        self
    }

    pub fn with_opacity(mut self, opacity: f32) -> Self {
        self.opacity = Signal::new(opacity);
        self
    }

    pub fn with_code(self, code: &str) -> Self {
        let val = CodeValue::new(code.to_string(), &self);
        self.code.set(val);
        self
    }

    pub fn with_language(mut self, lang: &str) -> Self {
        self.language = lang.to_string();
        // Re-tokenize if code exists
        let current_text = self.code.get().text;
        let val = CodeValue::new(current_text, &self);
        self.code.set(val);
        self
    }

    pub fn with_theme(mut self, theme: &str) -> Self {
        self.theme = theme.to_string();
        self
    }

    pub fn with_font(mut self, font: &str) -> Self {
        self.font_family = font.to_string();
        self
    }

    pub fn with_font_size(mut self, size: f32) -> Self {
        self.font_size = Signal::new(size);
        // Re-tokenize current code with new size to avoid "spazzing"
        let current_text = self.code.get().text;
        let mut val = CodeValue::new(current_text, &self);
        val.selection = self.code.get().selection;
        self.code.set(val);
        self
    }

    pub fn with_dim_opacity(mut self, dim: f32) -> Self {
        self.dim_opacity = Signal::new(dim);
        self
    }

    pub fn edit(
        &self,
        code: &str,
        duration: Duration,
    ) -> crate::engine::animation::SignalTween<CodeValue> {
        let code = code.to_string();
        let node = self.clone();
        self.code.to_lazy(
            move |current| {
                let mut next_value = CodeValue::new(code, &node);
                next_value.selection = current.selection.clone();
                next_value
            },
            duration,
        )
    }

    pub fn append(
        &self,
        text: &str,
        duration: Duration,
    ) -> crate::engine::animation::SignalTween<CodeValue> {
        let text = text.to_string();
        let node = self.clone();
        self.code.to_lazy(
            move |current| {
                let next_text = format!("{}{}", current.text, text);
                let mut next_val = CodeValue::new(next_text, &node);
                next_val.selection = current.selection.clone();
                next_val
            },
            duration,
        )
    }

    pub fn prepend(
        &self,
        text: &str,
        duration: Duration,
    ) -> crate::engine::animation::SignalTween<CodeValue> {
        let text = text.to_string();
        let node = self.clone();
        self.code.to_lazy(
            move |current| {
                let next_text = format!("{}{}", text, current.text);
                let mut next_val = CodeValue::new(next_text, &node);
                next_val.selection = current.selection.clone();
                next_val
            },
            duration,
        )
    }

    pub fn select_lines(
        &self,
        lines: Vec<usize>,
        duration: Duration,
    ) -> crate::engine::animation::SignalTween<CodeValue> {
        self.code.to_lazy(
            move |current| {
                let mut next_value = current.clone();
                next_value.transition = None; // Reset transition for the target
                next_value.selection = lines;
                next_value
            },
            duration,
        )
    }

    /// Select lines using a printer-style selection string (e.g., "1-3, 5").
    /// Uses 1-based indexing for user convenience.
    pub fn select_string(
        &self,
        selection: &str,
        duration: Duration,
    ) -> crate::engine::animation::SignalTween<CodeValue> {
        let lines = self.parse_selection(selection);
        self.select_lines(lines, duration)
    }

    fn parse_selection(&self, selection: &str) -> Vec<usize> {
        let mut lines = Vec::new();
        for part in selection.split(',') {
            let part = part.trim();
            if part.contains('-') {
                let mut bounds = part.split('-');
                if let (Some(start_str), Some(end_str)) = (bounds.next(), bounds.next()) {
                    if let (Ok(start), Ok(end)) =
                        (start_str.parse::<usize>(), end_str.parse::<usize>())
                    {
                        for i in start..=end {
                            if i > 0 {
                                lines.push(i - 1);
                            }
                        }
                    }
                }
            } else if let Ok(line) = part.parse::<usize>() {
                if line > 0 {
                    lines.push(line - 1);
                }
            }
        }
        lines.sort_unstable();
        lines.dedup();
        lines
    }

    fn tokenize(&self, code: &str) -> Vec<Token> {
        let size = self.font_size.get();
        let key = CodeCacheKey {
            code: code.to_string(),
            font_size_bits: size.to_bits(),
            language: self.language.clone(),
            theme: self.theme.clone(),
            font_family: self.font_family.clone(),
        };

        if let Some(cached) = GLOBAL_CODE_CACHE.lock().unwrap().get(&key) {
            return (**cached).clone();
        }

        let mut tokens = Vec::new();
        let syntax = SYNTAX_SET
            .find_syntax_by_extension(&self.language)
            .or_else(|| SYNTAX_SET.find_syntax_by_name(&self.language))
            .or_else(|| SYNTAX_SET.find_syntax_by_name(&self.language.to_lowercase()))
            .or_else(|| {
                SYNTAX_SET.find_syntax_by_name(&format!(
                    "{}{}",
                    (&self.language[..1]).to_uppercase(),
                    &self.language[1..]
                ))
            })
            .unwrap_or_else(|| SYNTAX_SET.find_syntax_plain_text());

        let theme_name = if THEME_SET.themes.contains_key(&self.theme) {
            &self.theme
        } else {
            DEFAULT_THEME
        };
        let theme = &THEME_SET.themes[theme_name];
        let mut h = HighlightLines::new(syntax, theme);
        let mut y_offset = 0.0;

        if let Some(font_data) = FontManager::get_font_with_fallback(&[
            &self.font_family,
            "Fira Code",
            "Courier New",
            "monospace",
        ]) {
            let font_ref = FontManager::get_font_ref(&font_data);
            let charmap = font_ref.charmap();
            let outlines = font_ref.outline_glyphs();

            for (line_idx, line) in code.lines().enumerate() {
                let ranges = h.highlight_line(line, &SYNTAX_SET).unwrap();
                let mut x_offset = 0.0;
                for (style, text) in ranges {
                    let fg = style.foreground;
                    let color = Color::rgba8(fg.r, fg.g, fg.b, fg.a);

                    let mut token_text = String::new();
                    let mut glyphs = Vec::new();
                    let mut token_width = 0.0;

                    for c in text.chars() {
                        let glyph_id = charmap.map(c).unwrap_or_default();
                        let mut pb = BezPath::new();
                        let mut advance = (size * ADVANCE_FALLBACK_FACTOR) as f64;

                        if let Some(glyph) = outlines.get(glyph_id) {
                            let mut sink = PathSink(&mut pb);
                            let font_size = Size::new(size);
                            let _ = glyph.draw(font_size, &mut sink);

                            if let Some(metrics) = font_ref
                                .glyph_metrics(font_size, LocationRef::default())
                                .advance_width(glyph_id)
                            {
                                advance = metrics as f64;
                            }
                        }

                        let base_transform = Affine::translate((token_width, size as f64))
                            * Affine::scale_non_uniform(1.0, -1.0);
                        glyphs.push((base_transform, pb));
                        token_width += advance;
                        token_text.push(c);
                    }

                    tokens.push(Token {
                        text: token_text,
                        color,
                        pos: Vec2::new(x_offset as f32, y_offset as f32),
                        size,
                        glyphs,
                        width: token_width as f32,
                        line_index: line_idx,
                    });

                    x_offset += token_width;
                }
                y_offset += (size * LINE_HEIGHT_MULTIPLIER) as f64;
            }
        }

        let arc_tokens = Arc::new(tokens.clone());
        GLOBAL_CODE_CACHE.lock().unwrap().insert(key, arc_tokens);
        tokens
    }
}

struct PathSink<'a>(&'a mut BezPath);

impl<'a> skrifa::outline::OutlinePen for PathSink<'a> {
    fn move_to(&mut self, x: f32, y: f32) {
        self.0.move_to((x as f64, y as f64));
    }
    fn line_to(&mut self, x: f32, y: f32) {
        self.0.line_to((x as f64, y as f64));
    }
    fn quad_to(&mut self, cx0: f32, cy0: f32, x: f32, y: f32) {
        self.0
            .quad_to((cx0 as f64, cy0 as f64), (x as f64, y as f64));
    }
    fn curve_to(&mut self, cx0: f32, cy0: f32, cx1: f32, cy1: f32, x: f32, y: f32) {
        self.0.curve_to(
            (cx0 as f64, cy0 as f64),
            (cx1 as f64, cy1 as f64),
            (x as f64, y as f64),
        );
    }
    fn close(&mut self) {
        self.0.close_path();
    }
}

impl Node for CodeNode {
    fn render(&self, scene: &mut Scene, parent_transform: Affine, parent_opacity: f32) {
        let code_val = self.code.get();
        let local_transform = self.transform.get();
        let opacity = self.opacity.get();
        let root_transform = parent_transform * local_transform;
        let combined_opacity = parent_opacity * opacity;

        let dim_factor = self.dim_opacity.get();

        if let Some(trans) = &code_val.transition {
            let p = trans.progress;

            let mut matched_from = vec![false; trans.from_tokens.len()];
            let mut matched_to = vec![false; trans.to_tokens.len()];

            // 1. Draw moving matches
            for &(from_idx, to_idx) in &trans.matches {
                let from = &trans.from_tokens[from_idx];
                let to = &trans.to_tokens[to_idx];

                let current_pos = from.pos.lerp(to.pos, p);
                let current_color = Color::interpolate(&from.color, &to.color, p);

                let scale = if from.size != to.size {
                    (from.size + (to.size - from.size) * p) / to.size
                } else {
                    1.0
                };

                let from_is_dimmed = !trans.from_selection.is_empty()
                    && !trans.from_selection.contains(&from.line_index);
                let to_is_dimmed =
                    !trans.to_selection.is_empty() && !trans.to_selection.contains(&to.line_index);

                let from_dim = if from_is_dimmed { dim_factor } else { 1.0 };
                let to_dim = if to_is_dimmed { dim_factor } else { 1.0 };
                let current_dim = from_dim + (to_dim - from_dim) * p;

                draw_token(
                    scene,
                    root_transform
                        * Affine::translate((current_pos.x as f64, current_pos.y as f64))
                        * Affine::scale(scale as f64),
                    to,
                    current_color,
                    combined_opacity * current_dim,
                );

                matched_from[from_idx] = true;
                matched_to[to_idx] = true;
            }

            // Draw unmatched from-tokens (vanishing)
            for (i, matched) in matched_from.iter().enumerate() {
                if !*matched {
                    let from = &trans.from_tokens[i];
                    let is_dimmed = !trans.from_selection.is_empty()
                        && !trans.from_selection.contains(&from.line_index);
                    let dim = if is_dimmed { dim_factor } else { 1.0 };
                    draw_token(
                        scene,
                        root_transform * Affine::translate((from.pos.x as f64, from.pos.y as f64)),
                        from,
                        from.color,
                        combined_opacity * dim * (1.0 - p),
                    );
                }
            }

            // Draw unmatched to-tokens (appearing)
            for (i, matched) in matched_to.iter().enumerate() {
                if !*matched {
                    let to = &trans.to_tokens[i];
                    let is_dimmed = !trans.to_selection.is_empty()
                        && !trans.to_selection.contains(&to.line_index);
                    let dim = if is_dimmed { dim_factor } else { 1.0 };
                    draw_token(
                        scene,
                        root_transform * Affine::translate((to.pos.x as f64, to.pos.y as f64)),
                        to,
                        to.color,
                        combined_opacity * dim * p,
                    );
                }
            }
        } else {
            // Static render
            let has_selection = !code_val.selection.is_empty();
            let dim_factor = self.dim_opacity.get();
            for token in &code_val.tokens {
                let is_selected = !has_selection || code_val.selection.contains(&token.line_index);
                let dim = if is_selected { 1.0 } else { dim_factor };
                draw_token(
                    scene,
                    root_transform * Affine::translate((token.pos.x as f64, token.pos.y as f64)),
                    token,
                    token.color,
                    combined_opacity * dim,
                );
            }
        }
    }

    fn update(&mut self, _dt: Duration) {}

    fn state_hash(&self) -> u64 {
        use std::collections::hash_map::DefaultHasher;
        use std::hash::{Hash, Hasher};
        let mut s = DefaultHasher::new();

        let coeffs = self.transform.get().as_coeffs();
        for c in coeffs {
            c.to_bits().hash(&mut s);
        }

        self.font_size.get().to_bits().hash(&mut s);
        let val = self.code.get();
        val.text.hash(&mut s);
        if let Some(trans) = &val.transition {
            trans.progress.to_bits().hash(&mut s);
        }
        self.language.hash(&mut s);
        self.theme.hash(&mut s);
        self.font_family.hash(&mut s);
        self.opacity.get().to_bits().hash(&mut s);
        s.finish()
    }

    fn clone_node(&self) -> Box<dyn Node> {
        Box::new(self.clone())
    }
}

fn draw_token(scene: &mut Scene, transform: Affine, token: &Token, color: Color, opacity: f32) {
    if opacity <= 0.0 {
        return;
    }
    let mut c = color;
    // We need to be careful with alpha.
    // Multiply the token's original alpha by the transition opacity.
    let alpha = (color.a as f32 * opacity).clamp(0.0, 255.0) as u8;
    c.a = alpha;
    let brush = Brush::Solid(c);
    for (glyph_transform, pb) in &token.glyphs {
        scene.fill(
            Fill::NonZero,
            transform * *glyph_transform,
            &brush,
            None,
            pb,
        );
    }
}