aboutsummaryrefslogtreecommitdiff
path: root/vendor/sdl3/ttf/sdl3_textengine.odin
blob: 00bf881ddaea56010b3df94a735ffcb89fe53366 (plain)
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
package sdl3_ttf

import "core:c"
import SDL "vendor:sdl3"

DrawCommand :: enum c.int {
	NOOP,
	FILL,
	COPY,
}

FillOperation :: struct {
	cmd:  DrawCommand,
	rect: SDL.Rect,
}

CopyOperation :: struct {
	cmd:         DrawCommand,
	text_offset: c.int,
	glyph_font:  ^Font,
	glyph_index: u32,
	src:         SDL.Rect,
	dst:         SDL.Rect,
	reserved:    rawptr,
}

DrawOperation :: struct #raw_union {
	cmd:  DrawCommand,
	fill: FillOperation,
	copy: CopyOperation,
}

TextLayout :: struct {}

TextData :: struct {
	font:                ^Font,
	color:               SDL.FColor,
	needs_layout_update: bool,
	layout:              ^TextLayout,
	x, y:                c.int,
	w, h:                c.int,
	num_ops:             c.int,
	ops:                 [^]DrawOperation `fmt:"v,num_ops"`,
	num_clusters:        c.int,
	clusters:            [^]SubString     `fmt:"v,num_clusters"`,
	props:               SDL.PropertiesID,
	needs_engine_update: bool,
	engine:              ^TextEngine,
	engine_text:         rawptr,
}

TextEngine :: struct {
	version:     u32,
	userdata:    rawptr,
	CreateText:  proc "c" (userdata: rawptr, text: ^Text) -> bool,
	DestroyText: proc "c" (userdata: rawptr, Textext: ^Text),
}

#assert(
	(size_of(TextEngine) == 16 && size_of(rawptr) == 4) ||
	(size_of(TextEngine) == 32 && size_of(rawptr) == 8),
)