Fortran · 1151 bytes Raw Blame History
1 module glyph_mod
2 use, intrinsic :: iso_c_binding
3 implicit none
4 public
5
6 ! Glyph information for a single character
7 type :: glyph_t
8 integer :: codepoint = 0 ! Unicode codepoint
9 integer :: tex_x = 0, tex_y = 0 ! Position in texture atlas
10 integer :: width = 0, height = 0 ! Bitmap dimensions
11 integer :: bearing_x = 0 ! Offset from cursor X to left edge
12 integer :: bearing_y = 0 ! Offset from baseline to top edge
13 integer :: advance = 0 ! Horizontal advance to next character
14 real(c_float) :: u0 = 0.0, v0 = 0.0 ! UV coords (top-left)
15 real(c_float) :: u1 = 0.0, v1 = 0.0 ! UV coords (bottom-right)
16 logical :: valid = .false. ! Whether glyph data is loaded
17 end type glyph_t
18
19 contains
20
21 ! Initialize a glyph with default values
22 subroutine glyph_init(g)
23 type(glyph_t), intent(out) :: g
24 g%codepoint = 0
25 g%tex_x = 0
26 g%tex_y = 0
27 g%width = 0
28 g%height = 0
29 g%bearing_x = 0
30 g%bearing_y = 0
31 g%advance = 0
32 g%u0 = 0.0
33 g%v0 = 0.0
34 g%u1 = 0.0
35 g%v1 = 0.0
36 g%valid = .false.
37 end subroutine glyph_init
38
39 end module glyph_mod
40