1    type TextDisplay
2        let materials : Materials @auto
3    
4        var obs memory : Option<MeshMemory> = None
5        var obs text_memory : Option<TextMeshMemory> = None
6    
7        let drawable = Drawable
8            mesh = Mesh.from_memory memory@atom
9    
10       maybe_drawable = drawable
11   
12       let update_mesh () =
13           drawable.material = materials.text_rgba font.unwrap
14   
15           let text_mesh_memory = text_mesh/create
16               text
17               visible_up
18               visible_down
19               selection
20               font.unwrap
21   
22           memory = text_mesh_memory.memory
23           set_fixed_width text_mesh_memory.width
24           set_fixed_height text_mesh_memory.height
25   
26           advance = text_mesh_memory.advance
27           margin = text_mesh_memory.margin
28           line_height = text_mesh_memory.line_height
29           has_text = true
30   
31           if text_memory ? Some x then
32               x.discard
33   
34           text_memory = text_mesh_memory
35   
36       update.subscribe { update_mesh } |> push_token
37