revert back to rasterized fonts

This commit is contained in:
Matthew 2026-04-24 07:28:55 +10:00
parent 61422a21b5
commit 05706efecc
21 changed files with 566 additions and 105 deletions

BIN
assets/Lato-Regular.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
assets/msdf-atlas.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 KiB

BIN
assets/msdf-atlas.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
assets/msdf-atlas.rgba Normal file

Binary file not shown.

95
assets/msdf.csv Normal file
View File

@ -0,0 +1,95 @@
32,0.59999999999999998,0,0,0,0,0,0,0,0
33,0.59999999999999998,0.19230769230769232,-0.046153846153846149,0.40769230769230769,0.78461538461538449,19.5,151.5,26.5,178.5
34,0.59999999999999998,0.10000000000000001,0.38461538461538458,0.5,0.78461538461538449,0.5,2.5,13.5,15.5
35,0.59999999999999998,-0.0076923076923077257,-0.046153846153846149,0.60769230769230764,0.78461538461538449,195.5,188.5,215.5,215.5
36,0.59999999999999998,0.038461538461538408,-0.20000000000000001,0.56153846153846143,0.90769230769230758,0.5,179.5,17.5,215.5
37,0.59999999999999998,-0.023076923076923134,-0.046153846153846149,0.62307692307692286,0.78461538461538449,44.5,151.5,65.5,178.5
38,0.59999999999999998,-0.018461538461538505,-0.046153846153846149,0.65846153846153832,0.78461538461538449,105.5,151.5,127.5,178.5
39,0.59999999999999998,0.2076923076923077,0.38461538461538458,0.39230769230769225,0.78461538461538449,31.5,2.5,37.5,15.5
40,0.59999999999999998,0.15038461538461537,-0.16923076923076924,0.51961538461538459,0.87692307692307681,18.5,181.5,30.5,215.5
41,0.59999999999999998,0.080384615384615388,-0.16923076923076924,0.44961538461538458,0.87692307692307681,71.5,181.5,83.5,215.5
42,0.59999999999999998,-0.0076923076923077465,0.046153846153846149,0.60769230769230764,0.66153846153846141,143.5,17.5,163.5,37.5
43,0.59999999999999998,0.023076923076923054,0.046153846153846149,0.57692307692307676,0.59999999999999987,164.5,19.5,182.5,37.5
44,0.59999999999999998,0.16842307692307693,-0.20000000000000001,0.41457692307692307,0.19999999999999998,206.5,99.5,214.5,112.5
45,0.59999999999999998,0.10000000000000001,0.23076923076923078,0.5,0.41538461538461535,201.5,31.5,214.5,37.5
46,0.59999999999999998,0.17692307692307693,-0.046153846153846149,0.42307692307692307,0.19999999999999996,201.5,22.5,209.5,30.5
47,0.59999999999999998,0.038461538461538457,-0.16923076923076924,0.56153846153846154,0.87692307692307681,84.5,181.5,101.5,215.5
48,0.59999999999999998,0.038461538461538471,-0.046153846153846149,0.56153846153846154,0.78461538461538449,0.5,122.5,17.5,149.5
49,0.59999999999999998,0.053461538461538456,-0.046153846153846149,0.57653846153846156,0.78461538461538449,18.5,122.5,35.5,149.5
50,0.59999999999999998,0.039961538461538437,-0.046153846153846149,0.5630384615384616,0.78461538461538449,53.5,122.5,70.5,149.5
51,0.59999999999999998,0.028461538461538469,-0.046153846153846149,0.55153846153846153,0.78461538461538449,71.5,122.5,88.5,149.5
52,0.59999999999999998,0.033846153846153818,-0.046153846153846149,0.52615384615384608,0.78461538461538449,106.5,122.5,122.5,149.5
53,0.59999999999999998,0.033461538461538466,-0.046153846153846149,0.55653846153846154,0.78461538461538449,123.5,122.5,140.5,149.5
54,0.59999999999999998,0.023076923076923016,-0.046153846153846149,0.57692307692307676,0.78461538461538449,141.5,122.5,159.5,149.5
55,0.59999999999999998,0.037076923076923042,-0.046153846153846149,0.59092307692307677,0.78461538461538449,160.5,122.5,178.5,149.5
56,0.59999999999999998,0.02307692307692303,-0.046153846153846149,0.57692307692307676,0.78461538461538449,135.5,94.5,153.5,121.5
57,0.59999999999999998,0.023076923076923016,-0.046153846153846149,0.57692307692307676,0.78461538461538449,33.5,38.5,51.5,65.5
58,0.59999999999999998,0.17692307692307693,-0.046153846153846149,0.42307692307692307,0.59999999999999987,116.5,44.5,124.5,65.5
59,0.59999999999999998,0.17192307692307693,-0.20000000000000001,0.41807692307692307,0.59999999999999998,71.5,39.5,79.5,65.5
60,0.59999999999999998,0.053846153846153842,0.015384615384615384,0.5461538461538461,0.63076923076923075,109.5,17.5,125.5,37.5
61,0.59999999999999998,0.053846153846153842,0.13846153846153847,0.5461538461538461,0.53846153846153844,14.5,2.5,30.5,15.5
62,0.59999999999999998,0.053846153846153842,0.015384615384615384,0.5461538461538461,0.63076923076923075,126.5,17.5,142.5,37.5
63,0.59999999999999998,0.092115384615384613,-0.046153846153846149,0.52288461538461539,0.78461538461538449,0.5,38.5,14.5,65.5
64,0.59999999999999998,0.010192307692307648,-0.23076923076923075,0.59480769230769226,0.78461538461538449,157.5,182.5,176.5,215.5
65,0.59999999999999998,0.0076923076923076364,-0.046153846153846149,0.59230769230769231,0.78461538461538449,196.5,122.5,215.5,149.5
66,0.59999999999999998,0.049961538461538467,-0.046153846153846149,0.57303846153846161,0.78461538461538449,156.5,66.5,173.5,93.5
67,0.59999999999999998,0.060846153846153841,-0.046153846153846149,0.55315384615384611,0.78461538461538449,139.5,66.5,155.5,93.5
68,0.59999999999999998,0.055846153846153823,-0.046153846153846149,0.5481538461538461,0.78461538461538449,122.5,66.5,138.5,93.5
69,0.59999999999999998,0.06384615384615383,-0.046153846153846149,0.55615384615384611,0.78461538461538449,105.5,66.5,121.5,93.5
70,0.59999999999999998,0.063846153846153844,-0.046153846153846149,0.55615384615384611,0.78461538461538449,88.5,66.5,104.5,93.5
71,0.59999999999999998,0.056846153846153838,-0.046153846153846149,0.5491538461538461,0.78461538461538449,71.5,66.5,87.5,93.5
72,0.59999999999999998,0.053846153846153814,-0.046153846153846149,0.5461538461538461,0.78461538461538449,54.5,66.5,70.5,93.5
73,0.59999999999999998,0.069230769230769207,-0.046153846153846149,0.53076923076923077,0.78461538461538449,200.5,151.5,215.5,178.5
74,0.59999999999999998,0.0084615384615384596,-0.046153846153846149,0.53153846153846152,0.78461538461538449,19.5,66.5,36.5,93.5
75,0.59999999999999998,0.049076923076923039,-0.046153846153846149,0.60292307692307678,0.78461538461538449,0.5,66.5,18.5,93.5
76,0.59999999999999998,0.093846153846153829,-0.046153846153846149,0.58615384615384614,0.78461538461538449,194.5,66.5,210.5,93.5
77,0.59999999999999998,0.038461538461538408,-0.046153846153846149,0.56153846153846143,0.78461538461538449,15.5,38.5,32.5,65.5
78,0.59999999999999998,0.053846153846153828,-0.046153846153846149,0.5461538461538461,0.78461538461538449,189.5,94.5,205.5,121.5
79,0.59999999999999998,0.053846153846153842,-0.046153846153846149,0.5461538461538461,0.78461538461538449,172.5,94.5,188.5,121.5
80,0.59999999999999998,0.059461538461538427,-0.046153846153846149,0.58253846153846145,0.78461538461538449,154.5,94.5,171.5,121.5
81,0.59999999999999998,0.041461538461538418,-0.23076923076923075,0.56453846153846143,0.78461538461538449,177.5,182.5,194.5,215.5
82,0.59999999999999998,0.057461538461538425,-0.046153846153846149,0.58053846153846145,0.78461538461538449,117.5,94.5,134.5,121.5
83,0.59999999999999998,0.038461538461538408,-0.046153846153846149,0.56153846153846143,0.78461538461538449,99.5,94.5,116.5,121.5
84,0.59999999999999998,0.02307692307692303,-0.046153846153846149,0.57692307692307676,0.78461538461538449,80.5,94.5,98.5,121.5
85,0.59999999999999998,0.053846153846153828,-0.046153846153846149,0.5461538461538461,0.78461538461538449,63.5,94.5,79.5,121.5
86,0.59999999999999998,0.0076923076923076364,-0.046153846153846149,0.59230769230769231,0.78461538461538449,43.5,94.5,62.5,121.5
87,0.59999999999999998,-0.023076923076923141,-0.046153846153846149,0.62307692307692286,0.78461538461538449,21.5,94.5,42.5,121.5
88,0.59999999999999998,0.0076923076923076684,-0.046153846153846149,0.59230769230769231,0.78461538461538449,174.5,66.5,193.5,93.5
89,0.59999999999999998,-0.0076923076923077257,-0.046153846153846149,0.60769230769230764,0.78461538461538449,0.5,94.5,20.5,121.5
90,0.59999999999999998,0.053846153846153842,-0.046153846153846149,0.5461538461538461,0.78461538461538449,179.5,122.5,195.5,149.5
91,0.59999999999999998,0.17365384615384616,-0.16923076923076924,0.48134615384615381,0.87692307692307681,102.5,181.5,112.5,215.5
92,0.59999999999999998,0.038461538461538457,-0.16923076923076924,0.56153846153846154,0.87692307692307681,113.5,181.5,130.5,215.5
93,0.59999999999999998,0.11865384615384617,-0.16923076923076924,0.42634615384615382,0.87692307692307681,131.5,181.5,141.5,215.5
94,0.59999999999999998,0.038461538461538471,0.29230769230769227,0.56153846153846154,0.78461538461538449,183.5,21.5,200.5,37.5
95,0.59999999999999998,0.02307692307692304,-0.13846153846153847,0.57692307692307676,0.015384615384615387,195.5,182.5,213.5,187.5
96,0.59999999999999998,0.12853846153846155,0.59999999999999998,0.40546153846153848,0.84615384615384626,206.5,113.5,215.5,121.5
97,0.59999999999999998,0.025961538461538449,-0.046153846153846149,0.54903846153846159,0.59999999999999987,18.5,16.5,35.5,37.5
98,0.59999999999999998,0.056346153846153824,-0.046153846153846149,0.54865384615384605,0.78461538461538449,36.5,122.5,52.5,149.5
99,0.59999999999999998,0.043961538461538448,-0.046153846153846149,0.5670384615384616,0.59999999999999987,36.5,16.5,53.5,37.5
100,0.59999999999999998,0.051346153846153826,-0.046153846153846149,0.54365384615384604,0.78461538461538449,37.5,66.5,53.5,93.5
101,0.59999999999999998,0.038461538461538436,-0.046153846153846149,0.56153846153846154,0.59999999999999987,74.5,16.5,91.5,37.5
102,0.59999999999999998,0.01557692307692302,-0.046153846153846149,0.56942307692307681,0.78461538461538449,181.5,151.5,199.5,178.5
103,0.59999999999999998,0.05134615384615384,-0.23076923076923075,0.54365384615384604,0.59999999999999998,164.5,151.5,180.5,178.5
104,0.59999999999999998,0.054846153846153829,-0.046153846153846149,0.5471538461538461,0.78461538461538449,147.5,151.5,163.5,178.5
105,0.59999999999999998,0.043076923076923054,-0.046153846153846149,0.59692307692307678,0.81538461538461526,0.5,150.5,18.5,178.5
106,0.59999999999999998,0.052615384615384626,-0.23076923076923075,0.48338461538461536,0.81538461538461526,142.5,181.5,156.5,215.5
107,0.59999999999999998,0.051076923076923027,-0.046153846153846149,0.60492307692307679,0.78461538461538449,86.5,151.5,104.5,178.5
108,0.59999999999999998,-0.0023076923076923313,-0.046153846153846149,0.5823076923076923,0.78461538461538449,66.5,151.5,85.5,178.5
109,0.59999999999999998,0.02307692307692304,-0.046153846153846149,0.57692307692307676,0.59999999999999987,97.5,44.5,115.5,65.5
110,0.59999999999999998,0.054846153846153829,-0.046153846153846149,0.5471538461538461,0.59999999999999987,80.5,44.5,96.5,65.5
111,0.59999999999999998,0.038461538461538436,-0.046153846153846149,0.56153846153846154,0.59999999999999987,0.5,16.5,17.5,37.5
112,0.59999999999999998,0.056346153846153824,-0.23076923076923075,0.54865384615384605,0.59999999999999998,89.5,122.5,105.5,149.5
113,0.59999999999999998,0.051346153846153826,-0.23076923076923075,0.54365384615384604,0.59999999999999998,27.5,151.5,43.5,178.5
114,0.59999999999999998,0.074846153846153826,-0.046153846153846149,0.56715384615384612,0.59999999999999987,125.5,44.5,141.5,65.5
115,0.59999999999999998,0.053846153846153842,-0.046153846153846149,0.5461538461538461,0.59999999999999987,92.5,16.5,108.5,37.5
116,0.59999999999999998,0.0065769230769230557,-0.046153846153846149,0.5604230769230768,0.75384615384615383,52.5,39.5,70.5,65.5
117,0.59999999999999998,0.053846153846153828,-0.046153846153846149,0.5461538461538461,0.59999999999999987,182.5,44.5,198.5,65.5
118,0.59999999999999998,0.023076923076923054,-0.046153846153846149,0.57692307692307676,0.59999999999999987,163.5,44.5,181.5,65.5
119,0.59999999999999998,-0.0076923076923077578,-0.046153846153846149,0.60769230769230764,0.59999999999999987,142.5,44.5,162.5,65.5
120,0.59999999999999998,0.0076923076923076364,-0.046153846153846149,0.59230769230769231,0.59999999999999987,54.5,16.5,73.5,37.5
121,0.59999999999999998,0.023076923076923054,-0.23076923076923075,0.57692307692307676,0.59999999999999998,128.5,151.5,146.5,178.5
122,0.59999999999999998,0.053846153846153828,-0.046153846153846149,0.5461538461538461,0.59999999999999987,199.5,44.5,215.5,65.5
123,0.59999999999999998,0.04384615384615384,-0.16923076923076924,0.53615384615384609,0.87692307692307681,54.5,181.5,70.5,215.5
124,0.59999999999999998,0.22307692307692309,-0.16923076923076924,0.37692307692307692,0.87692307692307681,48.5,181.5,53.5,215.5
125,0.59999999999999998,0.063846153846153844,-0.16923076923076924,0.55615384615384611,0.87692307692307681,31.5,181.5,47.5,215.5
126,0.59999999999999998,0.038461538461538394,0.20000000000000001,0.56153846153846143,0.50769230769230766,38.5,5.5,55.5,15.5
1 32 0.59999999999999998 0 0 0 0 0 0 0 0
2 33 0.59999999999999998 0.19230769230769232 -0.046153846153846149 0.40769230769230769 0.78461538461538449 19.5 151.5 26.5 178.5
3 34 0.59999999999999998 0.10000000000000001 0.38461538461538458 0.5 0.78461538461538449 0.5 2.5 13.5 15.5
4 35 0.59999999999999998 -0.0076923076923077257 -0.046153846153846149 0.60769230769230764 0.78461538461538449 195.5 188.5 215.5 215.5
5 36 0.59999999999999998 0.038461538461538408 -0.20000000000000001 0.56153846153846143 0.90769230769230758 0.5 179.5 17.5 215.5
6 37 0.59999999999999998 -0.023076923076923134 -0.046153846153846149 0.62307692307692286 0.78461538461538449 44.5 151.5 65.5 178.5
7 38 0.59999999999999998 -0.018461538461538505 -0.046153846153846149 0.65846153846153832 0.78461538461538449 105.5 151.5 127.5 178.5
8 39 0.59999999999999998 0.2076923076923077 0.38461538461538458 0.39230769230769225 0.78461538461538449 31.5 2.5 37.5 15.5
9 40 0.59999999999999998 0.15038461538461537 -0.16923076923076924 0.51961538461538459 0.87692307692307681 18.5 181.5 30.5 215.5
10 41 0.59999999999999998 0.080384615384615388 -0.16923076923076924 0.44961538461538458 0.87692307692307681 71.5 181.5 83.5 215.5
11 42 0.59999999999999998 -0.0076923076923077465 0.046153846153846149 0.60769230769230764 0.66153846153846141 143.5 17.5 163.5 37.5
12 43 0.59999999999999998 0.023076923076923054 0.046153846153846149 0.57692307692307676 0.59999999999999987 164.5 19.5 182.5 37.5
13 44 0.59999999999999998 0.16842307692307693 -0.20000000000000001 0.41457692307692307 0.19999999999999998 206.5 99.5 214.5 112.5
14 45 0.59999999999999998 0.10000000000000001 0.23076923076923078 0.5 0.41538461538461535 201.5 31.5 214.5 37.5
15 46 0.59999999999999998 0.17692307692307693 -0.046153846153846149 0.42307692307692307 0.19999999999999996 201.5 22.5 209.5 30.5
16 47 0.59999999999999998 0.038461538461538457 -0.16923076923076924 0.56153846153846154 0.87692307692307681 84.5 181.5 101.5 215.5
17 48 0.59999999999999998 0.038461538461538471 -0.046153846153846149 0.56153846153846154 0.78461538461538449 0.5 122.5 17.5 149.5
18 49 0.59999999999999998 0.053461538461538456 -0.046153846153846149 0.57653846153846156 0.78461538461538449 18.5 122.5 35.5 149.5
19 50 0.59999999999999998 0.039961538461538437 -0.046153846153846149 0.5630384615384616 0.78461538461538449 53.5 122.5 70.5 149.5
20 51 0.59999999999999998 0.028461538461538469 -0.046153846153846149 0.55153846153846153 0.78461538461538449 71.5 122.5 88.5 149.5
21 52 0.59999999999999998 0.033846153846153818 -0.046153846153846149 0.52615384615384608 0.78461538461538449 106.5 122.5 122.5 149.5
22 53 0.59999999999999998 0.033461538461538466 -0.046153846153846149 0.55653846153846154 0.78461538461538449 123.5 122.5 140.5 149.5
23 54 0.59999999999999998 0.023076923076923016 -0.046153846153846149 0.57692307692307676 0.78461538461538449 141.5 122.5 159.5 149.5
24 55 0.59999999999999998 0.037076923076923042 -0.046153846153846149 0.59092307692307677 0.78461538461538449 160.5 122.5 178.5 149.5
25 56 0.59999999999999998 0.02307692307692303 -0.046153846153846149 0.57692307692307676 0.78461538461538449 135.5 94.5 153.5 121.5
26 57 0.59999999999999998 0.023076923076923016 -0.046153846153846149 0.57692307692307676 0.78461538461538449 33.5 38.5 51.5 65.5
27 58 0.59999999999999998 0.17692307692307693 -0.046153846153846149 0.42307692307692307 0.59999999999999987 116.5 44.5 124.5 65.5
28 59 0.59999999999999998 0.17192307692307693 -0.20000000000000001 0.41807692307692307 0.59999999999999998 71.5 39.5 79.5 65.5
29 60 0.59999999999999998 0.053846153846153842 0.015384615384615384 0.5461538461538461 0.63076923076923075 109.5 17.5 125.5 37.5
30 61 0.59999999999999998 0.053846153846153842 0.13846153846153847 0.5461538461538461 0.53846153846153844 14.5 2.5 30.5 15.5
31 62 0.59999999999999998 0.053846153846153842 0.015384615384615384 0.5461538461538461 0.63076923076923075 126.5 17.5 142.5 37.5
32 63 0.59999999999999998 0.092115384615384613 -0.046153846153846149 0.52288461538461539 0.78461538461538449 0.5 38.5 14.5 65.5
33 64 0.59999999999999998 0.010192307692307648 -0.23076923076923075 0.59480769230769226 0.78461538461538449 157.5 182.5 176.5 215.5
34 65 0.59999999999999998 0.0076923076923076364 -0.046153846153846149 0.59230769230769231 0.78461538461538449 196.5 122.5 215.5 149.5
35 66 0.59999999999999998 0.049961538461538467 -0.046153846153846149 0.57303846153846161 0.78461538461538449 156.5 66.5 173.5 93.5
36 67 0.59999999999999998 0.060846153846153841 -0.046153846153846149 0.55315384615384611 0.78461538461538449 139.5 66.5 155.5 93.5
37 68 0.59999999999999998 0.055846153846153823 -0.046153846153846149 0.5481538461538461 0.78461538461538449 122.5 66.5 138.5 93.5
38 69 0.59999999999999998 0.06384615384615383 -0.046153846153846149 0.55615384615384611 0.78461538461538449 105.5 66.5 121.5 93.5
39 70 0.59999999999999998 0.063846153846153844 -0.046153846153846149 0.55615384615384611 0.78461538461538449 88.5 66.5 104.5 93.5
40 71 0.59999999999999998 0.056846153846153838 -0.046153846153846149 0.5491538461538461 0.78461538461538449 71.5 66.5 87.5 93.5
41 72 0.59999999999999998 0.053846153846153814 -0.046153846153846149 0.5461538461538461 0.78461538461538449 54.5 66.5 70.5 93.5
42 73 0.59999999999999998 0.069230769230769207 -0.046153846153846149 0.53076923076923077 0.78461538461538449 200.5 151.5 215.5 178.5
43 74 0.59999999999999998 0.0084615384615384596 -0.046153846153846149 0.53153846153846152 0.78461538461538449 19.5 66.5 36.5 93.5
44 75 0.59999999999999998 0.049076923076923039 -0.046153846153846149 0.60292307692307678 0.78461538461538449 0.5 66.5 18.5 93.5
45 76 0.59999999999999998 0.093846153846153829 -0.046153846153846149 0.58615384615384614 0.78461538461538449 194.5 66.5 210.5 93.5
46 77 0.59999999999999998 0.038461538461538408 -0.046153846153846149 0.56153846153846143 0.78461538461538449 15.5 38.5 32.5 65.5
47 78 0.59999999999999998 0.053846153846153828 -0.046153846153846149 0.5461538461538461 0.78461538461538449 189.5 94.5 205.5 121.5
48 79 0.59999999999999998 0.053846153846153842 -0.046153846153846149 0.5461538461538461 0.78461538461538449 172.5 94.5 188.5 121.5
49 80 0.59999999999999998 0.059461538461538427 -0.046153846153846149 0.58253846153846145 0.78461538461538449 154.5 94.5 171.5 121.5
50 81 0.59999999999999998 0.041461538461538418 -0.23076923076923075 0.56453846153846143 0.78461538461538449 177.5 182.5 194.5 215.5
51 82 0.59999999999999998 0.057461538461538425 -0.046153846153846149 0.58053846153846145 0.78461538461538449 117.5 94.5 134.5 121.5
52 83 0.59999999999999998 0.038461538461538408 -0.046153846153846149 0.56153846153846143 0.78461538461538449 99.5 94.5 116.5 121.5
53 84 0.59999999999999998 0.02307692307692303 -0.046153846153846149 0.57692307692307676 0.78461538461538449 80.5 94.5 98.5 121.5
54 85 0.59999999999999998 0.053846153846153828 -0.046153846153846149 0.5461538461538461 0.78461538461538449 63.5 94.5 79.5 121.5
55 86 0.59999999999999998 0.0076923076923076364 -0.046153846153846149 0.59230769230769231 0.78461538461538449 43.5 94.5 62.5 121.5
56 87 0.59999999999999998 -0.023076923076923141 -0.046153846153846149 0.62307692307692286 0.78461538461538449 21.5 94.5 42.5 121.5
57 88 0.59999999999999998 0.0076923076923076684 -0.046153846153846149 0.59230769230769231 0.78461538461538449 174.5 66.5 193.5 93.5
58 89 0.59999999999999998 -0.0076923076923077257 -0.046153846153846149 0.60769230769230764 0.78461538461538449 0.5 94.5 20.5 121.5
59 90 0.59999999999999998 0.053846153846153842 -0.046153846153846149 0.5461538461538461 0.78461538461538449 179.5 122.5 195.5 149.5
60 91 0.59999999999999998 0.17365384615384616 -0.16923076923076924 0.48134615384615381 0.87692307692307681 102.5 181.5 112.5 215.5
61 92 0.59999999999999998 0.038461538461538457 -0.16923076923076924 0.56153846153846154 0.87692307692307681 113.5 181.5 130.5 215.5
62 93 0.59999999999999998 0.11865384615384617 -0.16923076923076924 0.42634615384615382 0.87692307692307681 131.5 181.5 141.5 215.5
63 94 0.59999999999999998 0.038461538461538471 0.29230769230769227 0.56153846153846154 0.78461538461538449 183.5 21.5 200.5 37.5
64 95 0.59999999999999998 0.02307692307692304 -0.13846153846153847 0.57692307692307676 0.015384615384615387 195.5 182.5 213.5 187.5
65 96 0.59999999999999998 0.12853846153846155 0.59999999999999998 0.40546153846153848 0.84615384615384626 206.5 113.5 215.5 121.5
66 97 0.59999999999999998 0.025961538461538449 -0.046153846153846149 0.54903846153846159 0.59999999999999987 18.5 16.5 35.5 37.5
67 98 0.59999999999999998 0.056346153846153824 -0.046153846153846149 0.54865384615384605 0.78461538461538449 36.5 122.5 52.5 149.5
68 99 0.59999999999999998 0.043961538461538448 -0.046153846153846149 0.5670384615384616 0.59999999999999987 36.5 16.5 53.5 37.5
69 100 0.59999999999999998 0.051346153846153826 -0.046153846153846149 0.54365384615384604 0.78461538461538449 37.5 66.5 53.5 93.5
70 101 0.59999999999999998 0.038461538461538436 -0.046153846153846149 0.56153846153846154 0.59999999999999987 74.5 16.5 91.5 37.5
71 102 0.59999999999999998 0.01557692307692302 -0.046153846153846149 0.56942307692307681 0.78461538461538449 181.5 151.5 199.5 178.5
72 103 0.59999999999999998 0.05134615384615384 -0.23076923076923075 0.54365384615384604 0.59999999999999998 164.5 151.5 180.5 178.5
73 104 0.59999999999999998 0.054846153846153829 -0.046153846153846149 0.5471538461538461 0.78461538461538449 147.5 151.5 163.5 178.5
74 105 0.59999999999999998 0.043076923076923054 -0.046153846153846149 0.59692307692307678 0.81538461538461526 0.5 150.5 18.5 178.5
75 106 0.59999999999999998 0.052615384615384626 -0.23076923076923075 0.48338461538461536 0.81538461538461526 142.5 181.5 156.5 215.5
76 107 0.59999999999999998 0.051076923076923027 -0.046153846153846149 0.60492307692307679 0.78461538461538449 86.5 151.5 104.5 178.5
77 108 0.59999999999999998 -0.0023076923076923313 -0.046153846153846149 0.5823076923076923 0.78461538461538449 66.5 151.5 85.5 178.5
78 109 0.59999999999999998 0.02307692307692304 -0.046153846153846149 0.57692307692307676 0.59999999999999987 97.5 44.5 115.5 65.5
79 110 0.59999999999999998 0.054846153846153829 -0.046153846153846149 0.5471538461538461 0.59999999999999987 80.5 44.5 96.5 65.5
80 111 0.59999999999999998 0.038461538461538436 -0.046153846153846149 0.56153846153846154 0.59999999999999987 0.5 16.5 17.5 37.5
81 112 0.59999999999999998 0.056346153846153824 -0.23076923076923075 0.54865384615384605 0.59999999999999998 89.5 122.5 105.5 149.5
82 113 0.59999999999999998 0.051346153846153826 -0.23076923076923075 0.54365384615384604 0.59999999999999998 27.5 151.5 43.5 178.5
83 114 0.59999999999999998 0.074846153846153826 -0.046153846153846149 0.56715384615384612 0.59999999999999987 125.5 44.5 141.5 65.5
84 115 0.59999999999999998 0.053846153846153842 -0.046153846153846149 0.5461538461538461 0.59999999999999987 92.5 16.5 108.5 37.5
85 116 0.59999999999999998 0.0065769230769230557 -0.046153846153846149 0.5604230769230768 0.75384615384615383 52.5 39.5 70.5 65.5
86 117 0.59999999999999998 0.053846153846153828 -0.046153846153846149 0.5461538461538461 0.59999999999999987 182.5 44.5 198.5 65.5
87 118 0.59999999999999998 0.023076923076923054 -0.046153846153846149 0.57692307692307676 0.59999999999999987 163.5 44.5 181.5 65.5
88 119 0.59999999999999998 -0.0076923076923077578 -0.046153846153846149 0.60769230769230764 0.59999999999999987 142.5 44.5 162.5 65.5
89 120 0.59999999999999998 0.0076923076923076364 -0.046153846153846149 0.59230769230769231 0.59999999999999987 54.5 16.5 73.5 37.5
90 121 0.59999999999999998 0.023076923076923054 -0.23076923076923075 0.57692307692307676 0.59999999999999998 128.5 151.5 146.5 178.5
91 122 0.59999999999999998 0.053846153846153828 -0.046153846153846149 0.5461538461538461 0.59999999999999987 199.5 44.5 215.5 65.5
92 123 0.59999999999999998 0.04384615384615384 -0.16923076923076924 0.53615384615384609 0.87692307692307681 54.5 181.5 70.5 215.5
93 124 0.59999999999999998 0.22307692307692309 -0.16923076923076924 0.37692307692307692 0.87692307692307681 48.5 181.5 53.5 215.5
94 125 0.59999999999999998 0.063846153846153844 -0.16923076923076924 0.55615384615384611 0.87692307692307681 31.5 181.5 47.5 215.5
95 126 0.59999999999999998 0.038461538461538394 0.20000000000000001 0.56153846153846143 0.50769230769230766 38.5 5.5 55.5 15.5

