-
Notifications
You must be signed in to change notification settings - Fork 7
/
GlyphRangeFactory.cs
333 lines (319 loc) · 23.7 KB
/
GlyphRangeFactory.cs
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
using SharpPluginLoader.Core.Memory;
namespace SharpPluginLoader.Core.Rendering;
using GlyphRange = (ushort start, ushort end);
/// <summary>
/// A class for creating glyph ranges for ImGui.
/// </summary>
public static class GlyphRangeFactory
{
/// <summary>
/// Creates a new set of glyph ranges from the provided ranges, with a null terminator at the end.
/// </summary>
/// <param name="ranges">The ranges to create the glyph ranges from</param>
/// <returns>The newly allocated glyph ranges which can be used with ImGui</returns>
/// <remarks>You must call <see cref="DestroyGlyphRanges"/> when you are done with the glyph ranges.</remarks>
public static unsafe nint CreateGlyphRanges(params GlyphRange[] ranges)
{
var ptr = MemoryUtil.Alloc<ushort>(ranges.Length * 2 + 1);
for (var i = 0; i < ranges.Length; i++)
{
ptr[i * 2] = ranges[i].start;
ptr[i * 2 + 1] = ranges[i].end;
}
ptr[ranges.Length * 2] = 0;
return (nint)ptr;
}
/// <summary>
/// Destroys the glyph ranges created by <see cref="CreateGlyphRanges(GlyphRange[])"/>.
/// </summary>
/// <param name="ranges">The glyph ranges to destroy</param>
public static void DestroyGlyphRanges(nint ranges)
{
MemoryUtil.Free(ranges);
}
private static unsafe nint CreateGlyphRanges(ushort baseCodepoint, IReadOnlyList<short> accumulativeOffsets, params GlyphRange[] ranges)
{
var ptr = MemoryUtil.Alloc<ushort>(ranges.Length * 2 + accumulativeOffsets.Count * 2 + 1);
for (var i = 0; i < ranges.Length; i++)
{
ptr[i * 2] = ranges[i].start;
ptr[i * 2 + 1] = ranges[i].end;
}
UnpackAccumulativeOffsetsIntoRanges(baseCodepoint, accumulativeOffsets, ptr + ranges.Length * 2);
ptr[ranges.Length * 2 + accumulativeOffsets.Count * 2] = 0;
return (nint)ptr;
}
internal static nint CreateGlyphRanges(GlyphRanges ranges)
{
return ranges switch
{
GlyphRanges.Default => CreateGlyphRanges(DefaultGlyphRanges),
GlyphRanges.Greek => CreateGlyphRanges(GreekGlyphRanges),
GlyphRanges.Korean => CreateGlyphRanges(KoreanGlyphRanges),
GlyphRanges.Japanese => CreateGlyphRanges(0x4E00, JapaneseGlyphOffsets, JapaneseGlyphRanges),
GlyphRanges.ChineseFull => CreateGlyphRanges(ChineseFullGlyphRanges),
GlyphRanges.ChineseSimplifiedCommon => CreateGlyphRanges(0x4E00, ChineseSimplifiedGlyphOffsets, ChineseSimplifiedCommonGlyphRanges),
GlyphRanges.Cyrillic => CreateGlyphRanges(CyrillicGlyphRanges),
GlyphRanges.Thai => CreateGlyphRanges(ThaiGlyphRanges),
GlyphRanges.Vietnamese => CreateGlyphRanges(VietnameseGlyphRanges),
_ => throw new ArgumentOutOfRangeException(nameof(ranges), ranges, null)
};
}
private static unsafe void UnpackAccumulativeOffsetsIntoRanges(int baseCodepoint, IReadOnlyList<short> accumulativeOffsets, ushort* ranges)
{
for (var i = 0; i < accumulativeOffsets.Count; i++, ranges += 2)
{
ranges[0] = ranges[1] = (ushort)(baseCodepoint + accumulativeOffsets[i]);
baseCodepoint += accumulativeOffsets[i];
}
ranges[0] = 0;
}
private static readonly GlyphRange[] DefaultGlyphRanges =
[
(0x0020, 0x00FF)
];
private static readonly GlyphRange[] GreekGlyphRanges =
[
(0x0020, 0x00FF),
(0x0370, 0x03FF)
];
private static readonly GlyphRange[] KoreanGlyphRanges =
[
(0x0020, 0x00FF),
(0x3131, 0x3163),
(0xAC00, 0xD7A3),
(0xFFFD, 0xFFFD)
];
private static readonly GlyphRange[] JapaneseGlyphRanges =
[
(0x0020, 0x00FF),
(0x3000, 0x30FF),
(0x31F0, 0x31FF),
(0xFF00, 0xFFEF),
(0xFFFD, 0xFFFD)
];
private static readonly GlyphRange[] ChineseFullGlyphRanges =
[
(0x0020, 0x00FF),
(0x2000, 0x206F),
(0x3000, 0x30FF),
(0x31F0, 0x31FF),
(0xFF00, 0xFFEF),
(0xFFFD, 0xFFFD),
(0x4e00, 0x9FAF)
];
private static readonly GlyphRange[] ChineseSimplifiedCommonGlyphRanges =
[
(0x0020, 0x00FF),
(0x2000, 0x206F),
(0x3000, 0x30FF),
(0x31F0, 0x31FF),
(0xFF00, 0xFFEF),
(0xFFFD, 0xFFFD)
];
private static readonly GlyphRange[] CyrillicGlyphRanges =
[
(0x0020, 0x00FF),
(0x0400, 0x052F),
(0x2DE0, 0x2DFF),
(0xA640, 0xA69F)
];
private static readonly GlyphRange[] ThaiGlyphRanges =
[
(0x0020, 0x00FF),
(0x2010, 0x205E),
(0x0E00, 0x0E7F)
];
private static readonly GlyphRange[] VietnameseGlyphRanges =
[
(0x0020, 0x00FF),
(0x0102, 0x0103),
(0x0110, 0x0111),
(0x0128, 0x0129),
(0x0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24, 1, 16, 17, 9, 23, 10, 17, 6, 1, 51, 55, 44, 13, 294, 9,
3, 6, 2, 4, 2, 2, 15, 1, 1, 1, 13, 21, 17, 68, 14, 8, 9, 4, 1, 4, 9, 3, 11, 7, 1, 1, 1,
5, 6, 3, 2, 1, 1, 1, 2, 3, 8, 1, 2, 2, 4, 1, 5, 5, 2, 1, 4, 3, 7, 13, 4, 1, 4, 1, 3, 1, 1, 1, 5, 5, 10, 1, 6, 1,
5, 2, 1, 5, 2, 4, 1, 4, 5, 7, 3, 18, 2, 9, 11, 32, 4, 3, 3, 2, 4, 7, 11, 16, 9, 11, 8, 13, 38,
32, 8, 4, 2, 1, 1, 2, 1, 2, 4, 4, 1, 1, 1, 4, 1, 21, 3, 11, 1, 16, 1, 1, 6, 1, 3, 2, 4, 9, 8, 57, 7, 44, 1, 3,
3, 13, 3, 10, 1, 1, 7, 5, 2, 7, 21, 47, 63, 3, 15, 4, 7, 1, 16, 1, 1, 2, 8, 2, 3, 42, 15, 4,
1, 29, 7, 22, 10, 3, 78, 16, 12, 20, 18, 4, 67, 11, 5, 1, 3, 15, 6, 21, 31, 32, 27, 18, 13, 71, 35, 5, 142, 4,
10, 1, 2, 50, 19, 33, 16, 35, 37, 16, 19, 27, 7, 1, 133, 19, 1, 4, 8, 7, 20, 1, 4,
4, 1, 10, 3, 1, 6, 1, 2, 51, 5, 40, 15, 24, 43, 22928, 11, 1, 13, 154, 70, 3, 1, 1, 7, 4, 10, 1, 2, 1, 1, 2, 1,
2, 1, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1,
3, 2, 1, 1, 1, 1, 2, 1, 1,
];
private static readonly short[] ChineseSimplifiedGlyphOffsets =
[
0, 1, 2, 4, 1, 1, 1, 1, 2, 1, 3, 2, 1, 2, 2, 1, 1, 1, 1, 1, 5, 2, 1, 2, 3, 3, 3, 2, 2, 4, 1, 1, 1, 2, 1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 33, 6, 3, 6, 7, 3, 1, 3, 1, 11, 14, 4, 9, 5, 12, 11, 49, 18, 51, 31,
140, 31, 2, 2, 1, 5, 1, 8, 1, 10, 1, 4, 4, 3, 24, 1, 10, 1, 3, 6, 6, 16, 3, 4, 5, 2, 1, 4, 2, 57, 10, 6, 22, 2,
22, 3, 7, 22, 6, 10, 11, 36, 18, 16, 33, 36, 2, 5, 5, 1, 1, 1, 4, 10, 1, 4, 13, 2, 7,
5, 2, 9, 3, 4, 1, 7, 43, 3, 7, 3, 9, 14, 7, 9, 1, 11, 1, 1, 3, 7, 4, 18, 13, 1, 14, 1, 3, 6, 10, 73, 2, 2, 30,
6, 1, 11, 18, 19, 13, 22, 3, 46, 42, 37, 89, 7, 3, 16, 34, 2, 2, 3, 9, 1, 7, 1, 1, 1, 2,
2, 4, 10, 7, 3, 10, 3, 9, 5, 28, 9, 2, 6, 13, 7, 3, 1, 3, 10, 2, 7, 2, 11, 3, 6, 21, 54, 85, 2, 1, 4, 2, 2, 1,
39, 3, 21, 2, 2, 5, 1, 1, 1, 4, 1, 1, 3, 4, 15, 1, 3, 2, 4, 4, 2, 3, 8, 2, 20, 1, 8, 7, 13,
4, 1, 26, 6, 2, 9, 34, 4, 21, 52, 10, 4, 4, 1, 5, 12, 2, 11, 1, 7, 2, 30, 12, 44, 2, 30, 1, 1, 3, 6, 16, 9, 17,
39, 82, 2, 2, 24, 7, 1, 7, 3, 16, 9, 14, 44, 2, 1, 2, 1, 2, 3, 5, 2, 4, 1, 6, 7, 5, 3,
2, 6, 1, 11, 5, 11, 2, 1, 18, 19, 8, 1, 3, 24, 29, 2, 1, 3, 5, 2, 2, 1, 13, 6, 5, 1, 46, 11, 3, 5, 1, 1, 5, 8,
2, 10, 6, 12, 6, 3, 7, 11, 2, 4, 16, 13, 2, 5, 1, 1, 2, 2, 5, 2, 28, 5, 2, 23, 10, 8, 4,
4, 22, 39, 95, 38, 8, 14, 9, 5, 1, 13, 5, 4, 3, 13, 12, 11, 1, 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