1
assets/msdf.json Normal file

File diff suppressed because one or more lines are too long

BIN
assets/slug/slug.frag.spv Normal file

Binary file not shown.

BIN
assets/slug/slug.vert.spv Normal file

Binary file not shown.

View File

@ -3,29 +3,18 @@ set -eu
# SHADERS
shader_compiler="glslc"
shader_flags="-std=460 -O --target-env=vulkan1.2 -g"
shader_out="-oassets/"
shader_compiler="glslang"
shader_flags="--target-env vulkan1.2 -gVS"
shader_out="-o assets/"
mkdir -p build
mkdir -p assets
for shader in src/shaders/*.glsl; do
base_name=$(basename -- "$shader" .glsl)
case "$base_name" in
*.vert) shader_stage="-fshader-stage=vert" ;;
*.frag) shader_stage="-fshader-stage=frag" ;;
*.tesc) shader_stage="-fshader-stage=tesc" ;;
*.tese) shader_stage="-fshader-stage=tese" ;;
*.geom) shader_stage="-fshader-stage=geom" ;;
*.comp) shader_stage="-fshader-stage=comp" ;;
*) continue ;;
esac
$shader_compiler $shader_flags $shader_stage $shader "${shader_out}${base_name}.spv"
$shader_compiler $shader_flags $shader_out${base_name}.spv $shader
done
#/bin/bash src/VulkanRenderer/build.sh build
/bin/bash src/VulkanRenderer/build.sh build
/bin/bash src/dlib/build.sh build

BIN
frag.spv Normal file

Binary file not shown.

@ -1 +1 @@
Subproject commit b7674e43bde4661dac2a11092826079c57a4d66c
Subproject commit 245db6ea6fe787e91839dd78f92dda007e234f7c

@ -1 +1 @@
Subproject commit 8690e93b41ffe7bba528b76dfa749ee4bb6f28d5
Subproject commit 6ae59dab5bca9d44fdf4a7f517654b1c0f8545f1

View File

@ -24,12 +24,13 @@ struct RenderCtx
Descriptor[FS] font_descs;
Descriptor default_tex;
Descriptor sampler;
Descriptor msdf_texture;
Pipeline pipeline;
Pipeline slug_pipeline;
DescSetLayout desc_set_layout;
DescSet[FO] desc_sets;
PipelineLayout pipeline_layout;
PushConst pc;
Vec2 res;
}
struct Ctx
@ -54,14 +55,19 @@ struct Ctx
LinkedList!(UIInput) events;
IVec2 mouse_pos;
SlugFont slug_font;
FontFace font;
FontSet[FS] font_sets;
u32 font_sets_used;
bool[FO] fonts_to_load;
bool prev_has_tex;
u32 prev_atlas_index;
u32 prev_atlas_index;
UIBuffer[FO] buffers;
SlugBuffer[FO] slug_buffers;
MappedBuffer!(SlugVertex)[FO] slug_vertex_buffers;
MappedBuffer!(u32)[FO] slug_index_buffers;
u32 tab_width;
Vec4[TS.max][UISH.max] syntax_colors;

View File

@ -43,11 +43,12 @@ void main(string[] argv)
}
Vec2 current_res = Vec2(window.w, window.h);
if(g_ctx.res != current_res)
if(g_ctx.pc.resolution != current_res)
{
SetExtent(window.w, window.h);
g_ctx.res = current_res;
g_ctx.pc.resolution = current_res;
Ortho(&g_ctx.pc.projection, 0.0, 0.0, current_res.x, current_res.y, -10.0, 10.0);
UpdateMSDFShaderInfo(&g_ctx.pc, g_ctx.pc.resolution);
}
if(inputs.first == null)

View File

@ -60,9 +60,9 @@ const f32 CORNER_RADIUS = 8.0;
//u8[] FONT_BYTES = Arr!(u8)(import("pc-9800.ttf"));
//u8[] FONT_BYTES = Arr!(u8)(import("NuberNextCondensed-DemiBold.otf"));
u8[] FONT_BYTES = cast(u8[])import("jetbrains-mono/JetBrainsMono-Regular.ttf");
u8[] VERTEX_BYTES = cast(u8[])import("gui.vert.spv");
u8[] FRAGMENT_BYTES = cast(u8[])import("gui.frag.spv");
u8[] FONT_BYTES = cast(u8[])import("jetbrains-mono/JetBrainsMono-Regular.ttf");
u8[] VERTEX_BYTES = cast(u8[])import("gui.vert.spv");
u8[] FRAGMENT_BYTES = cast(u8[])import("gui.frag.spv");
const SEP_FLAGS = UIF.Drag|UIF.Priority|UIF.TargetLeniency;
const PANEL_FLAGS = UIF.Click|UIF.Drag;
@ -179,7 +179,12 @@ enum ItemStateFlags
struct PushConst
{
Mat4 projection;
Vec2 resolution;
Vec2 aem_range;
u32 atlas_index;
f32 threshold_em;
f32 antialias_per_em;
f32 distance_range;
}
enum FO = FRAME_OVERLAP;
@ -288,6 +293,19 @@ struct UIPanel
alias item this;
}
void
UpdateMSDFShaderInfo(PushConst* pc, Vec2 resolution)
{
const f32 AA_PIXEL_SIZE = 1.0;
f32 aa_in_em = AA_PIXEL_SIZE * resolution.x / MSDF_INFO.pixels_per_em;
pc.antialias_per_em = 1.0 / aa_in_em;
pc.aem_range = MSDF_INFO.aem_range;
pc.threshold_em = 0.0;
pc.distance_range = MSDF_INFO.distance_field_range;
}
struct Window
{
Window* next, prev;
@ -305,16 +323,16 @@ enum SettingType
}
Attribute[10] attributes = [
{ binding: 0, location: 0, format: FMT.RGBA_F32, offset: Vertex.cols.offsetof },
{ binding: 0, location: 1, format: FMT.RGBA_F32, offset: Vertex.corner_radius.offsetof },
{ binding: 0, location: 2, format: FMT.RG_F32, offset: Vertex.dst_start.offsetof },
{ binding: 0, location: 3, format: FMT.RG_F32, offset: Vertex.dst_end.offsetof },
{ binding: 0, location: 4, format: FMT.RG_F32, offset: Vertex.src_start.offsetof },
{ binding: 0, location: 5, format: FMT.RG_F32, offset: Vertex.src_end.offsetof },
{ binding: 0, location: 6, format: FMT.R_F32, offset: Vertex.border_thickness.offsetof },
{ binding: 0, location: 7, format: FMT.R_F32, offset: Vertex.edge_softness.offsetof },
{ binding: 0, location: 8, format: FMT.R_F32, offset: Vertex.raised.offsetof },
{ binding: 0, location: 9, format: FMT.R_U32, offset: Vertex.has_texture.offsetof },
{ binding: 0, location: 0, format: FMT.RGBA_F32, offset: Vertex.cols.offsetof },
{ binding: 0, location: 1, format: FMT.RGBA_F32, offset: Vertex.corner_radius.offsetof },
{ binding: 0, location: 2, format: FMT.RG_F32, offset: Vertex.dst_start.offsetof },
{ binding: 0, location: 3, format: FMT.RG_F32, offset: Vertex.dst_end.offsetof },
{ binding: 0, location: 4, format: FMT.RG_F32, offset: Vertex.src_start.offsetof },
{ binding: 0, location: 5, format: FMT.RG_F32, offset: Vertex.src_end.offsetof },
{ binding: 0, location: 6, format: FMT.R_F32, offset: Vertex.border_thickness.offsetof },
{ binding: 0, location: 7, format: FMT.R_F32, offset: Vertex.edge_softness.offsetof },
{ binding: 0, location: 8, format: FMT.R_F32, offset: Vertex.raised.offsetof },
{ binding: 0, location: 9, format: FMT.R_U32, offset: Vertex.has_texture.offsetof },
];
union Rect
@ -336,6 +354,226 @@ struct UIKey
bool opCast(T)() if(is(T == bool)) => this.hash != 0;
}
/*
"atlas": {
"type": "mtsdf",
"distanceRange": 2,
"distanceRangeMiddle": 0,
"size": 32.5,
"width": 216,
"height": 216,
"yOrigin": "bottom"
},
"metrics": {
"emSize": 1,
"lineHeight": 1.3200000000000001,
"ascender": 1.02,
"descender": -0.29999999999999999,
"underlineY": -0.17999999999999999,
"underlineThickness": 0.050000000000000003
},
"glyphs": [
{
"unicode": 32,
"advance": 0.59999999999999998
},
{
"unicode": 33,
"advance": 0.59999999999999998,
"planeBounds": {
"left": 0.19230769230769232,
"bottom": -0.046153846153846149,
"right": 0.40769230769230769,
"top": 0.78461538461538449
},
"atlasBounds": {
"left": 19.5,
"bottom": 151.5,
"right": 26.5,
"top": 178.5
}
},
*/
enum MSDFType
{
None,
HardMask,
SoftMask,
SDF,
PSDF,
MSDF,
MTSDF,
}
enum MSDFYOrigin
{
None,
Left,
Bottom,
Right,
Top,
}
struct MSDFInfo
{
MSDFGlyph[] glyphs;
MSDFType type;
Vec2 aem_range;
u32 distance_field_range;
u32 distance_field_range_middle;
f32 pixels_per_em;
u32 texture_width;
u32 texture_height;
MSDFYOrigin y_origin;
f32 line_height; // EM
f32 ascender; // EM
f32 descender; // EM
f32 underline_y; // EM
f32 underline_thickness; // EM
}
struct MSDFBounds
{
f32 left = 0.0, bottom = 0.0, right = 0.0, top = 0.0;
}
struct MSDFGlyph
{
dchar glyph = 0;
f32 advance = 0.0;
MSDFBounds plane; // EM
MSDFBounds atlas; // Pixels
}
const u8[] MSDF_ATLAS = cast(u8[])import("msdf-atlas.rgba");
const MSDFInfo MSDF_INFO = GenerateMSDF();
static MSDFInfo
GenerateMSDF()
{
import std.json;
string msdf_json = import("msdf.json");
JSONValue jsonv = parseJSON(msdf_json);
static T GetJSONValue(T)(JSONValue jsonv, string name)
{
static if(is(T == string))
{
T result = "";
}
else
{
T result = cast(T)0;
}
if(const(JSONValue)* value = name in jsonv)
{
switch(value.type())
{
static if(is(T == u32) || is(T == u64) || is(T == f32))
{
case JSONType.float_: result = cast(T)value.floating; break;
case JSONType.uinteger: result = cast(T)value.uinteger; break;
case JSONType.integer: result = cast(T)value.integer; break;
}
static if(is(T == string))
{
case JSONType.string: result = cast(T)value.str; break;
}
default: assert(false, "Unable to retrieve value");
}
}
return result;
}
MSDFInfo result = {
distance_field_range: GetJSONValue!(u32)(jsonv["atlas"], "distanceRange"),
distance_field_range_middle: GetJSONValue!(u32)(jsonv["atlas"], "distanceRangeMiddle"),
pixels_per_em: GetJSONValue!(f32)(jsonv["atlas"], "size"),
texture_width: GetJSONValue!(u32)(jsonv["atlas"], "width"),
texture_height: GetJSONValue!(u32)(jsonv["atlas"], "height"),
line_height: GetJSONValue!(f32)(jsonv["metrics"], "lineHeight"),
ascender: GetJSONValue!(f32)(jsonv["metrics"], "ascender"),
descender: GetJSONValue!(f32)(jsonv["metrics"], "descender"),
underline_y: GetJSONValue!(f32)(jsonv["metrics"], "underlineY"),
underline_thickness: GetJSONValue!(f32)(jsonv["metrics"], "underlineThickness"),
};
result.aem_range = Vec2(
(result.distance_field_range_middle - result.distance_field_range/2) / result.pixels_per_em,
(result.distance_field_range_middle + result.distance_field_range/2) / result.pixels_per_em
);
string type_string = GetJSONValue!(string)(jsonv["atlas"], "type");
string y_origin_string = GetJSONValue!(string)(jsonv["atlas"], "yOrigin");
assert(type_string.length);
assert(y_origin_string.length);
final switch(type_string) with(MSDFType)
{
case "hardmask": result.type = HardMask; break;
case "softmask": result.type = SoftMask; break;
case "sdf": result.type = SDF; break;
case "psdf": result.type = PSDF; break;
case "msdf": result.type = MSDF; break;
case "mtsdf": result.type = MTSDF; break;
}
final switch(y_origin_string) with(MSDFYOrigin)
{
case "top": result.y_origin = Top; break;
case "left": result.y_origin = Left; break;
case "right": result.y_origin = Right; break;
case "bottom": result.y_origin = Bottom; break;
}
MSDFGlyph[] glyphs = new MSDFGlyph[128];
JSONValue[] glyph_json = jsonv["glyphs"].array;
foreach(i; 0 .. glyph_json.length)
{
u64 ch = cast(u64)glyph_json[i]["unicode"].integer;
MSDFGlyph glyph = { glyph: cast(dchar)ch };
glyph.advance = GetJSONValue!(f32)(glyph_json[i], "advance");
if("planeBounds" in glyph_json[i])
{
glyph.plane.left = GetJSONValue!(f32)(glyph_json[i]["planeBounds"], "left");
glyph.plane.right = GetJSONValue!(f32)(glyph_json[i]["planeBounds"], "right");
glyph.plane.bottom = GetJSONValue!(f32)(glyph_json[i]["planeBounds"], "bottom");
glyph.plane.top = GetJSONValue!(f32)(glyph_json[i]["planeBounds"], "top");
glyph.atlas.left = GetJSONValue!(f32)(glyph_json[i]["atlasBounds"], "left");
glyph.atlas.right = GetJSONValue!(f32)(glyph_json[i]["atlasBounds"], "right");
glyph.atlas.bottom = GetJSONValue!(f32)(glyph_json[i]["atlasBounds"], "bottom");
glyph.atlas.top = GetJSONValue!(f32)(glyph_json[i]["atlasBounds"], "top");
}
glyphs[ch] = glyph;
}
foreach(i; 0 .. glyphs.length)
{
if(glyphs[i].glyph == 0xFFFF)
{
glyphs[i].glyph = 0;
glyphs[i].plane = MSDFBounds(left: 0.0, right: 0.0, top: 0.0, bottom: 0.0);
glyphs[i].atlas = MSDFBounds(left: 0.0, right: 0.0, top: 0.0, bottom: 0.0);
}
}
result.glyphs = glyphs;
return result;
}
enum bool KeyType(T) = (StringType!(T) || is(T == UIKey) || is(T == const(UIKey)));
enum bool ItemAndKeyType(T) = (KeyType!(T) || is(T == UIItem*));
@ -362,12 +600,12 @@ InitUI(Ctx* ctx)
UIBuffer[FRAME_OVERLAP] buffers;
ctx.items = CreateHashTable!(UIHash, UIItem*)(12);
ctx.arena = arena;
ctx.temp_arena = CreateArena(MB(1));
ctx.font = OpenFont(cast(u8[])FONT_BYTES);
ctx.tab_width = 2;
ctx.syntax_colors = [DEFAULT_COLORS, SYNTAX_COLORS];
ctx.items = CreateHashTable!(UIHash, UIItem*)(12);
ctx.arena = arena;
ctx.temp_arena = CreateArena(MB(1));
ctx.font = OpenFont(cast(u8[])FONT_BYTES);
ctx.tab_width = 2;
ctx.syntax_colors = [DEFAULT_COLORS, SYNTAX_COLORS];
assert(ctx.font);
@ -375,9 +613,10 @@ InitUI(Ctx* ctx)
{
InitRenderer(handles, MB(16), MB(8));
DescLayoutBinding[2] layout_bindings = [
DescLayoutBinding[3] layout_bindings = [
{ binding: 0, descriptorType: DT.Image, descriptorCount: FONT_SIZES, stageFlags: SS.All },
{ binding: 1, descriptorType: DT.Sampler, descriptorCount: 1, stageFlags: SS.All },
{ binding: 2, descriptorType: DT.Image, descriptorCount: 1, stageFlags: SS.All },
];
ctx.desc_set_layout = CreateDescSetLayout(layout_bindings);
@ -392,6 +631,11 @@ InitUI(Ctx* ctx)
ctx.buffers[i].idx[0 .. $] = [0, 1, 2, 2, 1, 3];
ctx.desc_sets[i] = AllocDescSet(ctx.desc_set_layout);
ctx.str_arenas[i] = CreateArena(MB(1));
ctx.slug_vertex_buffers[i] = CreateMappedBuffer!(SlugVertex)(BT.Vertex, 1000);
ctx.slug_index_buffers[i] = CreateMappedBuffer!(u32)(BT.Index, 1000);
ctx.slug_buffers[i].vertices = ctx.slug_vertex_buffers[i].data;
ctx.slug_buffers[i].indices = ctx.slug_index_buffers[i].data;
}
GfxPipelineInfo ui_info = {
@ -411,6 +655,20 @@ InitUI(Ctx* ctx)
CreateGraphicsPipeline(&ctx.pipeline, &ui_info);
CreateDescriptor(
&ctx.msdf_texture,
DescInfo(
type: DT.Image,
format: FMT.RGBA_UNORM,
usage: IU.Texture,
w: MSDF_INFO.texture_width,
h: MSDF_INFO.texture_height,
ch: 4,
binding: 2,
),
cast(u8[])MSDF_ATLAS[12 .. $]
);
for(u32 i = 0; i < ctx.font_descs.length; i += 1)
{
CreateDescriptor(&ctx.font_descs[i], DescInfo(
@ -428,9 +686,12 @@ InitUI(Ctx* ctx)
}
CreateDescriptor(&ctx.sampler, DescInfo(
type: DT.Sampler,
mipmap_mode: MipmapMode.Nearest,
binding: 1,
type: DT.Sampler,
min_filter: Filter.Nearest,
mag_filter: Filter.Nearest,
enable_anisotropy: true,
mipmap_mode: MipmapMode.Linear,
binding: 1,
));
u8[512*512*4] white_tex = 255;
@ -443,6 +704,7 @@ InitUI(Ctx* ctx)
{
Write(ctx.desc_sets[i], ctx.font_descs);
Write(ctx.desc_sets[i], &ctx.sampler);
Write(ctx.desc_sets[i], &ctx.msdf_texture);
}
SetClearColors([0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 0.0]);
@ -558,10 +820,12 @@ Scissor(Ctx* ctx, Rect rect, Style* style)
f32 b = style.border_thickness + style.border_thickness*style.edge_softness;
i32 x = cast(i32)clamp(floor(rect.p0.x+b), 0.0, ctx.res.x);
i32 y = cast(i32)clamp(floor(rect.p0.y+b), 0.0, ctx.res.y);
i32 w = cast(i32)clamp(floor(rect.p1.x-b) - x, 0.0, ctx.res.x);
i32 h = cast(i32)clamp(floor(rect.p1.y-b) - y, 0.0, ctx.res.y);
Vec2 res = ctx.pc.resolution;
i32 x = cast(i32)clamp(floor(rect.p0.x+b), 0.0, res.x);
i32 y = cast(i32)clamp(floor(rect.p0.y+b), 0.0, res.y);
i32 w = cast(i32)clamp(floor(rect.p1.x-b) - x, 0.0, res.x);
i32 h = cast(i32)clamp(floor(rect.p1.y-b) - y, 0.0, res.y);
SetScissor(x, y, w, h);
}
@ -1477,6 +1741,22 @@ DrawUI(Ctx* ctx, u32 atlas_index)
}
}
void
DrawSlug(Ctx* ctx)
{
version(ENABLE_RENDERER)
{
// TODO: fix this
SlugBuffer* buffer = ctx.slug_buffers.ptr + ctx.f_idx;
auto vertex_buffer = ctx.slug_vertex_buffers.ptr + ctx.f_idx;
auto index_buffer = ctx.slug_index_buffers.ptr + ctx.f_idx;
BindBuffers(index_buffer, vertex_buffer);
DrawIndexed(buffer.quad_offset*6, 1, 0, 0, 0);
}
}
void
DrawUI(Ctx* ctx)
{
@ -1638,9 +1918,15 @@ BeginUI(Inputs* inputs)
Bind(ctx.pipeline, ctx.desc_sets[ctx.f_idx]);
}
memset(ctx.buffers[ctx.f_idx].vtx.ptr, 0, Vertex.sizeof * ctx.buffers[ctx.f_idx].count);
ctx.buffers[ctx.f_idx].count = 0;
ctx.buffers[ctx.f_idx].vtx_offset = 0;
UIBuffer* buffer = ctx.buffers.ptr + ctx.f_idx;
SlugBuffer* slug_buffer = ctx.slug_buffers.ptr + ctx.f_idx;
memset(buffer.vtx.ptr, 0, Vertex.sizeof * buffer.count);
memset(slug_buffer.vertices.ptr, 0, SlugVertex.sizeof * slug_buffer.quad_offset);
buffer.count = 0;
buffer.vtx_offset = 0;
slug_buffer.quad_offset = 0;
}
UIKey
@ -1741,8 +2027,8 @@ SetNil(Args...)(Args args)
void
Clamp(Ctx* ctx, Vertex* v)
{
v.dst_start = Clamp(v.dst_start, Vec2(0.0), cast(Vec2)ctx.res);
v.dst_end = Clamp(v.dst_end, Vec2(0.0), cast(Vec2)ctx.res);
v.dst_start = Clamp(v.dst_start, Vec2(0.0), cast(Vec2)ctx.pc.resolution);
v.dst_end = Clamp(v.dst_end, Vec2(0.0), cast(Vec2)ctx.pc.resolution);
}
bool
@ -1917,7 +2203,7 @@ DrawText(T, U, V)(Ctx* ctx, T text_param, U col_param, V text_size_param, Rect r
}
AnimateReady(ready, &col);
DrawGlyph(rect, g, &x, rect.p0.y, fs.line_height, col);
DrawGlyph(rect, g, &x, rect.p0.y, fs.line_height, fs.size, col);
}
}
else static if(is(U == Vec4))
@ -1929,7 +2215,7 @@ DrawText(T, U, V)(Ctx* ctx, T text_param, U col_param, V text_size_param, Rect r
{
u8 ch = text[j];
Glyph* g = ch < fs.glyphs.length ? fs.glyphs.ptr + ch : null;
DrawGlyph(rect, g, &x, rect.p0.y, fs.line_height, hl_char == j ? InvertCol(col) : col);
DrawGlyph(rect, g, &x, rect.p0.y, fs.line_height, fs.size, hl_char == j ? InvertCol(col) : col);
}
}
else static assert(false, "invalid input parameter, U must be TokenStyle[] or Vec4");
@ -1946,10 +2232,12 @@ BeginScissor(Ctx* ctx, UIItem* item, bool scissor_x = true, bool scissor_y = tru
{
DrawUI(ctx);
i32 x = cast(i32)clamp(scissor_x ? floor(item.rect.p0.x) : 0, 0.0, ctx.res.x);
i32 y = cast(i32)clamp(scissor_y ? floor(item.rect.p0.y) : 0, 0.0, ctx.res.y);
i32 w = cast(i32)clamp(scissor_x ? floor(item.rect.p1.x) - x : ctx.res.x, 0.0, ctx.res.x);
i32 h = cast(i32)clamp(scissor_y ? floor(item.rect.p1.y) - y : ctx.res.y, 0.0, ctx.res.y);
Vec2 res = ctx.pc.resolution;
i32 x = cast(i32)clamp(scissor_x ? floor(item.rect.p0.x) : 0, 0.0, res.x);
i32 y = cast(i32)clamp(scissor_y ? floor(item.rect.p0.y) : 0, 0.0, res.y);
i32 w = cast(i32)clamp(scissor_x ? floor(item.rect.p1.x) - x : res.x, 0.0, res.x);
i32 h = cast(i32)clamp(scissor_y ? floor(item.rect.p1.y) - y : res.y, 0.0, res.y);
SetScissor(x, y, w, h);
@ -2254,11 +2542,13 @@ GlyphWidth(Glyph* g, FontSet* fs)
}
pragma(inline) void
DrawGlyph(Rect rect, Glyph* glyph, f32* x_pos, f32 y, f32 line_height, Vec4 col = Vec4(1.0))
DrawGlyph(Rect rect, Glyph* glyph, f32* x_pos, f32 y, f32 line_height, u32 size, Vec4 col = Vec4(1.0))
{
if(glyph)
{
Ctx* ctx = GetCtx();
const(MSDFGlyph)* msdf_glyph = &MSDF_INFO.glyphs[glyph.ch];
Ctx* ctx = GetCtx();
Vertex* v = null;
f32 advance = glyph.advance;
@ -2279,11 +2569,12 @@ DrawGlyph(Rect rect, Glyph* glyph, f32* x_pos, f32 y, f32 line_height, Vec4 col
f32 y_pos = y + glyph.plane_top;
// Need to change how the quads are calculated, i had changed it so they were all same height and same top/bottom placement as it was easier to draw rasterized glyphs that way but doesn't work when the SDFs are not generated in a similar way
v.dst_start = Vec2(*x_pos+glyph.plane_left, y_pos);
v.dst_end = Vec2(*x_pos+glyph.plane_left+w, y_pos+h);
v.cols = col;
v.src_start = Vec2(glyph.atlas_left, glyph.atlas_top);
v.src_end = Vec2(glyph.atlas_right, glyph.atlas_bottom);
v.src_start = Vec2(glyph.atlas_left, glyph.atlas_top); // Vec2(msdf_glyph.atlas.left, msdf_glyph.atlas.top);
v.src_end = Vec2(glyph.atlas_right, glyph.atlas_bottom); // Vec2(msdf_glyph.atlas.right, msdf_glyph.atlas.bottom);
v.has_texture = true;
f32 end_x = *x_pos + advance;
@ -2329,7 +2620,7 @@ GetVertex(Ctx* ctx)
bool
Nil(T)(T item)
{
static if(is(T == UIItem*)) return item == null || item == g_UI_NIL;
static if(is(T == UIItem*)) return item == null || item == g_UI_NIL;
else static if(is(T == UIInput*)) return item == null || item == g_UI_NIL_INPUT;
else static if(is(T == UIPanel*)) return item == null || item == g_NIL_PANEL;
else static assert(false, "Invalid nil type checked");

View File

@ -7,33 +7,91 @@
#include "gui.layout"
layout (location = 0) FragDataFlat
{
vec2 atlas_size;
uint has_texture;
} FDF;
layout (location = 2) FragData
{
vec4 color;
vec2 uv;
vec2 dst_pos;
vec2 dst_center;
vec2 dst_half_size;
vec2 sdf_sample_pos;
float corner_radius;
float softness;
float raised;
float border_thickness;
} FD;
layout (location = 0) out vec4 FragColor;
float RectSDF(vec2 pos, vec2 half_size, float radius)
float
RectSDF(vec2 pos, vec2 half_size, float radius)
{
return length(max(abs(pos) - half_size + radius, 0.0)) - radius;
}
float ToSRGB(float col)
float
ToSRGB(float col)
{
return pow(col, 1.0/2.2);
}
vec4 ToSRGB(vec4 col)
vec4
ToSRGB(vec4 col)
{
return vec4(ToSRGB(col.r), ToSRGB(col.g), ToSRGB(col.b), col.a);
}
vec4 ToLinear(vec4 col)
vec4
ToLinear(vec4 col)
{
return pow(col, vec4(vec3(2.2), 1.0));
}
float GradientNoise(vec2 uv)
float
GradientNoise(vec2 uv)
{
return fract(52.9829189 * fract(dot(uv, vec2(0.06711056, 0.00583715))));
}
float
Median(vec3 v)
{
return max(min(v.r, v.g), min(max(v.r, v.g), v.b));
}
float
GetMSDFTexel()
{
vec2 dx = 0.25 * dFdx(FD.uv);
vec2 dy = 0.25 * dFdy(FD.uv);
float center = Median(texture(MSDFAtlas, FD.uv).rgb);
float s0 = Median(texture(MSDFAtlas, FD.uv - dx - dy).rgb);
float s1 = Median(texture(MSDFAtlas, FD.uv + dx - dy).rgb);
float s2 = Median(texture(MSDFAtlas, FD.uv - dx + dy).rgb);
float s3 = Median(texture(MSDFAtlas, FD.uv + dx + dy).rgb);
return mix(center, 0.25 * (s0+s1+s2+s3), 0.0);
}
vec2
Square(vec2 x)
{
return x*x;
}
float
ScreenPxRange()
{
vec2 screen_tex_size = vec2(1.0)/fwidth(FD.uv);
return max(0.5*dot(vec2(0.03125), screen_tex_size), 1.0);
}
void main()
{
float softness = FD.softness;
@ -65,19 +123,28 @@ void main()
vec4 inv_gamma = vec4(1.4);
vec4 gamma = vec4(1.0/1.4);
vec4 tex_color = vec4(1.0);
vec4 tex_color = vec4(1.0); // ToLinear(FD.color);
if(FDF.has_texture != 0)
{
tex_color = texture(sampler2D(SpriteAtlas, SamplerNearest), FD.uv);
// old:
tex_color = texture(SpriteAtlas, FD.uv);
/*
float sd = Median(texture(MSDFAtlas, FD.uv).rgb);
float px_range = ScreenPxRange();
float screen_px_dist = ScreenPxRange() * (sd-0.5);
float opacity = clamp(0.5 + screen_px_dist/fwidth(screen_px_dist), 0.0, 1.0);
color.a *= opacity;
*/
}
vec4 color = FD.color; // ToLinear(FD.color);
vec4 out_color = color * tex_color;
vec4 color = FD.color * tex_color;
out_color.a *= corner_factor;
out_color.a *= border_factor;
color.a *= corner_factor;
color.a *= border_factor;
out_color += (1.0 / 255.0) * GradientNoise(gl_FragCoord.xy);
color += (1.0 / 255.0) * GradientNoise(gl_FragCoord.xy);
FragColor = out_color;
FragColor = color;
}

View File

@ -1,15 +1,23 @@
layout (rgba16f, set = 0, binding = 0) uniform image2D DrawImage;
layout (set = 1, binding = 0) uniform texture2D SpriteAtlasArray[24];
layout (set = 1, binding = 1) uniform sampler SamplerNearest;
layout(rgba16f, set = 0, binding = 0) uniform image2D DrawImage;
layout(set = 1, binding = 0) uniform texture2D SpriteAtlasArray[24];
layout(set = 1, binding = 1) uniform sampler SamplerNearest;
layout(set = 1, binding = 2) uniform texture2D MSDFAtlasTexture;
layout (push_constant) uniform Constants {
mat4 projection;
uint atlas_index;
mat4 projection;
vec2 resolution;
vec2 aem_range;
uint atlas_index;
float threshold_em;
float antialias_per_em;
float distance_range;
} PC;
#define SpriteAtlas SpriteAtlasArray[PC.atlas_index]
#define SpriteAtlas sampler2D(SpriteAtlasArray[PC.atlas_index], SamplerNearest)
#define MSDFAtlas sampler2D(MSDFAtlasTexture, SamplerNearest)
#ifdef VERT_SHADER
# define FragData out struct FragDataOut
@ -21,21 +29,3 @@ layout (push_constant) uniform Constants {
# define FragDataFlat flat in struct FragDataFlatIn
#endif
layout (location = 0) FragDataFlat
{
uint has_texture;
} FDF;
layout (location = 1) FragData
{
vec4 color;
vec2 uv;
vec2 dst_pos;
vec2 dst_center;
vec2 dst_half_size;
vec2 sdf_sample_pos;
float corner_radius;
float softness;
float raised;
float border_thickness;
} FD;

View File

@ -17,6 +17,26 @@ layout (location = 7) in float edge_softness;
layout (location = 8) in float raised;
layout (location = 9) in uint has_texture;
layout (location = 0) FragDataFlat
{
vec2 atlas_size;
uint has_texture;
} FDF;
layout (location = 2) FragData
{
vec4 color;
vec2 uv;
vec2 dst_pos;
vec2 dst_center;
vec2 dst_half_size;
vec2 sdf_sample_pos;
float corner_radius;
float softness;
float raised;
float border_thickness;
} FD;
vec2 Vertices[4] = vec2[4](
vec2(-1.0, -1.0),
vec2(-1.0, +1.0),
@ -31,7 +51,7 @@ vec2 rotate(vec2 coords, float theta)
void main()
{
ivec2 tex_size = textureSize(sampler2D(SpriteAtlas, SamplerNearest), 0);
ivec2 tex_size = textureSize(SpriteAtlas, 0);
vec4 pos_start = vec4(in_dst_start.x, in_dst_start.y - raised, 0.0, 1.0);
vec4 pos_end = vec4(in_dst_end.x, in_dst_end.y, 0.0, 1.0);
@ -47,8 +67,8 @@ void main()
vec2 uvs[4] = vec2[4](
vec2(in_src_start.x, in_src_start.y),
vec2(in_src_start.x, in_src_end.y),
vec2(in_src_end.x, in_src_start.y),
vec2(in_src_end.x, in_src_end.y)
vec2(in_src_end.x, in_src_start.y),
vec2(in_src_end.x, in_src_end.y)
);
float corner_radius[4] = float[4](
@ -72,6 +92,7 @@ void main()
FD.border_thickness = border_thickness;
FD.sdf_sample_pos = (2.0f * dst_verts_pct - 1.0f) * half_size;
FDF.has_texture = has_texture;
FDF.atlas_size = in_src_end - in_src_start;
vec4 v_pos = PC.projection * vec4(pos.x, pos.y, 0, 1);
gl_Position = vec4(v_pos.x, v_pos.y, v_pos.z, 1);

BIN
vert.spv Normal file

Binary file not shown.