Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/dep/imgui/src/imgui_draw.cpp
7372 views
1
// dear imgui, v1.92.6 WIP
2
// (drawing and font code)
3
4
/*
5
6
Index of this file:
7
8
// [SECTION] STB libraries implementation
9
// [SECTION] Style functions
10
// [SECTION] ImDrawList
11
// [SECTION] ImTriangulator, ImDrawList concave polygon fill
12
// [SECTION] ImDrawListSplitter
13
// [SECTION] ImDrawData
14
// [SECTION] Helpers ShadeVertsXXX functions
15
// [SECTION] ImFontConfig
16
// [SECTION] ImFontAtlas, ImFontAtlasBuilder
17
// [SECTION] ImFontAtlas: backend for stb_truetype
18
// [SECTION] ImFontAtlas: glyph ranges helpers
19
// [SECTION] ImFontGlyphRangesBuilder
20
// [SECTION] ImFontBaked, ImFont
21
// [SECTION] ImGui Internal Render Helpers
22
// [SECTION] Decompression code
23
// [SECTION] Default font data (ProggyClean.ttf)
24
// [SECTION] Default font data (ProggyVector-minimal.ttf)
25
26
*/
27
28
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
29
#define _CRT_SECURE_NO_WARNINGS
30
#endif
31
32
#ifndef IMGUI_DEFINE_MATH_OPERATORS
33
#define IMGUI_DEFINE_MATH_OPERATORS
34
#endif
35
36
#include "imgui.h"
37
#ifndef IMGUI_DISABLE
38
#include "imgui_internal.h"
39
#ifdef IMGUI_ENABLE_FREETYPE
40
#include "imgui_freetype.h"
41
#endif
42
43
#include <stdio.h> // vsnprintf, sscanf, printf
44
#include <stdint.h> // intptr_t
45
46
// Visual Studio warnings
47
#ifdef _MSC_VER
48
#pragma warning (disable: 4127) // condition expression is constant
49
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
50
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
51
#pragma warning (disable: 26451) // [Static Analyzer] Arithmetic overflow : Using operator 'xxx' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator 'xxx' to avoid overflow(io.2).
52
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
53
#endif
54
55
// Clang/GCC warnings with -Weverything
56
#if defined(__clang__)
57
#if __has_warning("-Wunknown-warning-option")
58
#pragma clang diagnostic ignored "-Wunknown-warning-option" // warning: unknown warning group 'xxx' // not all warnings are known by all Clang versions and they tend to be rename-happy.. so ignoring warnings triggers new warnings on some configuration. Great!
59
#endif
60
#pragma clang diagnostic ignored "-Wunknown-pragmas" // warning: unknown warning group 'xxx'
61
#pragma clang diagnostic ignored "-Wold-style-cast" // warning: use of old-style cast // yes, they are more terse.
62
#pragma clang diagnostic ignored "-Wfloat-equal" // warning: comparing floating point with == or != is unsafe // storing and comparing against same constants ok.
63
#pragma clang diagnostic ignored "-Wglobal-constructors" // warning: declaration requires a global destructor // similar to above, not sure what the exact difference is.
64
#pragma clang diagnostic ignored "-Wsign-conversion" // warning: implicit conversion changes signedness
65
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" // warning: zero as null pointer constant // some standard header variations use #define NULL 0
66
#pragma clang diagnostic ignored "-Wcomma" // warning: possible misuse of comma operator here
67
#pragma clang diagnostic ignored "-Wreserved-id-macro" // warning: macro name is a reserved identifier
68
#pragma clang diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function // using printf() is a misery with this as C++ va_arg ellipsis changes float to double.
69
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion" // warning: implicit conversion from 'xxx' to 'float' may lose precision
70
#pragma clang diagnostic ignored "-Wreserved-identifier" // warning: identifier '_Xxx' is reserved because it starts with '_' followed by a capital letter
71
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" // warning: 'xxx' is an unsafe pointer used for buffer access
72
#pragma clang diagnostic ignored "-Wnontrivial-memaccess" // warning: first argument in call to 'memset' is a pointer to non-trivially copyable type
73
#pragma clang diagnostic ignored "-Wcast-qual" // warning: cast from 'const xxxx *' to 'xxx *' drops const qualifier
74
#pragma clang diagnostic ignored "-Wswitch-default" // warning: 'switch' missing 'default' label
75
#elif defined(__GNUC__)
76
#pragma GCC diagnostic ignored "-Wpragmas" // warning: unknown option after '#pragma GCC diagnostic' kind
77
#pragma GCC diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
78
#pragma GCC diagnostic ignored "-Wfloat-equal" // warning: comparing floating-point with '==' or '!=' is unsafe
79
#pragma GCC diagnostic ignored "-Wdouble-promotion" // warning: implicit conversion from 'float' to 'double' when passing argument to function
80
#pragma GCC diagnostic ignored "-Wconversion" // warning: conversion to 'xxxx' from 'xxxx' may alter its value
81
#pragma GCC diagnostic ignored "-Wstack-protector" // warning: stack protector not protecting local variables: variable length buffer
82
#pragma GCC diagnostic ignored "-Wstrict-overflow" // warning: assuming signed overflow does not occur when simplifying division / ..when changing X +- C1 cmp C2 to X cmp C2 -+ C1
83
#pragma GCC diagnostic ignored "-Wclass-memaccess" // [__GNUC__ >= 8] warning: 'memset/memcpy' clearing/writing an object of type 'xxxx' with no trivial copy-assignment; use assignment or value-initialization instead
84
#pragma GCC diagnostic ignored "-Wcast-qual" // warning: cast from type 'const xxxx *' to type 'xxxx *' casts away qualifiers
85
#endif
86
87
//-------------------------------------------------------------------------
88
// [SECTION] STB libraries implementation (for stb_truetype and stb_rect_pack)
89
//-------------------------------------------------------------------------
90
91
// Compile time options:
92
//#define IMGUI_STB_NAMESPACE ImStb
93
//#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h"
94
//#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h"
95
//#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION
96
//#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION
97
98
#ifdef IMGUI_STB_NAMESPACE
99
namespace IMGUI_STB_NAMESPACE
100
{
101
#endif
102
103
#ifdef _MSC_VER
104
#pragma warning (push)
105
#pragma warning (disable: 4456) // declaration of 'xx' hides previous local declaration
106
#pragma warning (disable: 6011) // (stb_rectpack) Dereferencing NULL pointer 'cur->next'.
107
#pragma warning (disable: 6385) // (stb_truetype) Reading invalid data from 'buffer': the readable size is '_Old_3`kernel_width' bytes, but '3' bytes may be read.
108
#pragma warning (disable: 28182) // (stb_rectpack) Dereferencing NULL pointer. 'cur' contains the same NULL value as 'cur->next' did.
109
#endif
110
111
#if defined(__clang__)
112
#pragma clang diagnostic push
113
#pragma clang diagnostic ignored "-Wunused-function" // warning: 'xxxx' defined but not used
114
#pragma clang diagnostic ignored "-Wmissing-prototypes"
115
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
116
#endif
117
118
#if defined(__GNUC__)
119
#pragma GCC diagnostic push
120
#pragma GCC diagnostic ignored "-Wtype-limits" // warning: comparison is always true due to limited range of data type [-Wtype-limits]
121
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough" // warning: this statement may fall through
122
#endif
123
124
#ifndef STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
125
#ifndef IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION // in case the user already have an implementation in another compilation unit
126
#define STBRP_STATIC
127
#define STBRP_ASSERT(x) do { IM_ASSERT(x); } while (0)
128
#define STBRP_SORT ImQsort
129
#define STB_RECT_PACK_IMPLEMENTATION
130
#endif
131
#ifdef IMGUI_STB_RECT_PACK_FILENAME
132
#include IMGUI_STB_RECT_PACK_FILENAME
133
#else
134
#include "imstb_rectpack.h"
135
#endif
136
#endif
137
138
#ifdef IMGUI_ENABLE_STB_TRUETYPE
139
#ifndef STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in the _same_ compilation unit (e.g. unity builds)
140
#ifndef IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION // in case the user already have an implementation in another compilation unit
141
#define STBTT_malloc(x,u) ((void)(u), IM_ALLOC(x))
142
#define STBTT_free(x,u) ((void)(u), IM_FREE(x))
143
#define STBTT_assert(x) do { IM_ASSERT(x); } while(0)
144
#define STBTT_fmod(x,y) ImFmod(x,y)
145
#define STBTT_sqrt(x) ImSqrt(x)
146
#define STBTT_pow(x,y) ImPow(x,y)
147
#define STBTT_fabs(x) ImFabs(x)
148
#define STBTT_ifloor(x) ((int)ImFloor(x))
149
#define STBTT_iceil(x) ((int)ImCeil(x))
150
#define STBTT_strlen(x) ImStrlen(x)
151
#define STBTT_STATIC
152
#define STB_TRUETYPE_IMPLEMENTATION
153
#else
154
#define STBTT_DEF extern
155
#endif
156
#ifdef IMGUI_STB_TRUETYPE_FILENAME
157
#include IMGUI_STB_TRUETYPE_FILENAME
158
#else
159
#include "imstb_truetype.h"
160
#endif
161
#endif
162
#endif // IMGUI_ENABLE_STB_TRUETYPE
163
164
#if defined(__GNUC__)
165
#pragma GCC diagnostic pop
166
#endif
167
168
#if defined(__clang__)
169
#pragma clang diagnostic pop
170
#endif
171
172
#if defined(_MSC_VER)
173
#pragma warning (pop)
174
#endif
175
176
#ifdef IMGUI_STB_NAMESPACE
177
} // namespace ImStb
178
using namespace IMGUI_STB_NAMESPACE;
179
#endif
180
181
//-----------------------------------------------------------------------------
182
// [SECTION] Style functions
183
//-----------------------------------------------------------------------------
184
185
void ImGui::StyleColorsDark(ImGuiStyle* dst)
186
{
187
ImGuiStyle* style = dst ? dst : &ImGui::GetStyle();
188
ImVec4* colors = style->Colors;
189
190
colors[ImGuiCol_Text] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
191
colors[ImGuiCol_TextDisabled] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
192
colors[ImGuiCol_WindowBg] = ImVec4(0.06f, 0.06f, 0.06f, 0.94f);
193
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
194
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
195
colors[ImGuiCol_Border] = ImVec4(0.43f, 0.43f, 0.50f, 0.50f);
196
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
197
colors[ImGuiCol_FrameBg] = ImVec4(0.16f, 0.29f, 0.48f, 0.54f);
198
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
199
colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
200
colors[ImGuiCol_TitleBg] = ImVec4(0.04f, 0.04f, 0.04f, 1.00f);
201
colors[ImGuiCol_TitleBgActive] = ImVec4(0.16f, 0.29f, 0.48f, 1.00f);
202
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f);
203
colors[ImGuiCol_MenuBarBg] = ImVec4(0.14f, 0.14f, 0.14f, 1.00f);
204
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.53f);
205
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.31f, 0.31f, 0.31f, 1.00f);
206
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.41f, 0.41f, 0.41f, 1.00f);
207
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.51f, 0.51f, 0.51f, 1.00f);
208
colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
209
colors[ImGuiCol_SliderGrab] = ImVec4(0.24f, 0.52f, 0.88f, 1.00f);
210
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
211
colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
212
colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
213
colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
214
colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
215
colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
216
colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
217
colors[ImGuiCol_Separator] = colors[ImGuiCol_Border];
218
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f);
219
colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f);
220
colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.20f);
221
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
222
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
223
colors[ImGuiCol_InputTextCursor] = colors[ImGuiCol_Text];
224
colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
225
colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f);
226
colors[ImGuiCol_TabSelected] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
227
colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive];
228
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
229
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
230
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.50f, 0.50f, 0.50f, 0.00f);
231
colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f);
232
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
233
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
234
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
235
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.19f, 0.19f, 0.20f, 1.00f);
236
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f); // Prefer using Alpha=1.0 here
237
colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f); // Prefer using Alpha=1.0 here
238
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
239
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.06f);
240
colors[ImGuiCol_TextLink] = colors[ImGuiCol_HeaderActive];
241
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
242
colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border];
243
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
244
colors[ImGuiCol_DragDropTargetBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
245
colors[ImGuiCol_UnsavedMarker] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
246
colors[ImGuiCol_NavCursor] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
247
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
248
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
249
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f);
250
}
251
252
void ImGui::StyleColorsClassic(ImGuiStyle* dst)
253
{
254
ImGuiStyle* style = dst ? dst : &ImGui::GetStyle();
255
ImVec4* colors = style->Colors;
256
257
colors[ImGuiCol_Text] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
258
colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
259
colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.85f);
260
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
261
colors[ImGuiCol_PopupBg] = ImVec4(0.11f, 0.11f, 0.14f, 0.92f);
262
colors[ImGuiCol_Border] = ImVec4(0.50f, 0.50f, 0.50f, 0.50f);
263
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
264
colors[ImGuiCol_FrameBg] = ImVec4(0.43f, 0.43f, 0.43f, 0.39f);
265
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.47f, 0.47f, 0.69f, 0.40f);
266
colors[ImGuiCol_FrameBgActive] = ImVec4(0.42f, 0.41f, 0.64f, 0.69f);
267
colors[ImGuiCol_TitleBg] = ImVec4(0.27f, 0.27f, 0.54f, 0.83f);
268
colors[ImGuiCol_TitleBgActive] = ImVec4(0.32f, 0.32f, 0.63f, 0.87f);
269
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.40f, 0.40f, 0.80f, 0.20f);
270
colors[ImGuiCol_MenuBarBg] = ImVec4(0.40f, 0.40f, 0.55f, 0.80f);
271
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.20f, 0.25f, 0.30f, 0.60f);
272
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.80f, 0.30f);
273
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.40f, 0.40f, 0.80f, 0.40f);
274
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f);
275
colors[ImGuiCol_CheckMark] = ImVec4(0.90f, 0.90f, 0.90f, 0.50f);
276
colors[ImGuiCol_SliderGrab] = ImVec4(1.00f, 1.00f, 1.00f, 0.30f);
277
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.41f, 0.39f, 0.80f, 0.60f);
278
colors[ImGuiCol_Button] = ImVec4(0.35f, 0.40f, 0.61f, 0.62f);
279
colors[ImGuiCol_ButtonHovered] = ImVec4(0.40f, 0.48f, 0.71f, 0.79f);
280
colors[ImGuiCol_ButtonActive] = ImVec4(0.46f, 0.54f, 0.80f, 1.00f);
281
colors[ImGuiCol_Header] = ImVec4(0.40f, 0.40f, 0.90f, 0.45f);
282
colors[ImGuiCol_HeaderHovered] = ImVec4(0.45f, 0.45f, 0.90f, 0.80f);
283
colors[ImGuiCol_HeaderActive] = ImVec4(0.53f, 0.53f, 0.87f, 0.80f);
284
colors[ImGuiCol_Separator] = ImVec4(0.50f, 0.50f, 0.50f, 0.60f);
285
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.60f, 0.60f, 0.70f, 1.00f);
286
colors[ImGuiCol_SeparatorActive] = ImVec4(0.70f, 0.70f, 0.90f, 1.00f);
287
colors[ImGuiCol_ResizeGrip] = ImVec4(1.00f, 1.00f, 1.00f, 0.10f);
288
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.78f, 0.82f, 1.00f, 0.60f);
289
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.78f, 0.82f, 1.00f, 0.90f);
290
colors[ImGuiCol_InputTextCursor] = colors[ImGuiCol_Text];
291
colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
292
colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.80f);
293
colors[ImGuiCol_TabSelected] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
294
colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive];
295
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
296
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
297
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.53f, 0.53f, 0.87f, 0.00f);
298
colors[ImGuiCol_PlotLines] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
299
colors[ImGuiCol_PlotLinesHovered] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
300
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
301
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f);
302
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.27f, 0.27f, 0.38f, 1.00f);
303
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.45f, 1.00f); // Prefer using Alpha=1.0 here
304
colors[ImGuiCol_TableBorderLight] = ImVec4(0.26f, 0.26f, 0.28f, 1.00f); // Prefer using Alpha=1.0 here
305
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
306
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.07f);
307
colors[ImGuiCol_TextLink] = colors[ImGuiCol_HeaderActive];
308
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.00f, 0.00f, 1.00f, 0.35f);
309
colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border];
310
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
311
colors[ImGuiCol_DragDropTargetBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
312
colors[ImGuiCol_UnsavedMarker] = ImVec4(0.90f, 0.90f, 0.90f, 1.00f);
313
colors[ImGuiCol_NavCursor] = colors[ImGuiCol_HeaderHovered];
314
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f);
315
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f);
316
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
317
}
318
319
// Those light colors are better suited with a thicker font than the default one + FrameBorder
320
void ImGui::StyleColorsLight(ImGuiStyle* dst)
321
{
322
ImGuiStyle* style = dst ? dst : &ImGui::GetStyle();
323
ImVec4* colors = style->Colors;
324
325
colors[ImGuiCol_Text] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
326
colors[ImGuiCol_TextDisabled] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
327
colors[ImGuiCol_WindowBg] = ImVec4(0.94f, 0.94f, 0.94f, 1.00f);
328
colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
329
colors[ImGuiCol_PopupBg] = ImVec4(1.00f, 1.00f, 1.00f, 0.98f);
330
colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.30f);
331
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
332
colors[ImGuiCol_FrameBg] = ImVec4(1.00f, 1.00f, 1.00f, 1.00f);
333
colors[ImGuiCol_FrameBgHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
334
colors[ImGuiCol_FrameBgActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
335
colors[ImGuiCol_TitleBg] = ImVec4(0.96f, 0.96f, 0.96f, 1.00f);
336
colors[ImGuiCol_TitleBgActive] = ImVec4(0.82f, 0.82f, 0.82f, 1.00f);
337
colors[ImGuiCol_TitleBgCollapsed] = ImVec4(1.00f, 1.00f, 1.00f, 0.51f);
338
colors[ImGuiCol_MenuBarBg] = ImVec4(0.86f, 0.86f, 0.86f, 1.00f);
339
colors[ImGuiCol_ScrollbarBg] = ImVec4(0.98f, 0.98f, 0.98f, 0.53f);
340
colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.69f, 0.69f, 0.69f, 0.80f);
341
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.49f, 0.49f, 0.49f, 0.80f);
342
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.49f, 0.49f, 0.49f, 1.00f);
343
colors[ImGuiCol_CheckMark] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
344
colors[ImGuiCol_SliderGrab] = ImVec4(0.26f, 0.59f, 0.98f, 0.78f);
345
colors[ImGuiCol_SliderGrabActive] = ImVec4(0.46f, 0.54f, 0.80f, 0.60f);
346
colors[ImGuiCol_Button] = ImVec4(0.26f, 0.59f, 0.98f, 0.40f);
347
colors[ImGuiCol_ButtonHovered] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
348
colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f);
349
colors[ImGuiCol_Header] = ImVec4(0.26f, 0.59f, 0.98f, 0.31f);
350
colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f);
351
colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
352
colors[ImGuiCol_Separator] = ImVec4(0.39f, 0.39f, 0.39f, 0.62f);
353
colors[ImGuiCol_SeparatorHovered] = ImVec4(0.14f, 0.44f, 0.80f, 0.78f);
354
colors[ImGuiCol_SeparatorActive] = ImVec4(0.14f, 0.44f, 0.80f, 1.00f);
355
colors[ImGuiCol_ResizeGrip] = ImVec4(0.35f, 0.35f, 0.35f, 0.17f);
356
colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f);
357
colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
358
colors[ImGuiCol_InputTextCursor] = colors[ImGuiCol_Text];
359
colors[ImGuiCol_TabHovered] = colors[ImGuiCol_HeaderHovered];
360
colors[ImGuiCol_Tab] = ImLerp(colors[ImGuiCol_Header], colors[ImGuiCol_TitleBgActive], 0.90f);
361
colors[ImGuiCol_TabSelected] = ImLerp(colors[ImGuiCol_HeaderActive], colors[ImGuiCol_TitleBgActive], 0.60f);
362
colors[ImGuiCol_TabSelectedOverline] = colors[ImGuiCol_HeaderActive];
363
colors[ImGuiCol_TabDimmed] = ImLerp(colors[ImGuiCol_Tab], colors[ImGuiCol_TitleBg], 0.80f);
364
colors[ImGuiCol_TabDimmedSelected] = ImLerp(colors[ImGuiCol_TabSelected], colors[ImGuiCol_TitleBg], 0.40f);
365
colors[ImGuiCol_TabDimmedSelectedOverline] = ImVec4(0.26f, 0.59f, 1.00f, 0.00f);
366
colors[ImGuiCol_PlotLines] = ImVec4(0.39f, 0.39f, 0.39f, 1.00f);
367
colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f);
368
colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f);
369
colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.45f, 0.00f, 1.00f);
370
colors[ImGuiCol_TableHeaderBg] = ImVec4(0.78f, 0.87f, 0.98f, 1.00f);
371
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.57f, 0.57f, 0.64f, 1.00f); // Prefer using Alpha=1.0 here
372
colors[ImGuiCol_TableBorderLight] = ImVec4(0.68f, 0.68f, 0.74f, 1.00f); // Prefer using Alpha=1.0 here
373
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
374
colors[ImGuiCol_TableRowBgAlt] = ImVec4(0.30f, 0.30f, 0.30f, 0.09f);
375
colors[ImGuiCol_TextLink] = colors[ImGuiCol_HeaderActive];
376
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
377
colors[ImGuiCol_TreeLines] = colors[ImGuiCol_Border];
378
colors[ImGuiCol_DragDropTarget] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f);
379
colors[ImGuiCol_DragDropTargetBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
380
colors[ImGuiCol_UnsavedMarker] = ImVec4(0.00f, 0.00f, 0.00f, 1.00f);
381
colors[ImGuiCol_NavCursor] = colors[ImGuiCol_HeaderHovered];
382
colors[ImGuiCol_NavWindowingHighlight] = ImVec4(0.70f, 0.70f, 0.70f, 0.70f);
383
colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.20f);
384
colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.35f);
385
}
386
387
//-----------------------------------------------------------------------------
388
// [SECTION] ImDrawList
389
//-----------------------------------------------------------------------------
390
391
ImDrawListSharedData::ImDrawListSharedData()
392
{
393
memset(this, 0, sizeof(*this));
394
InitialFringeScale = 1.0f;
395
for (int i = 0; i < IM_COUNTOF(ArcFastVtx); i++)
396
{
397
const float a = ((float)i * 2 * IM_PI) / (float)IM_COUNTOF(ArcFastVtx);
398
ArcFastVtx[i] = ImVec2(ImCos(a), ImSin(a));
399
}
400
ArcFastRadiusCutoff = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(IM_DRAWLIST_ARCFAST_SAMPLE_MAX, CircleSegmentMaxError);
401
}
402
403
ImDrawListSharedData::~ImDrawListSharedData()
404
{
405
IM_ASSERT(DrawLists.Size == 0);
406
}
407
408
void ImDrawListSharedData::SetCircleTessellationMaxError(float max_error)
409
{
410
if (CircleSegmentMaxError == max_error)
411
return;
412
413
IM_ASSERT(max_error > 0.0f);
414
CircleSegmentMaxError = max_error;
415
for (int i = 0; i < IM_COUNTOF(CircleSegmentCounts); i++)
416
{
417
const float radius = (float)i;
418
CircleSegmentCounts[i] = (ImU8)((i > 0) ? IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, CircleSegmentMaxError) : IM_DRAWLIST_ARCFAST_SAMPLE_MAX);
419
}
420
ArcFastRadiusCutoff = IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC_R(IM_DRAWLIST_ARCFAST_SAMPLE_MAX, CircleSegmentMaxError);
421
}
422
423
ImDrawList::ImDrawList(ImDrawListSharedData* shared_data)
424
{
425
memset(this, 0, sizeof(*this));
426
_SetDrawListSharedData(shared_data);
427
}
428
429
ImDrawList::~ImDrawList()
430
{
431
_ClearFreeMemory();
432
_SetDrawListSharedData(NULL);
433
}
434
435
void ImDrawList::_SetDrawListSharedData(ImDrawListSharedData* data)
436
{
437
if (_Data != NULL)
438
_Data->DrawLists.find_erase_unsorted(this);
439
_Data = data;
440
if (_Data != NULL)
441
_Data->DrawLists.push_back(this);
442
}
443
444
// Initialize before use in a new frame. We always have a command ready in the buffer.
445
// In the majority of cases, you would want to call PushClipRect() and PushTexture() after this.
446
void ImDrawList::_ResetForNewFrame()
447
{
448
// Verify that the ImDrawCmd fields we want to memcmp() are contiguous in memory to match ImDrawCmdHeader.
449
IM_STATIC_ASSERT(offsetof(ImDrawCmd, ClipRect) == 0);
450
IM_STATIC_ASSERT(offsetof(ImDrawCmd, TexRef) == sizeof(ImVec4));
451
IM_STATIC_ASSERT(offsetof(ImDrawCmd, VtxOffset) == sizeof(ImVec4) + sizeof(ImTextureRef));
452
IM_STATIC_ASSERT(offsetof(ImDrawCmd, ClipRect) == offsetof(ImDrawCmdHeader, ClipRect));
453
IM_STATIC_ASSERT(offsetof(ImDrawCmd, TexRef) == offsetof(ImDrawCmdHeader, TexRef));
454
IM_STATIC_ASSERT(offsetof(ImDrawCmd, VtxOffset) == offsetof(ImDrawCmdHeader, VtxOffset));
455
if (_Splitter._Count > 1)
456
_Splitter.Merge(this);
457
458
CmdBuffer.resize(0);
459
IdxBuffer.resize(0);
460
VtxBuffer.resize(0);
461
Flags = _Data->InitialFlags;
462
memset(&_CmdHeader, 0, sizeof(_CmdHeader));
463
_VtxCurrentIdx = 0;
464
_VtxWritePtr = NULL;
465
_IdxWritePtr = NULL;
466
_ClipRectStack.resize(0);
467
_TextureStack.resize(0);
468
_CallbacksDataBuf.resize(0);
469
_Path.resize(0);
470
_Splitter.Clear();
471
CmdBuffer.push_back(ImDrawCmd());
472
_FringeScale = _Data->InitialFringeScale;
473
}
474
475
void ImDrawList::_ClearFreeMemory()
476
{
477
CmdBuffer.clear();
478
IdxBuffer.clear();
479
VtxBuffer.clear();
480
Flags = ImDrawListFlags_None;
481
_VtxCurrentIdx = 0;
482
_VtxWritePtr = NULL;
483
_IdxWritePtr = NULL;
484
_ClipRectStack.clear();
485
_TextureStack.clear();
486
_CallbacksDataBuf.clear();
487
_Path.clear();
488
_Splitter.ClearFreeMemory();
489
}
490
491
// Note: For multi-threaded rendering, consider using `imgui_threaded_rendering` from https://github.com/ocornut/imgui_club
492
ImDrawList* ImDrawList::CloneOutput() const
493
{
494
ImDrawList* dst = IM_NEW(ImDrawList(NULL));
495
dst->CmdBuffer = CmdBuffer;
496
dst->IdxBuffer = IdxBuffer;
497
dst->VtxBuffer = VtxBuffer;
498
dst->Flags = Flags;
499
return dst;
500
}
501
502
void ImDrawList::AddDrawCmd()
503
{
504
ImDrawCmd draw_cmd;
505
draw_cmd.ClipRect = _CmdHeader.ClipRect; // Same as calling ImDrawCmd_HeaderCopy()
506
draw_cmd.TexRef = _CmdHeader.TexRef;
507
draw_cmd.VtxOffset = _CmdHeader.VtxOffset;
508
draw_cmd.IdxOffset = IdxBuffer.Size;
509
510
IM_ASSERT(draw_cmd.ClipRect.x <= draw_cmd.ClipRect.z && draw_cmd.ClipRect.y <= draw_cmd.ClipRect.w);
511
CmdBuffer.push_back(draw_cmd);
512
}
513
514
// Pop trailing draw command (used before merging or presenting to user)
515
// Note that this leaves the ImDrawList in a state unfit for further commands, as most code assume that CmdBuffer.Size > 0 && CmdBuffer.back().UserCallback == NULL
516
void ImDrawList::_PopUnusedDrawCmd()
517
{
518
while (CmdBuffer.Size > 0)
519
{
520
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
521
if (curr_cmd->ElemCount != 0 || curr_cmd->UserCallback != NULL)
522
return;// break;
523
CmdBuffer.pop_back();
524
}
525
}
526
527
void ImDrawList::AddCallback(ImDrawCallback callback, void* userdata, size_t userdata_size)
528
{
529
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
530
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
531
IM_ASSERT(callback != NULL);
532
IM_ASSERT(curr_cmd->UserCallback == NULL);
533
if (curr_cmd->ElemCount != 0)
534
{
535
AddDrawCmd();
536
curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
537
}
538
539
curr_cmd->UserCallback = callback;
540
if (userdata_size == 0)
541
{
542
// Store user data directly in command (no indirection)
543
curr_cmd->UserCallbackData = userdata;
544
curr_cmd->UserCallbackDataSize = 0;
545
curr_cmd->UserCallbackDataOffset = -1;
546
}
547
else
548
{
549
// Copy and store user data in a buffer
550
IM_ASSERT(userdata != NULL);
551
IM_ASSERT(userdata_size < (1u << 31));
552
curr_cmd->UserCallbackData = NULL; // Will be resolved during Render()
553
curr_cmd->UserCallbackDataSize = (int)userdata_size;
554
curr_cmd->UserCallbackDataOffset = _CallbacksDataBuf.Size;
555
_CallbacksDataBuf.resize(_CallbacksDataBuf.Size + (int)userdata_size);
556
memcpy(_CallbacksDataBuf.Data + (size_t)curr_cmd->UserCallbackDataOffset, userdata, userdata_size);
557
}
558
559
AddDrawCmd(); // Force a new command after us (see comment below)
560
}
561
562
// Compare ClipRect, TexRef and VtxOffset with a single memcmp()
563
#define ImDrawCmd_HeaderSize (offsetof(ImDrawCmd, VtxOffset) + sizeof(unsigned int))
564
#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS) (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize)) // Compare ClipRect, TexRef, VtxOffset
565
#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC) (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize)) // Copy ClipRect, TexRef, VtxOffset
566
#define ImDrawCmd_AreSequentialIdxOffset(CMD_0, CMD_1) (CMD_0->IdxOffset + CMD_0->ElemCount == CMD_1->IdxOffset)
567
568
// Try to merge two last draw commands
569
void ImDrawList::_TryMergeDrawCmds()
570
{
571
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
572
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
573
ImDrawCmd* prev_cmd = curr_cmd - 1;
574
if (ImDrawCmd_HeaderCompare(curr_cmd, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && curr_cmd->UserCallback == NULL && prev_cmd->UserCallback == NULL)
575
{
576
prev_cmd->ElemCount += curr_cmd->ElemCount;
577
CmdBuffer.pop_back();
578
}
579
}
580
581
// Our scheme may appears a bit unusual, basically we want the most-common calls AddLine AddRect etc. to not have to perform any check so we always have a command ready in the stack.
582
// The cost of figuring out if a new command has to be added or if we can merge is paid in those Update** functions only.
583
void ImDrawList::_OnChangedClipRect()
584
{
585
// If current command is used with different settings we need to add a new command
586
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
587
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
588
if (curr_cmd->ElemCount != 0 && memcmp(&curr_cmd->ClipRect, &_CmdHeader.ClipRect, sizeof(ImVec4)) != 0)
589
{
590
AddDrawCmd();
591
return;
592
}
593
IM_ASSERT(curr_cmd->UserCallback == NULL);
594
595
// Try to merge with previous command if it matches, else use current command
596
ImDrawCmd* prev_cmd = curr_cmd - 1;
597
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && prev_cmd->UserCallback == NULL)
598
{
599
CmdBuffer.pop_back();
600
return;
601
}
602
curr_cmd->ClipRect = _CmdHeader.ClipRect;
603
}
604
605
void ImDrawList::_OnChangedTexture()
606
{
607
// If current command is used with different settings we need to add a new command
608
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
609
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
610
if (curr_cmd->ElemCount != 0 && curr_cmd->TexRef != _CmdHeader.TexRef)
611
{
612
AddDrawCmd();
613
return;
614
}
615
616
// Unlike other _OnChangedXXX functions this may be called by ImFontAtlasUpdateDrawListsTextures() in more locations so we need to handle this case.
617
if (curr_cmd->UserCallback != NULL)
618
return;
619
620
// Try to merge with previous command if it matches, else use current command
621
ImDrawCmd* prev_cmd = curr_cmd - 1;
622
if (curr_cmd->ElemCount == 0 && CmdBuffer.Size > 1 && ImDrawCmd_HeaderCompare(&_CmdHeader, prev_cmd) == 0 && ImDrawCmd_AreSequentialIdxOffset(prev_cmd, curr_cmd) && prev_cmd->UserCallback == NULL)
623
{
624
CmdBuffer.pop_back();
625
return;
626
}
627
curr_cmd->TexRef = _CmdHeader.TexRef;
628
}
629
630
void ImDrawList::_OnChangedVtxOffset()
631
{
632
// We don't need to compare curr_cmd->VtxOffset != _CmdHeader.VtxOffset because we know it'll be different at the time we call this.
633
_VtxCurrentIdx = 0;
634
IM_ASSERT_PARANOID(CmdBuffer.Size > 0);
635
ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
636
//IM_ASSERT(curr_cmd->VtxOffset != _CmdHeader.VtxOffset); // See #3349
637
if (curr_cmd->ElemCount != 0)
638
{
639
AddDrawCmd();
640
return;
641
}
642
IM_ASSERT(curr_cmd->UserCallback == NULL);
643
curr_cmd->VtxOffset = _CmdHeader.VtxOffset;
644
}
645
646
int ImDrawList::_CalcCircleAutoSegmentCount(float radius) const
647
{
648
// Automatic segment count
649
const int radius_idx = (int)(radius + 0.999999f); // ceil to never reduce accuracy
650
if (radius_idx >= 0 && radius_idx < IM_COUNTOF(_Data->CircleSegmentCounts))
651
return _Data->CircleSegmentCounts[radius_idx]; // Use cached value
652
else
653
return IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_CALC(radius, _Data->CircleSegmentMaxError);
654
}
655
656
// Render-level scissoring. This is passed down to your render function but not used for CPU-side coarse clipping. Prefer using higher-level ImGui::PushClipRect() to affect logic (hit-testing and widget culling)
657
void ImDrawList::PushClipRect(const ImVec2& cr_min, const ImVec2& cr_max, bool intersect_with_current_clip_rect)
658
{
659
ImVec4 cr(cr_min.x, cr_min.y, cr_max.x, cr_max.y);
660
if (intersect_with_current_clip_rect)
661
{
662
ImVec4 current = _CmdHeader.ClipRect;
663
if (cr.x < current.x) cr.x = current.x;
664
if (cr.y < current.y) cr.y = current.y;
665
if (cr.z > current.z) cr.z = current.z;
666
if (cr.w > current.w) cr.w = current.w;
667
}
668
cr.z = ImMax(cr.x, cr.z);
669
cr.w = ImMax(cr.y, cr.w);
670
671
_ClipRectStack.push_back(cr);
672
_CmdHeader.ClipRect = cr;
673
_OnChangedClipRect();
674
}
675
676
void ImDrawList::PushClipRectFullScreen()
677
{
678
PushClipRect(ImVec2(_Data->ClipRectFullscreen.x, _Data->ClipRectFullscreen.y), ImVec2(_Data->ClipRectFullscreen.z, _Data->ClipRectFullscreen.w));
679
}
680
681
void ImDrawList::PopClipRect()
682
{
683
_ClipRectStack.pop_back();
684
_CmdHeader.ClipRect = (_ClipRectStack.Size == 0) ? _Data->ClipRectFullscreen : _ClipRectStack.Data[_ClipRectStack.Size - 1];
685
_OnChangedClipRect();
686
}
687
688
void ImDrawList::PushTexture(ImTextureRef tex_ref)
689
{
690
_TextureStack.push_back(tex_ref);
691
_CmdHeader.TexRef = tex_ref;
692
if (tex_ref._TexData != NULL)
693
IM_ASSERT(tex_ref._TexData->WantDestroyNextFrame == false);
694
_OnChangedTexture();
695
}
696
697
void ImDrawList::PopTexture()
698
{
699
_TextureStack.pop_back();
700
_CmdHeader.TexRef = (_TextureStack.Size == 0) ? ImTextureRef() : _TextureStack.Data[_TextureStack.Size - 1];
701
_OnChangedTexture();
702
}
703
704
// This is used by ImGui::PushFont()/PopFont(). It works because we never use _TextureIdStack[] elsewhere than in PushTexture()/PopTexture().
705
void ImDrawList::_SetTexture(ImTextureRef tex_ref)
706
{
707
if (_CmdHeader.TexRef == tex_ref)
708
return;
709
_CmdHeader.TexRef = tex_ref;
710
_TextureStack.back() = tex_ref;
711
_OnChangedTexture();
712
}
713
714
// Reserve space for a number of vertices and indices.
715
// You must finish filling your reserved data before calling PrimReserve() again, as it may reallocate or
716
// submit the intermediate results. PrimUnreserve() can be used to release unused allocations.
717
void ImDrawList::PrimReserve(int idx_count, int vtx_count)
718
{
719
// Large mesh support (when enabled)
720
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
721
if (sizeof(ImDrawIdx) == 2 && (_VtxCurrentIdx + vtx_count >= (1 << 16)) && (Flags & ImDrawListFlags_AllowVtxOffset))
722
{
723
// FIXME: In theory we should be testing that vtx_count <64k here.
724
// In practice, RenderText() relies on reserving ahead for a worst case scenario so it is currently useful for us
725
// to not make that check until we rework the text functions to handle clipping and large horizontal lines better.
726
_CmdHeader.VtxOffset = VtxBuffer.Size;
727
_OnChangedVtxOffset();
728
}
729
730
ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
731
draw_cmd->ElemCount += idx_count;
732
733
int vtx_buffer_old_size = VtxBuffer.Size;
734
VtxBuffer.resize(vtx_buffer_old_size + vtx_count);
735
_VtxWritePtr = VtxBuffer.Data + vtx_buffer_old_size;
736
737
int idx_buffer_old_size = IdxBuffer.Size;
738
IdxBuffer.resize(idx_buffer_old_size + idx_count);
739
_IdxWritePtr = IdxBuffer.Data + idx_buffer_old_size;
740
}
741
742
// Release the number of reserved vertices/indices from the end of the last reservation made with PrimReserve().
743
void ImDrawList::PrimUnreserve(int idx_count, int vtx_count)
744
{
745
IM_ASSERT_PARANOID(idx_count >= 0 && vtx_count >= 0);
746
747
ImDrawCmd* draw_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
748
draw_cmd->ElemCount -= idx_count;
749
VtxBuffer.shrink(VtxBuffer.Size - vtx_count);
750
IdxBuffer.shrink(IdxBuffer.Size - idx_count);
751
}
752
753
// Fully unrolled with inline call to keep our debug builds decently fast.
754
void ImDrawList::PrimRect(const ImVec2& a, const ImVec2& c, ImU32 col)
755
{
756
ImVec2 b(c.x, a.y), d(a.x, c.y), uv(_Data->TexUvWhitePixel);
757
ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx;
758
_IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2);
759
_IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3);
760
_VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
761
_VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col;
762
_VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv; _VtxWritePtr[2].col = col;
763
_VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv; _VtxWritePtr[3].col = col;
764
_VtxWritePtr += 4;
765
_VtxCurrentIdx += 4;
766
_IdxWritePtr += 6;
767
}
768
769
void ImDrawList::PrimRectUV(const ImVec2& a, const ImVec2& c, const ImVec2& uv_a, const ImVec2& uv_c, ImU32 col)
770
{
771
ImVec2 b(c.x, a.y), d(a.x, c.y), uv_b(uv_c.x, uv_a.y), uv_d(uv_a.x, uv_c.y);
772
ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx;
773
_IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2);
774
_IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3);
775
_VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col;
776
_VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col;
777
_VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col;
778
_VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col;
779
_VtxWritePtr += 4;
780
_VtxCurrentIdx += 4;
781
_IdxWritePtr += 6;
782
}
783
784
void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col)
785
{
786
ImDrawIdx idx = (ImDrawIdx)_VtxCurrentIdx;
787
_IdxWritePtr[0] = idx; _IdxWritePtr[1] = (ImDrawIdx)(idx+1); _IdxWritePtr[2] = (ImDrawIdx)(idx+2);
788
_IdxWritePtr[3] = idx; _IdxWritePtr[4] = (ImDrawIdx)(idx+2); _IdxWritePtr[5] = (ImDrawIdx)(idx+3);
789
_VtxWritePtr[0].pos = a; _VtxWritePtr[0].uv = uv_a; _VtxWritePtr[0].col = col;
790
_VtxWritePtr[1].pos = b; _VtxWritePtr[1].uv = uv_b; _VtxWritePtr[1].col = col;
791
_VtxWritePtr[2].pos = c; _VtxWritePtr[2].uv = uv_c; _VtxWritePtr[2].col = col;
792
_VtxWritePtr[3].pos = d; _VtxWritePtr[3].uv = uv_d; _VtxWritePtr[3].col = col;
793
_VtxWritePtr += 4;
794
_VtxCurrentIdx += 4;
795
_IdxWritePtr += 6;
796
}
797
798
// On AddPolyline() and AddConvexPolyFilled() we intentionally avoid using ImVec2 and superfluous function calls to optimize debug/non-inlined builds.
799
// - Those macros expects l-values and need to be used as their own statement.
800
// - Those macros are intentionally not surrounded by the 'do {} while (0)' idiom because even that translates to runtime with debug compilers.
801
#define IM_NORMALIZE2F_OVER_ZERO(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImRsqrt(d2); VX *= inv_len; VY *= inv_len; } } (void)0
802
#define IM_FIXNORMAL2F_MAX_INVLEN2 100.0f // 500.0f (see #4053, #3366)
803
#define IM_FIXNORMAL2F(VX,VY) { float d2 = VX*VX + VY*VY; if (d2 > 0.000001f) { float inv_len2 = 1.0f / d2; if (inv_len2 > IM_FIXNORMAL2F_MAX_INVLEN2) inv_len2 = IM_FIXNORMAL2F_MAX_INVLEN2; VX *= inv_len2; VY *= inv_len2; } } (void)0
804
805
// TODO: Thickness anti-aliased lines cap are missing their AA fringe.
806
// We avoid using the ImVec2 math operators here to reduce cost to a minimum for debug/non-inlined builds.
807
void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 col, ImDrawFlags flags, float thickness)
808
{
809
if (points_count < 2 || (col & IM_COL32_A_MASK) == 0)
810
return;
811
812
const bool closed = (flags & ImDrawFlags_Closed) != 0;
813
const ImVec2 opaque_uv = _Data->TexUvWhitePixel;
814
const int count = closed ? points_count : points_count - 1; // The number of line segments we need to draw
815
const bool thick_line = (thickness > _FringeScale);
816
817
if (Flags & ImDrawListFlags_AntiAliasedLines)
818
{
819
// Anti-aliased stroke
820
const float AA_SIZE = _FringeScale;
821
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
822
823
// Thicknesses <1.0 should behave like thickness 1.0
824
thickness = ImMax(thickness, 1.0f);
825
const int integer_thickness = (int)thickness;
826
const float fractional_thickness = thickness - integer_thickness;
827
828
// Do we want to draw this line using a texture?
829
// - For now, only draw integer-width lines using textures to avoid issues with the way scaling occurs, could be improved.
830
// - If AA_SIZE is not 1.0f we cannot use the texture path.
831
const bool use_texture = (Flags & ImDrawListFlags_AntiAliasedLinesUseTex) && (integer_thickness < IM_DRAWLIST_TEX_LINES_WIDTH_MAX) && (fractional_thickness <= 0.00001f) && (AA_SIZE == 1.0f);
832
833
// We should never hit this, because NewFrame() doesn't set ImDrawListFlags_AntiAliasedLinesUseTex unless ImFontAtlasFlags_NoBakedLines is off
834
IM_ASSERT_PARANOID(!use_texture || !(_Data->Font->OwnerAtlas->Flags & ImFontAtlasFlags_NoBakedLines));
835
836
const int idx_count = use_texture ? (count * 6) : (thick_line ? count * 18 : count * 12);
837
const int vtx_count = use_texture ? (points_count * 2) : (thick_line ? points_count * 4 : points_count * 3);
838
PrimReserve(idx_count, vtx_count);
839
840
// Temporary buffer
841
// The first <points_count> items are normals at each line point, then after that there are either 2 or 4 temp points for each line point
842
_Data->TempBuffer.reserve_discard(points_count * ((use_texture || !thick_line) ? 3 : 5));
843
ImVec2* temp_normals = _Data->TempBuffer.Data;
844
ImVec2* temp_points = temp_normals + points_count;
845
846
// Calculate normals (tangents) for each line segment
847
for (int i1 = 0; i1 < count; i1++)
848
{
849
const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1;
850
float dx = points[i2].x - points[i1].x;
851
float dy = points[i2].y - points[i1].y;
852
IM_NORMALIZE2F_OVER_ZERO(dx, dy);
853
temp_normals[i1].x = dy;
854
temp_normals[i1].y = -dx;
855
}
856
if (!closed)
857
temp_normals[points_count - 1] = temp_normals[points_count - 2];
858
859
// If we are drawing a one-pixel-wide line without a texture, or a textured line of any width, we only need 2 or 3 vertices per point
860
if (use_texture || !thick_line)
861
{
862
// [PATH 1] Texture-based lines (thick or non-thick)
863
// [PATH 2] Non texture-based lines (non-thick)
864
865
// The width of the geometry we need to draw - this is essentially <thickness> pixels for the line itself, plus "one pixel" for AA.
866
// - In the texture-based path, we don't use AA_SIZE here because the +1 is tied to the generated texture
867
// (see ImFontAtlasBuildRenderLinesTexData() function), and so alternate values won't work without changes to that code.
868
// - In the non texture-based paths, we would allow AA_SIZE to potentially be != 1.0f with a patch (e.g. fringe_scale patch to
869
// allow scaling geometry while preserving one-screen-pixel AA fringe).
870
const float half_draw_size = use_texture ? ((thickness * 0.5f) + 1) : AA_SIZE;
871
872
// If line is not closed, the first and last points need to be generated differently as there are no normals to blend
873
if (!closed)
874
{
875
temp_points[0] = points[0] + temp_normals[0] * half_draw_size;
876
temp_points[1] = points[0] - temp_normals[0] * half_draw_size;
877
temp_points[(points_count-1)*2+0] = points[points_count-1] + temp_normals[points_count-1] * half_draw_size;
878
temp_points[(points_count-1)*2+1] = points[points_count-1] - temp_normals[points_count-1] * half_draw_size;
879
}
880
881
// Generate the indices to form a number of triangles for each line segment, and the vertices for the line edges
882
// This takes points n and n+1 and writes into n+1, with the first point in a closed line being generated from the final one (as n+1 wraps)
883
// FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
884
unsigned int idx1 = _VtxCurrentIdx; // Vertex index for start of line segment
885
for (int i1 = 0; i1 < count; i1++) // i1 is the first point of the line segment
886
{
887
const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1; // i2 is the second point of the line segment
888
const unsigned int idx2 = ((i1 + 1) == points_count) ? _VtxCurrentIdx : (idx1 + (use_texture ? 2 : 3)); // Vertex index for end of segment
889
890
// Average normals
891
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
892
float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f;
893
IM_FIXNORMAL2F(dm_x, dm_y);
894
dm_x *= half_draw_size; // dm_x, dm_y are offset to the outer edge of the AA area
895
dm_y *= half_draw_size;
896
897
// Add temporary vertices for the outer edges
898
ImVec2* out_vtx = &temp_points[i2 * 2];
899
out_vtx[0].x = points[i2].x + dm_x;
900
out_vtx[0].y = points[i2].y + dm_y;
901
out_vtx[1].x = points[i2].x - dm_x;
902
out_vtx[1].y = points[i2].y - dm_y;
903
904
if (use_texture)
905
{
906
// Add indices for two triangles
907
_IdxWritePtr[0] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 1); // Right tri
908
_IdxWritePtr[3] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[4] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 0); // Left tri
909
_IdxWritePtr += 6;
910
}
911
else
912
{
913
// Add indexes for four triangles
914
_IdxWritePtr[0] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 2); // Right tri 1
915
_IdxWritePtr[3] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[4] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 0); // Right tri 2
916
_IdxWritePtr[6] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[7] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[8] = (ImDrawIdx)(idx1 + 0); // Left tri 1
917
_IdxWritePtr[9] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[10] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[11] = (ImDrawIdx)(idx2 + 1); // Left tri 2
918
_IdxWritePtr += 12;
919
}
920
921
idx1 = idx2;
922
}
923
924
// Add vertices for each point on the line
925
if (use_texture)
926
{
927
// If we're using textures we only need to emit the left/right edge vertices
928
ImVec4 tex_uvs = _Data->TexUvLines[integer_thickness];
929
/*if (fractional_thickness != 0.0f) // Currently always zero when use_texture==false!
930
{
931
const ImVec4 tex_uvs_1 = _Data->TexUvLines[integer_thickness + 1];
932
tex_uvs.x = tex_uvs.x + (tex_uvs_1.x - tex_uvs.x) * fractional_thickness; // inlined ImLerp()
933
tex_uvs.y = tex_uvs.y + (tex_uvs_1.y - tex_uvs.y) * fractional_thickness;
934
tex_uvs.z = tex_uvs.z + (tex_uvs_1.z - tex_uvs.z) * fractional_thickness;
935
tex_uvs.w = tex_uvs.w + (tex_uvs_1.w - tex_uvs.w) * fractional_thickness;
936
}*/
937
ImVec2 tex_uv0(tex_uvs.x, tex_uvs.y);
938
ImVec2 tex_uv1(tex_uvs.z, tex_uvs.w);
939
for (int i = 0; i < points_count; i++)
940
{
941
_VtxWritePtr[0].pos = temp_points[i * 2 + 0]; _VtxWritePtr[0].uv = tex_uv0; _VtxWritePtr[0].col = col; // Left-side outer edge
942
_VtxWritePtr[1].pos = temp_points[i * 2 + 1]; _VtxWritePtr[1].uv = tex_uv1; _VtxWritePtr[1].col = col; // Right-side outer edge
943
_VtxWritePtr += 2;
944
}
945
}
946
else
947
{
948
// If we're not using a texture, we need the center vertex as well
949
for (int i = 0; i < points_count; i++)
950
{
951
_VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col; // Center of line
952
_VtxWritePtr[1].pos = temp_points[i * 2 + 0]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col_trans; // Left-side outer edge
953
_VtxWritePtr[2].pos = temp_points[i * 2 + 1]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col_trans; // Right-side outer edge
954
_VtxWritePtr += 3;
955
}
956
}
957
}
958
else
959
{
960
// [PATH 2] Non texture-based lines (thick): we need to draw the solid line core and thus require four vertices per point
961
const float half_inner_thickness = (thickness - AA_SIZE) * 0.5f;
962
963
// If line is not closed, the first and last points need to be generated differently as there are no normals to blend
964
if (!closed)
965
{
966
const int points_last = points_count - 1;
967
temp_points[0] = points[0] + temp_normals[0] * (half_inner_thickness + AA_SIZE);
968
temp_points[1] = points[0] + temp_normals[0] * (half_inner_thickness);
969
temp_points[2] = points[0] - temp_normals[0] * (half_inner_thickness);
970
temp_points[3] = points[0] - temp_normals[0] * (half_inner_thickness + AA_SIZE);
971
temp_points[points_last * 4 + 0] = points[points_last] + temp_normals[points_last] * (half_inner_thickness + AA_SIZE);
972
temp_points[points_last * 4 + 1] = points[points_last] + temp_normals[points_last] * (half_inner_thickness);
973
temp_points[points_last * 4 + 2] = points[points_last] - temp_normals[points_last] * (half_inner_thickness);
974
temp_points[points_last * 4 + 3] = points[points_last] - temp_normals[points_last] * (half_inner_thickness + AA_SIZE);
975
}
976
977
// Generate the indices to form a number of triangles for each line segment, and the vertices for the line edges
978
// This takes points n and n+1 and writes into n+1, with the first point in a closed line being generated from the final one (as n+1 wraps)
979
// FIXME-OPT: Merge the different loops, possibly remove the temporary buffer.
980
unsigned int idx1 = _VtxCurrentIdx; // Vertex index for start of line segment
981
for (int i1 = 0; i1 < count; i1++) // i1 is the first point of the line segment
982
{
983
const int i2 = (i1 + 1) == points_count ? 0 : (i1 + 1); // i2 is the second point of the line segment
984
const unsigned int idx2 = (i1 + 1) == points_count ? _VtxCurrentIdx : (idx1 + 4); // Vertex index for end of segment
985
986
// Average normals
987
float dm_x = (temp_normals[i1].x + temp_normals[i2].x) * 0.5f;
988
float dm_y = (temp_normals[i1].y + temp_normals[i2].y) * 0.5f;
989
IM_FIXNORMAL2F(dm_x, dm_y);
990
float dm_out_x = dm_x * (half_inner_thickness + AA_SIZE);
991
float dm_out_y = dm_y * (half_inner_thickness + AA_SIZE);
992
float dm_in_x = dm_x * half_inner_thickness;
993
float dm_in_y = dm_y * half_inner_thickness;
994
995
// Add temporary vertices
996
ImVec2* out_vtx = &temp_points[i2 * 4];
997
out_vtx[0].x = points[i2].x + dm_out_x;
998
out_vtx[0].y = points[i2].y + dm_out_y;
999
out_vtx[1].x = points[i2].x + dm_in_x;
1000
out_vtx[1].y = points[i2].y + dm_in_y;
1001
out_vtx[2].x = points[i2].x - dm_in_x;
1002
out_vtx[2].y = points[i2].y - dm_in_y;
1003
out_vtx[3].x = points[i2].x - dm_out_x;
1004
out_vtx[3].y = points[i2].y - dm_out_y;
1005
1006
// Add indexes
1007
_IdxWritePtr[0] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[1] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[2] = (ImDrawIdx)(idx1 + 2);
1008
_IdxWritePtr[3] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[4] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[5] = (ImDrawIdx)(idx2 + 1);
1009
_IdxWritePtr[6] = (ImDrawIdx)(idx2 + 1); _IdxWritePtr[7] = (ImDrawIdx)(idx1 + 1); _IdxWritePtr[8] = (ImDrawIdx)(idx1 + 0);
1010
_IdxWritePtr[9] = (ImDrawIdx)(idx1 + 0); _IdxWritePtr[10] = (ImDrawIdx)(idx2 + 0); _IdxWritePtr[11] = (ImDrawIdx)(idx2 + 1);
1011
_IdxWritePtr[12] = (ImDrawIdx)(idx2 + 2); _IdxWritePtr[13] = (ImDrawIdx)(idx1 + 2); _IdxWritePtr[14] = (ImDrawIdx)(idx1 + 3);
1012
_IdxWritePtr[15] = (ImDrawIdx)(idx1 + 3); _IdxWritePtr[16] = (ImDrawIdx)(idx2 + 3); _IdxWritePtr[17] = (ImDrawIdx)(idx2 + 2);
1013
_IdxWritePtr += 18;
1014
1015
idx1 = idx2;
1016
}
1017
1018
// Add vertices
1019
for (int i = 0; i < points_count; i++)
1020
{
1021
_VtxWritePtr[0].pos = temp_points[i * 4 + 0]; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col_trans;
1022
_VtxWritePtr[1].pos = temp_points[i * 4 + 1]; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col;
1023
_VtxWritePtr[2].pos = temp_points[i * 4 + 2]; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col;
1024
_VtxWritePtr[3].pos = temp_points[i * 4 + 3]; _VtxWritePtr[3].uv = opaque_uv; _VtxWritePtr[3].col = col_trans;
1025
_VtxWritePtr += 4;
1026
}
1027
}
1028
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
1029
}
1030
else
1031
{
1032
// [PATH 4] Non texture-based, Non anti-aliased lines
1033
const int idx_count = count * 6;
1034
const int vtx_count = count * 4; // FIXME-OPT: Not sharing edges
1035
PrimReserve(idx_count, vtx_count);
1036
1037
for (int i1 = 0; i1 < count; i1++)
1038
{
1039
const int i2 = (i1 + 1) == points_count ? 0 : i1 + 1;
1040
const ImVec2& p1 = points[i1];
1041
const ImVec2& p2 = points[i2];
1042
1043
float dx = p2.x - p1.x;
1044
float dy = p2.y - p1.y;
1045
IM_NORMALIZE2F_OVER_ZERO(dx, dy);
1046
dx *= (thickness * 0.5f);
1047
dy *= (thickness * 0.5f);
1048
1049
_VtxWritePtr[0].pos.x = p1.x + dy; _VtxWritePtr[0].pos.y = p1.y - dx; _VtxWritePtr[0].uv = opaque_uv; _VtxWritePtr[0].col = col;
1050
_VtxWritePtr[1].pos.x = p2.x + dy; _VtxWritePtr[1].pos.y = p2.y - dx; _VtxWritePtr[1].uv = opaque_uv; _VtxWritePtr[1].col = col;
1051
_VtxWritePtr[2].pos.x = p2.x - dy; _VtxWritePtr[2].pos.y = p2.y + dx; _VtxWritePtr[2].uv = opaque_uv; _VtxWritePtr[2].col = col;
1052
_VtxWritePtr[3].pos.x = p1.x - dy; _VtxWritePtr[3].pos.y = p1.y + dx; _VtxWritePtr[3].uv = opaque_uv; _VtxWritePtr[3].col = col;
1053
_VtxWritePtr += 4;
1054
1055
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + 1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + 2);
1056
_IdxWritePtr[3] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[4] = (ImDrawIdx)(_VtxCurrentIdx + 2); _IdxWritePtr[5] = (ImDrawIdx)(_VtxCurrentIdx + 3);
1057
_IdxWritePtr += 6;
1058
_VtxCurrentIdx += 4;
1059
}
1060
}
1061
}
1062
1063
// - We intentionally avoid using ImVec2 and its math operators here to reduce cost to a minimum for debug/non-inlined builds.
1064
// - Filled shapes must always use clockwise winding order. The anti-aliasing fringe depends on it. Counter-clockwise shapes will have "inward" anti-aliasing.
1065
void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_count, ImU32 col)
1066
{
1067
if (points_count < 3 || (col & IM_COL32_A_MASK) == 0)
1068
return;
1069
1070
const ImVec2 uv = _Data->TexUvWhitePixel;
1071
1072
if (Flags & ImDrawListFlags_AntiAliasedFill)
1073
{
1074
// Anti-aliased Fill
1075
const float AA_SIZE = _FringeScale;
1076
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
1077
const int idx_count = (points_count - 2)*3 + points_count * 6;
1078
const int vtx_count = (points_count * 2);
1079
PrimReserve(idx_count, vtx_count);
1080
1081
// Add indexes for fill
1082
unsigned int vtx_inner_idx = _VtxCurrentIdx;
1083
unsigned int vtx_outer_idx = _VtxCurrentIdx + 1;
1084
for (int i = 2; i < points_count; i++)
1085
{
1086
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + ((i - 1) << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx + (i << 1));
1087
_IdxWritePtr += 3;
1088
}
1089
1090
// Compute normals
1091
_Data->TempBuffer.reserve_discard(points_count);
1092
ImVec2* temp_normals = _Data->TempBuffer.Data;
1093
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
1094
{
1095
const ImVec2& p0 = points[i0];
1096
const ImVec2& p1 = points[i1];
1097
float dx = p1.x - p0.x;
1098
float dy = p1.y - p0.y;
1099
IM_NORMALIZE2F_OVER_ZERO(dx, dy);
1100
temp_normals[i0].x = dy;
1101
temp_normals[i0].y = -dx;
1102
}
1103
1104
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
1105
{
1106
// Average normals
1107
const ImVec2& n0 = temp_normals[i0];
1108
const ImVec2& n1 = temp_normals[i1];
1109
float dm_x = (n0.x + n1.x) * 0.5f;
1110
float dm_y = (n0.y + n1.y) * 0.5f;
1111
IM_FIXNORMAL2F(dm_x, dm_y);
1112
dm_x *= AA_SIZE * 0.5f;
1113
dm_y *= AA_SIZE * 0.5f;
1114
1115
// Add vertices
1116
_VtxWritePtr[0].pos.x = (points[i1].x - dm_x); _VtxWritePtr[0].pos.y = (points[i1].y - dm_y); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; // Inner
1117
_VtxWritePtr[1].pos.x = (points[i1].x + dm_x); _VtxWritePtr[1].pos.y = (points[i1].y + dm_y); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; // Outer
1118
_VtxWritePtr += 2;
1119
1120
// Add indexes for fringes
1121
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + (i0 << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1));
1122
_IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx + (i1 << 1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1));
1123
_IdxWritePtr += 6;
1124
}
1125
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
1126
}
1127
else
1128
{
1129
// Non Anti-aliased Fill
1130
const int idx_count = (points_count - 2)*3;
1131
const int vtx_count = points_count;
1132
PrimReserve(idx_count, vtx_count);
1133
for (int i = 0; i < vtx_count; i++)
1134
{
1135
_VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
1136
_VtxWritePtr++;
1137
}
1138
for (int i = 2; i < points_count; i++)
1139
{
1140
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + i - 1); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + i);
1141
_IdxWritePtr += 3;
1142
}
1143
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
1144
}
1145
}
1146
1147
void ImDrawList::_PathArcToFastEx(const ImVec2& center, float radius, int a_min_sample, int a_max_sample, int a_step)
1148
{
1149
if (radius < 0.5f)
1150
{
1151
_Path.push_back(center);
1152
return;
1153
}
1154
1155
// Calculate arc auto segment step size
1156
if (a_step <= 0)
1157
a_step = IM_DRAWLIST_ARCFAST_SAMPLE_MAX / _CalcCircleAutoSegmentCount(radius);
1158
1159
// Make sure we never do steps larger than one quarter of the circle
1160
a_step = ImClamp(a_step, 1, IM_DRAWLIST_ARCFAST_TABLE_SIZE / 4);
1161
1162
const int sample_range = ImAbs(a_max_sample - a_min_sample);
1163
const int a_next_step = a_step;
1164
1165
int samples = sample_range + 1;
1166
bool extra_max_sample = false;
1167
if (a_step > 1)
1168
{
1169
samples = sample_range / a_step + 1;
1170
const int overstep = sample_range % a_step;
1171
1172
if (overstep > 0)
1173
{
1174
extra_max_sample = true;
1175
samples++;
1176
1177
// When we have overstep to avoid awkwardly looking one long line and one tiny one at the end,
1178
// distribute first step range evenly between them by reducing first step size.
1179
if (sample_range > 0)
1180
a_step -= (a_step - overstep) / 2;
1181
}
1182
}
1183
1184
_Path.resize(_Path.Size + samples);
1185
ImVec2* out_ptr = _Path.Data + (_Path.Size - samples);
1186
1187
int sample_index = a_min_sample;
1188
if (sample_index < 0 || sample_index >= IM_DRAWLIST_ARCFAST_SAMPLE_MAX)
1189
{
1190
sample_index = sample_index % IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1191
if (sample_index < 0)
1192
sample_index += IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1193
}
1194
1195
if (a_max_sample >= a_min_sample)
1196
{
1197
for (int a = a_min_sample; a <= a_max_sample; a += a_step, sample_index += a_step, a_step = a_next_step)
1198
{
1199
// a_step is clamped to IM_DRAWLIST_ARCFAST_SAMPLE_MAX, so we have guaranteed that it will not wrap over range twice or more
1200
if (sample_index >= IM_DRAWLIST_ARCFAST_SAMPLE_MAX)
1201
sample_index -= IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1202
1203
const ImVec2 s = _Data->ArcFastVtx[sample_index];
1204
out_ptr->x = center.x + s.x * radius;
1205
out_ptr->y = center.y + s.y * radius;
1206
out_ptr++;
1207
}
1208
}
1209
else
1210
{
1211
for (int a = a_min_sample; a >= a_max_sample; a -= a_step, sample_index -= a_step, a_step = a_next_step)
1212
{
1213
// a_step is clamped to IM_DRAWLIST_ARCFAST_SAMPLE_MAX, so we have guaranteed that it will not wrap over range twice or more
1214
if (sample_index < 0)
1215
sample_index += IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1216
1217
const ImVec2 s = _Data->ArcFastVtx[sample_index];
1218
out_ptr->x = center.x + s.x * radius;
1219
out_ptr->y = center.y + s.y * radius;
1220
out_ptr++;
1221
}
1222
}
1223
1224
if (extra_max_sample)
1225
{
1226
int normalized_max_sample = a_max_sample % IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1227
if (normalized_max_sample < 0)
1228
normalized_max_sample += IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1229
1230
const ImVec2 s = _Data->ArcFastVtx[normalized_max_sample];
1231
out_ptr->x = center.x + s.x * radius;
1232
out_ptr->y = center.y + s.y * radius;
1233
out_ptr++;
1234
}
1235
1236
IM_ASSERT_PARANOID(_Path.Data + _Path.Size == out_ptr);
1237
}
1238
1239
void ImDrawList::_PathArcToN(const ImVec2& center, float radius, float a_min, float a_max, int num_segments)
1240
{
1241
if (radius < 0.5f)
1242
{
1243
_Path.push_back(center);
1244
return;
1245
}
1246
1247
// Note that we are adding a point at both a_min and a_max.
1248
// If you are trying to draw a full closed circle you don't want the overlapping points!
1249
_Path.reserve(_Path.Size + (num_segments + 1));
1250
for (int i = 0; i <= num_segments; i++)
1251
{
1252
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
1253
_Path.push_back(ImVec2(center.x + ImCos(a) * radius, center.y + ImSin(a) * radius));
1254
}
1255
}
1256
1257
// 0: East, 3: South, 6: West, 9: North, 12: East
1258
void ImDrawList::PathArcToFast(const ImVec2& center, float radius, int a_min_of_12, int a_max_of_12)
1259
{
1260
if (radius < 0.5f)
1261
{
1262
_Path.push_back(center);
1263
return;
1264
}
1265
_PathArcToFastEx(center, radius, a_min_of_12 * IM_DRAWLIST_ARCFAST_SAMPLE_MAX / 12, a_max_of_12 * IM_DRAWLIST_ARCFAST_SAMPLE_MAX / 12, 0);
1266
}
1267
1268
void ImDrawList::PathArcTo(const ImVec2& center, float radius, float a_min, float a_max, int num_segments)
1269
{
1270
if (radius < 0.5f)
1271
{
1272
_Path.push_back(center);
1273
return;
1274
}
1275
1276
if (num_segments > 0)
1277
{
1278
_PathArcToN(center, radius, a_min, a_max, num_segments);
1279
return;
1280
}
1281
1282
// Automatic segment count
1283
if (radius <= _Data->ArcFastRadiusCutoff)
1284
{
1285
const bool a_is_reverse = a_max < a_min;
1286
1287
// We are going to use precomputed values for mid samples.
1288
// Determine first and last sample in lookup table that belong to the arc.
1289
const float a_min_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_min / (IM_PI * 2.0f);
1290
const float a_max_sample_f = IM_DRAWLIST_ARCFAST_SAMPLE_MAX * a_max / (IM_PI * 2.0f);
1291
1292
const int a_min_sample = a_is_reverse ? (int)ImFloor(a_min_sample_f) : (int)ImCeil(a_min_sample_f);
1293
const int a_max_sample = a_is_reverse ? (int)ImCeil(a_max_sample_f) : (int)ImFloor(a_max_sample_f);
1294
const int a_mid_samples = a_is_reverse ? ImMax(a_min_sample - a_max_sample, 0) : ImMax(a_max_sample - a_min_sample, 0);
1295
1296
const float a_min_segment_angle = a_min_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1297
const float a_max_segment_angle = a_max_sample * IM_PI * 2.0f / IM_DRAWLIST_ARCFAST_SAMPLE_MAX;
1298
const bool a_emit_start = ImAbs(a_min_segment_angle - a_min) >= 1e-5f;
1299
const bool a_emit_end = ImAbs(a_max - a_max_segment_angle) >= 1e-5f;
1300
1301
_Path.reserve(_Path.Size + (a_mid_samples + 1 + (a_emit_start ? 1 : 0) + (a_emit_end ? 1 : 0)));
1302
if (a_emit_start)
1303
_Path.push_back(ImVec2(center.x + ImCos(a_min) * radius, center.y + ImSin(a_min) * radius));
1304
if (a_mid_samples > 0)
1305
_PathArcToFastEx(center, radius, a_min_sample, a_max_sample, 0);
1306
if (a_emit_end)
1307
_Path.push_back(ImVec2(center.x + ImCos(a_max) * radius, center.y + ImSin(a_max) * radius));
1308
}
1309
else
1310
{
1311
const float arc_length = ImAbs(a_max - a_min);
1312
const int circle_segment_count = _CalcCircleAutoSegmentCount(radius);
1313
const int arc_segment_count = ImMax((int)ImCeil(circle_segment_count * arc_length / (IM_PI * 2.0f)), (int)(2.0f * IM_PI / arc_length));
1314
_PathArcToN(center, radius, a_min, a_max, arc_segment_count);
1315
}
1316
}
1317
1318
void ImDrawList::PathEllipticalArcTo(const ImVec2& center, const ImVec2& radius, float rot, float a_min, float a_max, int num_segments)
1319
{
1320
if (num_segments <= 0)
1321
num_segments = _CalcCircleAutoSegmentCount(ImMax(radius.x, radius.y)); // A bit pessimistic, maybe there's a better computation to do here.
1322
1323
_Path.reserve(_Path.Size + (num_segments + 1));
1324
1325
const float cos_rot = ImCos(rot);
1326
const float sin_rot = ImSin(rot);
1327
for (int i = 0; i <= num_segments; i++)
1328
{
1329
const float a = a_min + ((float)i / (float)num_segments) * (a_max - a_min);
1330
ImVec2 point(ImCos(a) * radius.x, ImSin(a) * radius.y);
1331
const ImVec2 rel((point.x * cos_rot) - (point.y * sin_rot), (point.x * sin_rot) + (point.y * cos_rot));
1332
point.x = rel.x + center.x;
1333
point.y = rel.y + center.y;
1334
_Path.push_back(point);
1335
}
1336
}
1337
1338
ImVec2 ImBezierCubicCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, float t)
1339
{
1340
float u = 1.0f - t;
1341
float w1 = u * u * u;
1342
float w2 = 3 * u * u * t;
1343
float w3 = 3 * u * t * t;
1344
float w4 = t * t * t;
1345
return ImVec2(w1 * p1.x + w2 * p2.x + w3 * p3.x + w4 * p4.x, w1 * p1.y + w2 * p2.y + w3 * p3.y + w4 * p4.y);
1346
}
1347
1348
ImVec2 ImBezierQuadraticCalc(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, float t)
1349
{
1350
float u = 1.0f - t;
1351
float w1 = u * u;
1352
float w2 = 2 * u * t;
1353
float w3 = t * t;
1354
return ImVec2(w1 * p1.x + w2 * p2.x + w3 * p3.x, w1 * p1.y + w2 * p2.y + w3 * p3.y);
1355
}
1356
1357
// Closely mimics ImBezierCubicClosestPointCasteljau() in imgui.cpp
1358
static void PathBezierCubicCurveToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float tess_tol, int level)
1359
{
1360
float dx = x4 - x1;
1361
float dy = y4 - y1;
1362
float d2 = (x2 - x4) * dy - (y2 - y4) * dx;
1363
float d3 = (x3 - x4) * dy - (y3 - y4) * dx;
1364
d2 = (d2 >= 0) ? d2 : -d2;
1365
d3 = (d3 >= 0) ? d3 : -d3;
1366
if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy))
1367
{
1368
path->push_back(ImVec2(x4, y4));
1369
}
1370
else if (level < 10)
1371
{
1372
float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f;
1373
float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f;
1374
float x34 = (x3 + x4) * 0.5f, y34 = (y3 + y4) * 0.5f;
1375
float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f;
1376
float x234 = (x23 + x34) * 0.5f, y234 = (y23 + y34) * 0.5f;
1377
float x1234 = (x123 + x234) * 0.5f, y1234 = (y123 + y234) * 0.5f;
1378
PathBezierCubicCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1);
1379
PathBezierCubicCurveToCasteljau(path, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1);
1380
}
1381
}
1382
1383
static void PathBezierQuadraticCurveToCasteljau(ImVector<ImVec2>* path, float x1, float y1, float x2, float y2, float x3, float y3, float tess_tol, int level)
1384
{
1385
float dx = x3 - x1, dy = y3 - y1;
1386
float det = (x2 - x3) * dy - (y2 - y3) * dx;
1387
if (det * det * 4.0f < tess_tol * (dx * dx + dy * dy))
1388
{
1389
path->push_back(ImVec2(x3, y3));
1390
}
1391
else if (level < 10)
1392
{
1393
float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f;
1394
float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f;
1395
float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f;
1396
PathBezierQuadraticCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, tess_tol, level + 1);
1397
PathBezierQuadraticCurveToCasteljau(path, x123, y123, x23, y23, x3, y3, tess_tol, level + 1);
1398
}
1399
}
1400
1401
void ImDrawList::PathBezierCubicCurveTo(const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, int num_segments)
1402
{
1403
ImVec2 p1 = _Path.back();
1404
if (num_segments == 0)
1405
{
1406
IM_ASSERT(_Data->CurveTessellationTol > 0.0f);
1407
PathBezierCubicCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, p4.x, p4.y, _Data->CurveTessellationTol, 0); // Auto-tessellated
1408
}
1409
else
1410
{
1411
float t_step = 1.0f / (float)num_segments;
1412
for (int i_step = 1; i_step <= num_segments; i_step++)
1413
_Path.push_back(ImBezierCubicCalc(p1, p2, p3, p4, t_step * i_step));
1414
}
1415
}
1416
1417
void ImDrawList::PathBezierQuadraticCurveTo(const ImVec2& p2, const ImVec2& p3, int num_segments)
1418
{
1419
ImVec2 p1 = _Path.back();
1420
if (num_segments == 0)
1421
{
1422
IM_ASSERT(_Data->CurveTessellationTol > 0.0f);
1423
PathBezierQuadraticCurveToCasteljau(&_Path, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, _Data->CurveTessellationTol, 0);// Auto-tessellated
1424
}
1425
else
1426
{
1427
float t_step = 1.0f / (float)num_segments;
1428
for (int i_step = 1; i_step <= num_segments; i_step++)
1429
_Path.push_back(ImBezierQuadraticCalc(p1, p2, p3, t_step * i_step));
1430
}
1431
}
1432
1433
static inline ImDrawFlags FixRectCornerFlags(ImDrawFlags flags)
1434
{
1435
/*
1436
IM_STATIC_ASSERT(ImDrawFlags_RoundCornersTopLeft == (1 << 4));
1437
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1438
// Obsoleted in 1.82 (from February 2021). This code was stripped/simplified and mostly commented in 1.90 (from September 2023)
1439
// - Legacy Support for hard coded ~0 (used to be a suggested equivalent to ImDrawCornerFlags_All)
1440
if (flags == ~0) { return ImDrawFlags_RoundCornersAll; }
1441
// - Legacy Support for hard coded 0x01 to 0x0F (matching 15 out of 16 old flags combinations). Read details in older version of this code.
1442
if (flags >= 0x01 && flags <= 0x0F) { return (flags << 4); }
1443
// We cannot support hard coded 0x00 with 'float rounding > 0.0f' --> replace with ImDrawFlags_RoundCornersNone or use 'float rounding = 0.0f'
1444
#endif
1445
*/
1446
// If this assert triggers, please update your code replacing hardcoded values with new ImDrawFlags_RoundCorners* values.
1447
// Note that ImDrawFlags_Closed (== 0x01) is an invalid flag for AddRect(), AddRectFilled(), PathRect() etc. anyway.
1448
// See details in 1.82 Changelog as well as 2021/03/12 and 2023/09/08 entries in "API BREAKING CHANGES" section.
1449
IM_ASSERT((flags & 0x0F) == 0 && "Misuse of legacy hardcoded ImDrawCornerFlags values!");
1450
1451
if ((flags & ImDrawFlags_RoundCornersMask_) == 0)
1452
flags |= ImDrawFlags_RoundCornersAll;
1453
1454
return flags;
1455
}
1456
1457
void ImDrawList::PathRect(const ImVec2& a, const ImVec2& b, float rounding, ImDrawFlags flags)
1458
{
1459
if (rounding >= 0.5f)
1460
{
1461
flags = FixRectCornerFlags(flags);
1462
rounding = ImMin(rounding, ImFabs(b.x - a.x) * (((flags & ImDrawFlags_RoundCornersTop) == ImDrawFlags_RoundCornersTop) || ((flags & ImDrawFlags_RoundCornersBottom) == ImDrawFlags_RoundCornersBottom) ? 0.5f : 1.0f) - 1.0f);
1463
rounding = ImMin(rounding, ImFabs(b.y - a.y) * (((flags & ImDrawFlags_RoundCornersLeft) == ImDrawFlags_RoundCornersLeft) || ((flags & ImDrawFlags_RoundCornersRight) == ImDrawFlags_RoundCornersRight) ? 0.5f : 1.0f) - 1.0f);
1464
}
1465
if (rounding < 0.5f || (flags & ImDrawFlags_RoundCornersMask_) == ImDrawFlags_RoundCornersNone)
1466
{
1467
PathLineTo(a);
1468
PathLineTo(ImVec2(b.x, a.y));
1469
PathLineTo(b);
1470
PathLineTo(ImVec2(a.x, b.y));
1471
}
1472
else
1473
{
1474
const float rounding_tl = (flags & ImDrawFlags_RoundCornersTopLeft) ? rounding : 0.0f;
1475
const float rounding_tr = (flags & ImDrawFlags_RoundCornersTopRight) ? rounding : 0.0f;
1476
const float rounding_br = (flags & ImDrawFlags_RoundCornersBottomRight) ? rounding : 0.0f;
1477
const float rounding_bl = (flags & ImDrawFlags_RoundCornersBottomLeft) ? rounding : 0.0f;
1478
PathArcToFast(ImVec2(a.x + rounding_tl, a.y + rounding_tl), rounding_tl, 6, 9);
1479
PathArcToFast(ImVec2(b.x - rounding_tr, a.y + rounding_tr), rounding_tr, 9, 12);
1480
PathArcToFast(ImVec2(b.x - rounding_br, b.y - rounding_br), rounding_br, 0, 3);
1481
PathArcToFast(ImVec2(a.x + rounding_bl, b.y - rounding_bl), rounding_bl, 3, 6);
1482
}
1483
}
1484
1485
void ImDrawList::AddLine(const ImVec2& p1, const ImVec2& p2, ImU32 col, float thickness)
1486
{
1487
if ((col & IM_COL32_A_MASK) == 0)
1488
return;
1489
PathLineTo(p1 + ImVec2(0.5f, 0.5f));
1490
PathLineTo(p2 + ImVec2(0.5f, 0.5f));
1491
PathStroke(col, 0, thickness);
1492
}
1493
1494
// p_min = upper-left, p_max = lower-right
1495
// Note we don't render 1 pixels sized rectangles properly.
1496
void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawFlags flags, float thickness)
1497
{
1498
if ((col & IM_COL32_A_MASK) == 0)
1499
return;
1500
if (Flags & ImDrawListFlags_AntiAliasedLines)
1501
PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.50f, 0.50f), rounding, flags);
1502
else
1503
PathRect(p_min + ImVec2(0.50f, 0.50f), p_max - ImVec2(0.49f, 0.49f), rounding, flags); // Better looking lower-right corner and rounded non-AA shapes.
1504
PathStroke(col, ImDrawFlags_Closed, thickness);
1505
}
1506
1507
void ImDrawList::AddRectFilled(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, float rounding, ImDrawFlags flags)
1508
{
1509
if ((col & IM_COL32_A_MASK) == 0)
1510
return;
1511
if (rounding < 0.5f || (flags & ImDrawFlags_RoundCornersMask_) == ImDrawFlags_RoundCornersNone)
1512
{
1513
PrimReserve(6, 4);
1514
PrimRect(p_min, p_max, col);
1515
}
1516
else
1517
{
1518
PathRect(p_min, p_max, rounding, flags);
1519
PathFillConvex(col);
1520
}
1521
}
1522
1523
// p_min = upper-left, p_max = lower-right
1524
void ImDrawList::AddRectFilledMultiColor(const ImVec2& p_min, const ImVec2& p_max, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
1525
{
1526
if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) & IM_COL32_A_MASK) == 0)
1527
return;
1528
1529
const ImVec2 uv = _Data->TexUvWhitePixel;
1530
PrimReserve(6, 4);
1531
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 1)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2));
1532
PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 2)); PrimWriteIdx((ImDrawIdx)(_VtxCurrentIdx + 3));
1533
PrimWriteVtx(p_min, uv, col_upr_left);
1534
PrimWriteVtx(ImVec2(p_max.x, p_min.y), uv, col_upr_right);
1535
PrimWriteVtx(p_max, uv, col_bot_right);
1536
PrimWriteVtx(ImVec2(p_min.x, p_max.y), uv, col_bot_left);
1537
}
1538
1539
void ImDrawList::AddQuad(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness)
1540
{
1541
if ((col & IM_COL32_A_MASK) == 0)
1542
return;
1543
1544
PathLineTo(p1);
1545
PathLineTo(p2);
1546
PathLineTo(p3);
1547
PathLineTo(p4);
1548
PathStroke(col, ImDrawFlags_Closed, thickness);
1549
}
1550
1551
void ImDrawList::AddQuadFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col)
1552
{
1553
if ((col & IM_COL32_A_MASK) == 0)
1554
return;
1555
1556
PathLineTo(p1);
1557
PathLineTo(p2);
1558
PathLineTo(p3);
1559
PathLineTo(p4);
1560
PathFillConvex(col);
1561
}
1562
1563
void ImDrawList::AddTriangle(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness)
1564
{
1565
if ((col & IM_COL32_A_MASK) == 0)
1566
return;
1567
1568
PathLineTo(p1);
1569
PathLineTo(p2);
1570
PathLineTo(p3);
1571
PathStroke(col, ImDrawFlags_Closed, thickness);
1572
}
1573
1574
void ImDrawList::AddTriangleFilled(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col)
1575
{
1576
if ((col & IM_COL32_A_MASK) == 0)
1577
return;
1578
1579
PathLineTo(p1);
1580
PathLineTo(p2);
1581
PathLineTo(p3);
1582
PathFillConvex(col);
1583
}
1584
1585
void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness)
1586
{
1587
if ((col & IM_COL32_A_MASK) == 0 || radius < 0.5f)
1588
return;
1589
1590
if (num_segments <= 0)
1591
{
1592
// Use arc with automatic segment count
1593
_PathArcToFastEx(center, radius - 0.5f, 0, IM_DRAWLIST_ARCFAST_SAMPLE_MAX, 0);
1594
_Path.Size--;
1595
}
1596
else
1597
{
1598
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
1599
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
1600
1601
// Because we are filling a closed shape we remove 1 from the count of segments/points
1602
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
1603
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
1604
}
1605
1606
PathStroke(col, ImDrawFlags_Closed, thickness);
1607
}
1608
1609
void ImDrawList::AddCircleFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
1610
{
1611
if ((col & IM_COL32_A_MASK) == 0 || radius < 0.5f)
1612
return;
1613
1614
if (num_segments <= 0)
1615
{
1616
// Use arc with automatic segment count
1617
_PathArcToFastEx(center, radius, 0, IM_DRAWLIST_ARCFAST_SAMPLE_MAX, 0);
1618
_Path.Size--;
1619
}
1620
else
1621
{
1622
// Explicit segment count (still clamp to avoid drawing insanely tessellated shapes)
1623
num_segments = ImClamp(num_segments, 3, IM_DRAWLIST_CIRCLE_AUTO_SEGMENT_MAX);
1624
1625
// Because we are filling a closed shape we remove 1 from the count of segments/points
1626
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
1627
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
1628
}
1629
1630
PathFillConvex(col);
1631
}
1632
1633
// Guaranteed to honor 'num_segments'
1634
void ImDrawList::AddNgon(const ImVec2& center, float radius, ImU32 col, int num_segments, float thickness)
1635
{
1636
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
1637
return;
1638
1639
// Because we are filling a closed shape we remove 1 from the count of segments/points
1640
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
1641
PathArcTo(center, radius - 0.5f, 0.0f, a_max, num_segments - 1);
1642
PathStroke(col, ImDrawFlags_Closed, thickness);
1643
}
1644
1645
// Guaranteed to honor 'num_segments'
1646
void ImDrawList::AddNgonFilled(const ImVec2& center, float radius, ImU32 col, int num_segments)
1647
{
1648
if ((col & IM_COL32_A_MASK) == 0 || num_segments <= 2)
1649
return;
1650
1651
// Because we are filling a closed shape we remove 1 from the count of segments/points
1652
const float a_max = (IM_PI * 2.0f) * ((float)num_segments - 1.0f) / (float)num_segments;
1653
PathArcTo(center, radius, 0.0f, a_max, num_segments - 1);
1654
PathFillConvex(col);
1655
}
1656
1657
// Ellipse
1658
void ImDrawList::AddEllipse(const ImVec2& center, const ImVec2& radius, ImU32 col, float rot, int num_segments, float thickness)
1659
{
1660
if ((col & IM_COL32_A_MASK) == 0)
1661
return;
1662
1663
if (num_segments <= 0)
1664
num_segments = _CalcCircleAutoSegmentCount(ImMax(radius.x, radius.y)); // A bit pessimistic, maybe there's a better computation to do here.
1665
1666
// Because we are filling a closed shape we remove 1 from the count of segments/points
1667
const float a_max = IM_PI * 2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
1668
PathEllipticalArcTo(center, radius, rot, 0.0f, a_max, num_segments - 1);
1669
PathStroke(col, true, thickness);
1670
}
1671
1672
void ImDrawList::AddEllipseFilled(const ImVec2& center, const ImVec2& radius, ImU32 col, float rot, int num_segments)
1673
{
1674
if ((col & IM_COL32_A_MASK) == 0)
1675
return;
1676
1677
if (num_segments <= 0)
1678
num_segments = _CalcCircleAutoSegmentCount(ImMax(radius.x, radius.y)); // A bit pessimistic, maybe there's a better computation to do here.
1679
1680
// Because we are filling a closed shape we remove 1 from the count of segments/points
1681
const float a_max = IM_PI * 2.0f * ((float)num_segments - 1.0f) / (float)num_segments;
1682
PathEllipticalArcTo(center, radius, rot, 0.0f, a_max, num_segments - 1);
1683
PathFillConvex(col);
1684
}
1685
1686
// Cubic Bezier takes 4 controls points
1687
void ImDrawList::AddBezierCubic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, ImU32 col, float thickness, int num_segments)
1688
{
1689
if ((col & IM_COL32_A_MASK) == 0)
1690
return;
1691
1692
PathLineTo(p1);
1693
PathBezierCubicCurveTo(p2, p3, p4, num_segments);
1694
PathStroke(col, 0, thickness);
1695
}
1696
1697
// Quadratic Bezier takes 3 controls points
1698
void ImDrawList::AddBezierQuadratic(const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, ImU32 col, float thickness, int num_segments)
1699
{
1700
if ((col & IM_COL32_A_MASK) == 0)
1701
return;
1702
1703
PathLineTo(p1);
1704
PathBezierQuadraticCurveTo(p2, p3, num_segments);
1705
PathStroke(col, 0, thickness);
1706
}
1707
1708
void ImDrawList::AddText(ImFont* font, float font_size, float font_weight, const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end, float wrap_width, const ImVec4* cpu_fine_clip_rect)
1709
{
1710
if ((col & IM_COL32_A_MASK) == 0)
1711
return;
1712
1713
// Accept null ranges
1714
if (text_begin == text_end || text_begin[0] == 0)
1715
return;
1716
// No need to strlen() here: font->RenderText() will do it and may early out.
1717
1718
// Pull default font/size from the shared ImDrawListSharedData instance
1719
if (font == NULL)
1720
font = _Data->Font;
1721
if (font_size == 0.0f)
1722
font_size = _Data->FontSize;
1723
if (font_weight == 0.0f)
1724
font_weight = _Data->FontWeight;
1725
1726
ImVec4 clip_rect = _CmdHeader.ClipRect;
1727
if (cpu_fine_clip_rect)
1728
{
1729
clip_rect.x = ImMax(clip_rect.x, cpu_fine_clip_rect->x);
1730
clip_rect.y = ImMax(clip_rect.y, cpu_fine_clip_rect->y);
1731
clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z);
1732
clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w);
1733
}
1734
font->RenderText(this, font_size, font_weight, pos, col, clip_rect, text_begin, text_end, wrap_width, (cpu_fine_clip_rect != NULL) ? ImDrawTextFlags_CpuFineClip : ImDrawTextFlags_None);
1735
}
1736
1737
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
1738
{
1739
AddText(_Data->Font, _Data->FontSize, _Data->FontWeight, pos, col, text_begin, text_end);
1740
}
1741
1742
void ImDrawList::AddImage(ImTextureRef tex_ref, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col)
1743
{
1744
if ((col & IM_COL32_A_MASK) == 0)
1745
return;
1746
1747
const bool push_texture_id = tex_ref != _CmdHeader.TexRef;
1748
if (push_texture_id)
1749
PushTexture(tex_ref);
1750
1751
PrimReserve(6, 4);
1752
PrimRectUV(p_min, p_max, uv_min, uv_max, col);
1753
1754
if (push_texture_id)
1755
PopTexture();
1756
}
1757
1758
void ImDrawList::AddImageQuad(ImTextureRef tex_ref, const ImVec2& p1, const ImVec2& p2, const ImVec2& p3, const ImVec2& p4, const ImVec2& uv1, const ImVec2& uv2, const ImVec2& uv3, const ImVec2& uv4, ImU32 col)
1759
{
1760
if ((col & IM_COL32_A_MASK) == 0)
1761
return;
1762
1763
const bool push_texture_id = tex_ref != _CmdHeader.TexRef;
1764
if (push_texture_id)
1765
PushTexture(tex_ref);
1766
1767
PrimReserve(6, 4);
1768
PrimQuadUV(p1, p2, p3, p4, uv1, uv2, uv3, uv4, col);
1769
1770
if (push_texture_id)
1771
PopTexture();
1772
}
1773
1774
void ImDrawList::AddImageRounded(ImTextureRef tex_ref, const ImVec2& p_min, const ImVec2& p_max, const ImVec2& uv_min, const ImVec2& uv_max, ImU32 col, float rounding, ImDrawFlags flags)
1775
{
1776
if ((col & IM_COL32_A_MASK) == 0)
1777
return;
1778
1779
flags = FixRectCornerFlags(flags);
1780
if (rounding < 0.5f || (flags & ImDrawFlags_RoundCornersMask_) == ImDrawFlags_RoundCornersNone)
1781
{
1782
AddImage(tex_ref, p_min, p_max, uv_min, uv_max, col);
1783
return;
1784
}
1785
1786
const bool push_texture_id = tex_ref != _CmdHeader.TexRef;
1787
if (push_texture_id)
1788
PushTexture(tex_ref);
1789
1790
int vert_start_idx = VtxBuffer.Size;
1791
PathRect(p_min, p_max, rounding, flags);
1792
PathFillConvex(col);
1793
int vert_end_idx = VtxBuffer.Size;
1794
ImGui::ShadeVertsLinearUV(this, vert_start_idx, vert_end_idx, p_min, p_max, uv_min, uv_max, true);
1795
1796
if (push_texture_id)
1797
PopTexture();
1798
}
1799
1800
//-----------------------------------------------------------------------------
1801
// [SECTION] ImTriangulator, ImDrawList concave polygon fill
1802
//-----------------------------------------------------------------------------
1803
// Triangulate concave polygons. Based on "Triangulation by Ear Clipping" paper, O(N^2) complexity.
1804
// Reference: https://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf
1805
// Provided as a convenience for user but not used by main library.
1806
//-----------------------------------------------------------------------------
1807
// - ImTriangulator [Internal]
1808
// - AddConcavePolyFilled()
1809
//-----------------------------------------------------------------------------
1810
1811
enum ImTriangulatorNodeType
1812
{
1813
ImTriangulatorNodeType_Convex,
1814
ImTriangulatorNodeType_Ear,
1815
ImTriangulatorNodeType_Reflex
1816
};
1817
1818
struct ImTriangulatorNode
1819
{
1820
ImTriangulatorNodeType Type;
1821
int Index;
1822
ImVec2 Pos;
1823
ImTriangulatorNode* Next;
1824
ImTriangulatorNode* Prev;
1825
1826
void Unlink() { Next->Prev = Prev; Prev->Next = Next; }
1827
};
1828
1829
struct ImTriangulatorNodeSpan
1830
{
1831
ImTriangulatorNode** Data = NULL;
1832
int Size = 0;
1833
1834
void push_back(ImTriangulatorNode* node) { Data[Size++] = node; }
1835
void find_erase_unsorted(int idx) { for (int i = Size - 1; i >= 0; i--) if (Data[i]->Index == idx) { Data[i] = Data[Size - 1]; Size--; return; } }
1836
};
1837
1838
struct ImTriangulator
1839
{
1840
static int EstimateTriangleCount(int points_count) { return (points_count < 3) ? 0 : points_count - 2; }
1841
static int EstimateScratchBufferSize(int points_count) { return sizeof(ImTriangulatorNode) * points_count + sizeof(ImTriangulatorNode*) * points_count * 2; }
1842
1843
void Init(const ImVec2* points, int points_count, void* scratch_buffer);
1844
void GetNextTriangle(unsigned int out_triangle[3]); // Return relative indexes for next triangle
1845
1846
// Internal functions
1847
void BuildNodes(const ImVec2* points, int points_count);
1848
void BuildReflexes();
1849
void BuildEars();
1850
void FlipNodeList();
1851
bool IsEar(int i0, int i1, int i2, const ImVec2& v0, const ImVec2& v1, const ImVec2& v2) const;
1852
void ReclassifyNode(ImTriangulatorNode* node);
1853
1854
// Internal members
1855
int _TrianglesLeft = 0;
1856
ImTriangulatorNode* _Nodes = NULL;
1857
ImTriangulatorNodeSpan _Ears;
1858
ImTriangulatorNodeSpan _Reflexes;
1859
};
1860
1861
// Distribute storage for nodes, ears and reflexes.
1862
// FIXME-OPT: if everything is convex, we could report it to caller and let it switch to an convex renderer
1863
// (this would require first building reflexes to bail to convex if empty, without even building nodes)
1864
void ImTriangulator::Init(const ImVec2* points, int points_count, void* scratch_buffer)
1865
{
1866
IM_ASSERT(scratch_buffer != NULL && points_count >= 3);
1867
_TrianglesLeft = EstimateTriangleCount(points_count);
1868
_Nodes = (ImTriangulatorNode*)scratch_buffer; // points_count x Node
1869
_Ears.Data = (ImTriangulatorNode**)(_Nodes + points_count); // points_count x Node*
1870
_Reflexes.Data = (ImTriangulatorNode**)(_Nodes + points_count) + points_count; // points_count x Node*
1871
BuildNodes(points, points_count);
1872
BuildReflexes();
1873
BuildEars();
1874
}
1875
1876
void ImTriangulator::BuildNodes(const ImVec2* points, int points_count)
1877
{
1878
for (int i = 0; i < points_count; i++)
1879
{
1880
_Nodes[i].Type = ImTriangulatorNodeType_Convex;
1881
_Nodes[i].Index = i;
1882
_Nodes[i].Pos = points[i];
1883
_Nodes[i].Next = _Nodes + i + 1;
1884
_Nodes[i].Prev = _Nodes + i - 1;
1885
}
1886
_Nodes[0].Prev = _Nodes + points_count - 1;
1887
_Nodes[points_count - 1].Next = _Nodes;
1888
}
1889
1890
void ImTriangulator::BuildReflexes()
1891
{
1892
ImTriangulatorNode* n1 = _Nodes;
1893
for (int i = _TrianglesLeft; i >= 0; i--, n1 = n1->Next)
1894
{
1895
if (ImTriangleIsClockwise(n1->Prev->Pos, n1->Pos, n1->Next->Pos))
1896
continue;
1897
n1->Type = ImTriangulatorNodeType_Reflex;
1898
_Reflexes.push_back(n1);
1899
}
1900
}
1901
1902
void ImTriangulator::BuildEars()
1903
{
1904
ImTriangulatorNode* n1 = _Nodes;
1905
for (int i = _TrianglesLeft; i >= 0; i--, n1 = n1->Next)
1906
{
1907
if (n1->Type != ImTriangulatorNodeType_Convex)
1908
continue;
1909
if (!IsEar(n1->Prev->Index, n1->Index, n1->Next->Index, n1->Prev->Pos, n1->Pos, n1->Next->Pos))
1910
continue;
1911
n1->Type = ImTriangulatorNodeType_Ear;
1912
_Ears.push_back(n1);
1913
}
1914
}
1915
1916
void ImTriangulator::GetNextTriangle(unsigned int out_triangle[3])
1917
{
1918
if (_Ears.Size == 0)
1919
{
1920
FlipNodeList();
1921
1922
ImTriangulatorNode* node = _Nodes;
1923
for (int i = _TrianglesLeft; i >= 0; i--, node = node->Next)
1924
node->Type = ImTriangulatorNodeType_Convex;
1925
_Reflexes.Size = 0;
1926
BuildReflexes();
1927
BuildEars();
1928
1929
// If we still don't have ears, it means geometry is degenerated.
1930
if (_Ears.Size == 0)
1931
{
1932
// Return first triangle available, mimicking the behavior of convex fill.
1933
IM_ASSERT(_TrianglesLeft > 0); // Geometry is degenerated
1934
_Ears.Data[0] = _Nodes;
1935
_Ears.Size = 1;
1936
}
1937
}
1938
1939
ImTriangulatorNode* ear = _Ears.Data[--_Ears.Size];
1940
out_triangle[0] = ear->Prev->Index;
1941
out_triangle[1] = ear->Index;
1942
out_triangle[2] = ear->Next->Index;
1943
1944
ear->Unlink();
1945
if (ear == _Nodes)
1946
_Nodes = ear->Next;
1947
1948
ReclassifyNode(ear->Prev);
1949
ReclassifyNode(ear->Next);
1950
_TrianglesLeft--;
1951
}
1952
1953
void ImTriangulator::FlipNodeList()
1954
{
1955
ImTriangulatorNode* prev = _Nodes;
1956
ImTriangulatorNode* temp = _Nodes;
1957
ImTriangulatorNode* current = _Nodes->Next;
1958
prev->Next = prev;
1959
prev->Prev = prev;
1960
while (current != _Nodes)
1961
{
1962
temp = current->Next;
1963
1964
current->Next = prev;
1965
prev->Prev = current;
1966
_Nodes->Next = current;
1967
current->Prev = _Nodes;
1968
1969
prev = current;
1970
current = temp;
1971
}
1972
_Nodes = prev;
1973
}
1974
1975
// A triangle is an ear is no other vertex is inside it. We can test reflexes vertices only (see reference algorithm)
1976
bool ImTriangulator::IsEar(int i0, int i1, int i2, const ImVec2& v0, const ImVec2& v1, const ImVec2& v2) const
1977
{
1978
ImTriangulatorNode** p_end = _Reflexes.Data + _Reflexes.Size;
1979
for (ImTriangulatorNode** p = _Reflexes.Data; p < p_end; p++)
1980
{
1981
ImTriangulatorNode* reflex = *p;
1982
if (reflex->Index != i0 && reflex->Index != i1 && reflex->Index != i2)
1983
if (ImTriangleContainsPoint(v0, v1, v2, reflex->Pos))
1984
return false;
1985
}
1986
return true;
1987
}
1988
1989
void ImTriangulator::ReclassifyNode(ImTriangulatorNode* n1)
1990
{
1991
// Classify node
1992
ImTriangulatorNodeType type;
1993
const ImTriangulatorNode* n0 = n1->Prev;
1994
const ImTriangulatorNode* n2 = n1->Next;
1995
if (!ImTriangleIsClockwise(n0->Pos, n1->Pos, n2->Pos))
1996
type = ImTriangulatorNodeType_Reflex;
1997
else if (IsEar(n0->Index, n1->Index, n2->Index, n0->Pos, n1->Pos, n2->Pos))
1998
type = ImTriangulatorNodeType_Ear;
1999
else
2000
type = ImTriangulatorNodeType_Convex;
2001
2002
// Update lists when a type changes
2003
if (type == n1->Type)
2004
return;
2005
if (n1->Type == ImTriangulatorNodeType_Reflex)
2006
_Reflexes.find_erase_unsorted(n1->Index);
2007
else if (n1->Type == ImTriangulatorNodeType_Ear)
2008
_Ears.find_erase_unsorted(n1->Index);
2009
if (type == ImTriangulatorNodeType_Reflex)
2010
_Reflexes.push_back(n1);
2011
else if (type == ImTriangulatorNodeType_Ear)
2012
_Ears.push_back(n1);
2013
n1->Type = type;
2014
}
2015
2016
// Use ear-clipping algorithm to triangulate a simple polygon (no self-interaction, no holes).
2017
// (Reminder: we don't perform any coarse clipping/culling in ImDrawList layer!
2018
// It is up to caller to ensure not making costly calls that will be outside of visible area.
2019
// As concave fill is noticeably more expensive than other primitives, be mindful of this...
2020
// Caller can build AABB of points, and avoid filling if 'draw_list->_CmdHeader.ClipRect.Overlays(points_bb) == false')
2021
void ImDrawList::AddConcavePolyFilled(const ImVec2* points, const int points_count, ImU32 col)
2022
{
2023
if (points_count < 3 || (col & IM_COL32_A_MASK) == 0)
2024
return;
2025
2026
const ImVec2 uv = _Data->TexUvWhitePixel;
2027
ImTriangulator triangulator;
2028
unsigned int triangle[3];
2029
if (Flags & ImDrawListFlags_AntiAliasedFill)
2030
{
2031
// Anti-aliased Fill
2032
const float AA_SIZE = _FringeScale;
2033
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
2034
const int idx_count = (points_count - 2) * 3 + points_count * 6;
2035
const int vtx_count = (points_count * 2);
2036
PrimReserve(idx_count, vtx_count);
2037
2038
// Add indexes for fill
2039
unsigned int vtx_inner_idx = _VtxCurrentIdx;
2040
unsigned int vtx_outer_idx = _VtxCurrentIdx + 1;
2041
2042
_Data->TempBuffer.reserve_discard((ImTriangulator::EstimateScratchBufferSize(points_count) + sizeof(ImVec2)) / sizeof(ImVec2));
2043
triangulator.Init(points, points_count, _Data->TempBuffer.Data);
2044
while (triangulator._TrianglesLeft > 0)
2045
{
2046
triangulator.GetNextTriangle(triangle);
2047
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx + (triangle[0] << 1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + (triangle[1] << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_inner_idx + (triangle[2] << 1));
2048
_IdxWritePtr += 3;
2049
}
2050
2051
// Compute normals
2052
_Data->TempBuffer.reserve_discard(points_count);
2053
ImVec2* temp_normals = _Data->TempBuffer.Data;
2054
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
2055
{
2056
const ImVec2& p0 = points[i0];
2057
const ImVec2& p1 = points[i1];
2058
float dx = p1.x - p0.x;
2059
float dy = p1.y - p0.y;
2060
IM_NORMALIZE2F_OVER_ZERO(dx, dy);
2061
temp_normals[i0].x = dy;
2062
temp_normals[i0].y = -dx;
2063
}
2064
2065
for (int i0 = points_count - 1, i1 = 0; i1 < points_count; i0 = i1++)
2066
{
2067
// Average normals
2068
const ImVec2& n0 = temp_normals[i0];
2069
const ImVec2& n1 = temp_normals[i1];
2070
float dm_x = (n0.x + n1.x) * 0.5f;
2071
float dm_y = (n0.y + n1.y) * 0.5f;
2072
IM_FIXNORMAL2F(dm_x, dm_y);
2073
dm_x *= AA_SIZE * 0.5f;
2074
dm_y *= AA_SIZE * 0.5f;
2075
2076
// Add vertices
2077
_VtxWritePtr[0].pos.x = (points[i1].x - dm_x); _VtxWritePtr[0].pos.y = (points[i1].y - dm_y); _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col; // Inner
2078
_VtxWritePtr[1].pos.x = (points[i1].x + dm_x); _VtxWritePtr[1].pos.y = (points[i1].y + dm_y); _VtxWritePtr[1].uv = uv; _VtxWritePtr[1].col = col_trans; // Outer
2079
_VtxWritePtr += 2;
2080
2081
// Add indexes for fringes
2082
_IdxWritePtr[0] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1)); _IdxWritePtr[1] = (ImDrawIdx)(vtx_inner_idx + (i0 << 1)); _IdxWritePtr[2] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1));
2083
_IdxWritePtr[3] = (ImDrawIdx)(vtx_outer_idx + (i0 << 1)); _IdxWritePtr[4] = (ImDrawIdx)(vtx_outer_idx + (i1 << 1)); _IdxWritePtr[5] = (ImDrawIdx)(vtx_inner_idx + (i1 << 1));
2084
_IdxWritePtr += 6;
2085
}
2086
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
2087
}
2088
else
2089
{
2090
// Non Anti-aliased Fill
2091
const int idx_count = (points_count - 2) * 3;
2092
const int vtx_count = points_count;
2093
PrimReserve(idx_count, vtx_count);
2094
for (int i = 0; i < vtx_count; i++)
2095
{
2096
_VtxWritePtr[0].pos = points[i]; _VtxWritePtr[0].uv = uv; _VtxWritePtr[0].col = col;
2097
_VtxWritePtr++;
2098
}
2099
_Data->TempBuffer.reserve_discard((ImTriangulator::EstimateScratchBufferSize(points_count) + sizeof(ImVec2)) / sizeof(ImVec2));
2100
triangulator.Init(points, points_count, _Data->TempBuffer.Data);
2101
while (triangulator._TrianglesLeft > 0)
2102
{
2103
triangulator.GetNextTriangle(triangle);
2104
_IdxWritePtr[0] = (ImDrawIdx)(_VtxCurrentIdx + triangle[0]); _IdxWritePtr[1] = (ImDrawIdx)(_VtxCurrentIdx + triangle[1]); _IdxWritePtr[2] = (ImDrawIdx)(_VtxCurrentIdx + triangle[2]);
2105
_IdxWritePtr += 3;
2106
}
2107
_VtxCurrentIdx += (ImDrawIdx)vtx_count;
2108
}
2109
}
2110
2111
//-----------------------------------------------------------------------------
2112
// [SECTION] ImDrawListSplitter
2113
//-----------------------------------------------------------------------------
2114
// FIXME: This may be a little confusing, trying to be a little too low-level/optimal instead of just doing vector swap..
2115
//-----------------------------------------------------------------------------
2116
2117
void ImDrawListSplitter::ClearFreeMemory()
2118
{
2119
for (int i = 0; i < _Channels.Size; i++)
2120
{
2121
if (i == _Current)
2122
memset(&_Channels[i], 0, sizeof(_Channels[i])); // Current channel is a copy of CmdBuffer/IdxBuffer, don't destruct again
2123
_Channels[i]._CmdBuffer.clear();
2124
_Channels[i]._IdxBuffer.clear();
2125
}
2126
_Current = 0;
2127
_Count = 1;
2128
_Channels.clear();
2129
}
2130
2131
void ImDrawListSplitter::Split(ImDrawList* draw_list, int channels_count)
2132
{
2133
IM_UNUSED(draw_list);
2134
IM_ASSERT(_Current == 0 && _Count <= 1 && "Nested channel splitting is not supported. Please use separate instances of ImDrawListSplitter.");
2135
int old_channels_count = _Channels.Size;
2136
if (old_channels_count < channels_count)
2137
{
2138
_Channels.reserve(channels_count); // Avoid over reserving since this is likely to stay stable
2139
_Channels.resize(channels_count);
2140
}
2141
_Count = channels_count;
2142
2143
// Channels[] (24/32 bytes each) hold storage that we'll swap with draw_list->_CmdBuffer/_IdxBuffer
2144
// The content of Channels[0] at this point doesn't matter. We clear it to make state tidy in a debugger but we don't strictly need to.
2145
// When we switch to the next channel, we'll copy draw_list->_CmdBuffer/_IdxBuffer into Channels[0] and then Channels[1] into draw_list->CmdBuffer/_IdxBuffer
2146
memset(&_Channels[0], 0, sizeof(ImDrawChannel));
2147
for (int i = 1; i < channels_count; i++)
2148
{
2149
if (i >= old_channels_count)
2150
{
2151
IM_PLACEMENT_NEW(&_Channels[i]) ImDrawChannel();
2152
}
2153
else
2154
{
2155
_Channels[i]._CmdBuffer.resize(0);
2156
_Channels[i]._IdxBuffer.resize(0);
2157
}
2158
}
2159
}
2160
2161
void ImDrawListSplitter::Merge(ImDrawList* draw_list)
2162
{
2163
// Note that we never use or rely on _Channels.Size because it is merely a buffer that we never shrink back to 0 to keep all sub-buffers ready for use.
2164
if (_Count <= 1)
2165
return;
2166
2167
SetCurrentChannel(draw_list, 0);
2168
draw_list->_PopUnusedDrawCmd();
2169
2170
// Calculate our final buffer sizes. Also fix the incorrect IdxOffset values in each command.
2171
int new_cmd_buffer_count = 0;
2172
int new_idx_buffer_count = 0;
2173
ImDrawCmd* last_cmd = (_Count > 0 && draw_list->CmdBuffer.Size > 0) ? &draw_list->CmdBuffer.back() : NULL;
2174
int idx_offset = last_cmd ? last_cmd->IdxOffset + last_cmd->ElemCount : 0;
2175
for (int i = 1; i < _Count; i++)
2176
{
2177
ImDrawChannel& ch = _Channels[i];
2178
if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0 && ch._CmdBuffer.back().UserCallback == NULL) // Equivalent of PopUnusedDrawCmd()
2179
ch._CmdBuffer.pop_back();
2180
2181
if (ch._CmdBuffer.Size > 0 && last_cmd != NULL)
2182
{
2183
// Do not include ImDrawCmd_AreSequentialIdxOffset() in the compare as we rebuild IdxOffset values ourselves.
2184
// Manipulating IdxOffset (e.g. by reordering draw commands like done by RenderDimmedBackgroundBehindWindow()) is not supported within a splitter.
2185
ImDrawCmd* next_cmd = &ch._CmdBuffer[0];
2186
if (ImDrawCmd_HeaderCompare(last_cmd, next_cmd) == 0 && last_cmd->UserCallback == NULL && next_cmd->UserCallback == NULL)
2187
{
2188
// Merge previous channel last draw command with current channel first draw command if matching.
2189
last_cmd->ElemCount += next_cmd->ElemCount;
2190
idx_offset += next_cmd->ElemCount;
2191
ch._CmdBuffer.erase(ch._CmdBuffer.Data); // FIXME-OPT: Improve for multiple merges.
2192
}
2193
}
2194
if (ch._CmdBuffer.Size > 0)
2195
last_cmd = &ch._CmdBuffer.back();
2196
new_cmd_buffer_count += ch._CmdBuffer.Size;
2197
new_idx_buffer_count += ch._IdxBuffer.Size;
2198
for (int cmd_n = 0; cmd_n < ch._CmdBuffer.Size; cmd_n++)
2199
{
2200
ch._CmdBuffer.Data[cmd_n].IdxOffset = idx_offset;
2201
idx_offset += ch._CmdBuffer.Data[cmd_n].ElemCount;
2202
}
2203
}
2204
draw_list->CmdBuffer.resize(draw_list->CmdBuffer.Size + new_cmd_buffer_count);
2205
draw_list->IdxBuffer.resize(draw_list->IdxBuffer.Size + new_idx_buffer_count);
2206
2207
// Write commands and indices in order (they are fairly small structures, we don't copy vertices only indices)
2208
ImDrawCmd* cmd_write = draw_list->CmdBuffer.Data + draw_list->CmdBuffer.Size - new_cmd_buffer_count;
2209
ImDrawIdx* idx_write = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size - new_idx_buffer_count;
2210
for (int i = 1; i < _Count; i++)
2211
{
2212
ImDrawChannel& ch = _Channels[i];
2213
if (int sz = ch._CmdBuffer.Size) { memcpy(cmd_write, ch._CmdBuffer.Data, sz * sizeof(ImDrawCmd)); cmd_write += sz; }
2214
if (int sz = ch._IdxBuffer.Size) { memcpy(idx_write, ch._IdxBuffer.Data, sz * sizeof(ImDrawIdx)); idx_write += sz; }
2215
}
2216
draw_list->_IdxWritePtr = idx_write;
2217
2218
// Ensure there's always a non-callback draw command trailing the command-buffer
2219
if (draw_list->CmdBuffer.Size == 0 || draw_list->CmdBuffer.back().UserCallback != NULL)
2220
draw_list->AddDrawCmd();
2221
2222
// If current command is used with different settings we need to add a new command
2223
ImDrawCmd* curr_cmd = &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1];
2224
if (curr_cmd->ElemCount == 0)
2225
ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TexRef, VtxOffset
2226
else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0)
2227
draw_list->AddDrawCmd();
2228
2229
_Count = 1;
2230
}
2231
2232
void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx)
2233
{
2234
IM_ASSERT(idx >= 0 && idx < _Count);
2235
if (_Current == idx)
2236
return;
2237
2238
// Overwrite ImVector (12/16 bytes), four times. This is merely a silly optimization instead of doing .swap()
2239
memcpy(&_Channels.Data[_Current]._CmdBuffer, &draw_list->CmdBuffer, sizeof(draw_list->CmdBuffer));
2240
memcpy(&_Channels.Data[_Current]._IdxBuffer, &draw_list->IdxBuffer, sizeof(draw_list->IdxBuffer));
2241
_Current = idx;
2242
memcpy(&draw_list->CmdBuffer, &_Channels.Data[idx]._CmdBuffer, sizeof(draw_list->CmdBuffer));
2243
memcpy(&draw_list->IdxBuffer, &_Channels.Data[idx]._IdxBuffer, sizeof(draw_list->IdxBuffer));
2244
draw_list->_IdxWritePtr = draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size;
2245
2246
// If current command is used with different settings we need to add a new command
2247
ImDrawCmd* curr_cmd = (draw_list->CmdBuffer.Size == 0) ? NULL : &draw_list->CmdBuffer.Data[draw_list->CmdBuffer.Size - 1];
2248
if (curr_cmd == NULL)
2249
draw_list->AddDrawCmd();
2250
else if (curr_cmd->ElemCount == 0)
2251
ImDrawCmd_HeaderCopy(curr_cmd, &draw_list->_CmdHeader); // Copy ClipRect, TexRef, VtxOffset
2252
else if (ImDrawCmd_HeaderCompare(curr_cmd, &draw_list->_CmdHeader) != 0)
2253
draw_list->AddDrawCmd();
2254
}
2255
2256
//-----------------------------------------------------------------------------
2257
// [SECTION] ImDrawData
2258
//-----------------------------------------------------------------------------
2259
2260
void ImDrawData::Clear()
2261
{
2262
Valid = false;
2263
CmdListsCount = TotalIdxCount = TotalVtxCount = 0;
2264
CmdLists.resize(0); // The ImDrawList are NOT owned by ImDrawData but e.g. by ImGuiContext, so we don't clear them.
2265
DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.0f, 0.0f);
2266
OwnerViewport = NULL;
2267
Textures = NULL;
2268
}
2269
2270
// Important: 'out_list' is generally going to be draw_data->CmdLists, but may be another temporary list
2271
// as long at it is expected that the result will be later merged into draw_data->CmdLists[].
2272
void ImGui::AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector<ImDrawList*>* out_list, ImDrawList* draw_list)
2273
{
2274
if (draw_list->CmdBuffer.Size == 0)
2275
return;
2276
if (draw_list->CmdBuffer.Size == 1 && draw_list->CmdBuffer[0].ElemCount == 0 && draw_list->CmdBuffer[0].UserCallback == NULL)
2277
return;
2278
2279
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
2280
// May trigger for you if you are using PrimXXX functions incorrectly.
2281
IM_ASSERT(draw_list->VtxBuffer.Size == 0 || draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
2282
IM_ASSERT(draw_list->IdxBuffer.Size == 0 || draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
2283
if (!(draw_list->Flags & ImDrawListFlags_AllowVtxOffset))
2284
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
2285
2286
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = unsigned short = 2 bytes = 64K vertices per ImDrawList = per window)
2287
// If this assert triggers because you are drawing lots of stuff manually:
2288
// - First, make sure you are coarse clipping yourself and not trying to draw many things outside visible bounds.
2289
// Be mindful that the lower-level ImDrawList API doesn't filter vertices. Use the Metrics/Debugger window to inspect draw list contents.
2290
// - If you want large meshes with more than 64K vertices, you can either:
2291
// (A) Handle the ImDrawCmd::VtxOffset value in your renderer backend, and set 'io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset'.
2292
// Most example backends already support this from 1.71. Pre-1.71 backends won't.
2293
// Some graphics API such as GL ES 1/2 don't have a way to offset the starting vertex so it is not supported for them.
2294
// (B) Or handle 32-bit indices in your renderer backend, and uncomment '#define ImDrawIdx unsigned int' line in imconfig.h.
2295
// Most example backends already support this. For example, the OpenGL example code detect index size at compile-time:
2296
// glDrawElements(GL_TRIANGLES, (GLsizei)pcmd->ElemCount, sizeof(ImDrawIdx) == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT, idx_buffer_offset);
2297
// Your own engine or render API may use different parameters or function calls to specify index sizes.
2298
// 2 and 4 bytes indices are generally supported by most graphics API.
2299
// - If for some reason neither of those solutions works for you, a workaround is to call BeginChild()/EndChild() before reaching
2300
// the 64K limit to split your draw commands in multiple draw lists.
2301
if (sizeof(ImDrawIdx) == 2)
2302
IM_ASSERT(draw_list->_VtxCurrentIdx < (1 << 16) && "Too many vertices in ImDrawList using 16-bit indices. Read comment above");
2303
2304
// Resolve callback data pointers
2305
if (draw_list->_CallbacksDataBuf.Size > 0)
2306
for (ImDrawCmd& cmd : draw_list->CmdBuffer)
2307
if (cmd.UserCallback != NULL && cmd.UserCallbackDataOffset != -1 && cmd.UserCallbackDataSize > 0)
2308
cmd.UserCallbackData = draw_list->_CallbacksDataBuf.Data + cmd.UserCallbackDataOffset;
2309
2310
// Add to output list + records state in ImDrawData
2311
out_list->push_back(draw_list);
2312
draw_data->CmdListsCount++;
2313
draw_data->TotalVtxCount += draw_list->VtxBuffer.Size;
2314
draw_data->TotalIdxCount += draw_list->IdxBuffer.Size;
2315
}
2316
2317
void ImDrawData::AddDrawList(ImDrawList* draw_list)
2318
{
2319
IM_ASSERT(CmdLists.Size == CmdListsCount);
2320
draw_list->_PopUnusedDrawCmd();
2321
ImGui::AddDrawListToDrawDataEx(this, &CmdLists, draw_list);
2322
}
2323
2324
// For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
2325
void ImDrawData::DeIndexAllBuffers()
2326
{
2327
ImVector<ImDrawVert> new_vtx_buffer;
2328
TotalVtxCount = TotalIdxCount = 0;
2329
for (ImDrawList* draw_list : CmdLists)
2330
{
2331
if (draw_list->IdxBuffer.empty())
2332
continue;
2333
new_vtx_buffer.resize(draw_list->IdxBuffer.Size);
2334
for (int j = 0; j < draw_list->IdxBuffer.Size; j++)
2335
new_vtx_buffer[j] = draw_list->VtxBuffer[draw_list->IdxBuffer[j]];
2336
draw_list->VtxBuffer.swap(new_vtx_buffer);
2337
draw_list->IdxBuffer.resize(0);
2338
TotalVtxCount += draw_list->VtxBuffer.Size;
2339
}
2340
}
2341
2342
// Helper to scale the ClipRect field of each ImDrawCmd.
2343
// Use if your final output buffer is at a different scale than draw_data->DisplaySize,
2344
// or if there is a difference between your window resolution and framebuffer resolution.
2345
void ImDrawData::ScaleClipRects(const ImVec2& fb_scale)
2346
{
2347
for (ImDrawList* draw_list : CmdLists)
2348
for (ImDrawCmd& cmd : draw_list->CmdBuffer)
2349
cmd.ClipRect = ImVec4(cmd.ClipRect.x * fb_scale.x, cmd.ClipRect.y * fb_scale.y, cmd.ClipRect.z * fb_scale.x, cmd.ClipRect.w * fb_scale.y);
2350
}
2351
2352
//-----------------------------------------------------------------------------
2353
// [SECTION] Helpers ShadeVertsXXX functions
2354
//-----------------------------------------------------------------------------
2355
2356
// Generic linear color gradient, write to RGB fields, leave A untouched.
2357
void ImGui::ShadeVertsLinearColorGradientKeepAlpha(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, ImVec2 gradient_p0, ImVec2 gradient_p1, ImU32 col0, ImU32 col1)
2358
{
2359
ImVec2 gradient_extent = gradient_p1 - gradient_p0;
2360
float gradient_inv_length2 = 1.0f / ImLengthSqr(gradient_extent);
2361
ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx;
2362
ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx;
2363
const int col0_r = (int)(col0 >> IM_COL32_R_SHIFT) & 0xFF;
2364
const int col0_g = (int)(col0 >> IM_COL32_G_SHIFT) & 0xFF;
2365
const int col0_b = (int)(col0 >> IM_COL32_B_SHIFT) & 0xFF;
2366
const int col_delta_r = ((int)(col1 >> IM_COL32_R_SHIFT) & 0xFF) - col0_r;
2367
const int col_delta_g = ((int)(col1 >> IM_COL32_G_SHIFT) & 0xFF) - col0_g;
2368
const int col_delta_b = ((int)(col1 >> IM_COL32_B_SHIFT) & 0xFF) - col0_b;
2369
for (ImDrawVert* vert = vert_start; vert < vert_end; vert++)
2370
{
2371
float d = ImDot(vert->pos - gradient_p0, gradient_extent);
2372
float t = ImClamp(d * gradient_inv_length2, 0.0f, 1.0f);
2373
int r = (int)(col0_r + col_delta_r * t);
2374
int g = (int)(col0_g + col_delta_g * t);
2375
int b = (int)(col0_b + col_delta_b * t);
2376
vert->col = (r << IM_COL32_R_SHIFT) | (g << IM_COL32_G_SHIFT) | (b << IM_COL32_B_SHIFT) | (vert->col & IM_COL32_A_MASK);
2377
}
2378
}
2379
2380
// Distribute UV over (a, b) rectangle
2381
void ImGui::ShadeVertsLinearUV(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, bool clamp)
2382
{
2383
const ImVec2 size = b - a;
2384
const ImVec2 uv_size = uv_b - uv_a;
2385
const ImVec2 scale = ImVec2(
2386
size.x != 0.0f ? (uv_size.x / size.x) : 0.0f,
2387
size.y != 0.0f ? (uv_size.y / size.y) : 0.0f);
2388
2389
ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx;
2390
ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx;
2391
if (clamp)
2392
{
2393
const ImVec2 min = ImMin(uv_a, uv_b);
2394
const ImVec2 max = ImMax(uv_a, uv_b);
2395
for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex)
2396
vertex->uv = ImClamp(uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale), min, max);
2397
}
2398
else
2399
{
2400
for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex)
2401
vertex->uv = uv_a + ImMul(ImVec2(vertex->pos.x, vertex->pos.y) - a, scale);
2402
}
2403
}
2404
2405
void ImGui::ShadeVertsTransformPos(ImDrawList* draw_list, int vert_start_idx, int vert_end_idx, const ImVec2& pivot_in, float cos_a, float sin_a, const ImVec2& pivot_out)
2406
{
2407
ImDrawVert* vert_start = draw_list->VtxBuffer.Data + vert_start_idx;
2408
ImDrawVert* vert_end = draw_list->VtxBuffer.Data + vert_end_idx;
2409
for (ImDrawVert* vertex = vert_start; vertex < vert_end; ++vertex)
2410
vertex->pos = ImRotate(vertex->pos- pivot_in, cos_a, sin_a) + pivot_out;
2411
}
2412
2413
//-----------------------------------------------------------------------------
2414
// [SECTION] ImFontConfig
2415
//-----------------------------------------------------------------------------
2416
2417
// FIXME-NEWATLAS: Oversample specification could be more dynamic. For now, favoring automatic selection.
2418
ImFontConfig::ImFontConfig()
2419
{
2420
memset(this, 0, sizeof(*this));
2421
FontDataOwnedByAtlas = true;
2422
OversampleH = 0; // Auto == 1 or 2 depending on size
2423
OversampleV = 0; // Auto == 1
2424
ExtraSizeScale = 1.0f;
2425
GlyphMaxAdvanceX = FLT_MAX;
2426
RasterizerMultiply = 1.0f;
2427
RasterizerDensity = 1.0f;
2428
EllipsisChar = 0;
2429
}
2430
2431
//-----------------------------------------------------------------------------
2432
// [SECTION] ImTextureData
2433
//-----------------------------------------------------------------------------
2434
// - ImTextureData::Create()
2435
// - ImTextureData::DestroyPixels()
2436
//-----------------------------------------------------------------------------
2437
2438
int ImTextureDataGetFormatBytesPerPixel(ImTextureFormat format)
2439
{
2440
switch (format)
2441
{
2442
case ImTextureFormat_Alpha8: return 1;
2443
case ImTextureFormat_RGBA32: return 4;
2444
}
2445
IM_ASSERT(0);
2446
return 0;
2447
}
2448
2449
const char* ImTextureDataGetStatusName(ImTextureStatus status)
2450
{
2451
switch (status)
2452
{
2453
case ImTextureStatus_OK: return "OK";
2454
case ImTextureStatus_Destroyed: return "Destroyed";
2455
case ImTextureStatus_WantCreate: return "WantCreate";
2456
case ImTextureStatus_WantUpdates: return "WantUpdates";
2457
case ImTextureStatus_WantDestroy: return "WantDestroy";
2458
}
2459
return "N/A";
2460
}
2461
2462
const char* ImTextureDataGetFormatName(ImTextureFormat format)
2463
{
2464
switch (format)
2465
{
2466
case ImTextureFormat_Alpha8: return "Alpha8";
2467
case ImTextureFormat_RGBA32: return "RGBA32";
2468
}
2469
return "N/A";
2470
}
2471
2472
void ImTextureData::Create(ImTextureFormat format, int w, int h)
2473
{
2474
IM_ASSERT(Status == ImTextureStatus_Destroyed);
2475
DestroyPixels();
2476
Format = format;
2477
Status = ImTextureStatus_WantCreate;
2478
Width = w;
2479
Height = h;
2480
BytesPerPixel = ImTextureDataGetFormatBytesPerPixel(format);
2481
UseColors = false;
2482
Pixels = (unsigned char*)IM_ALLOC(Width * Height * BytesPerPixel);
2483
IM_ASSERT(Pixels != NULL);
2484
memset(Pixels, 0, Width * Height * BytesPerPixel);
2485
UsedRect.x = UsedRect.y = UsedRect.w = UsedRect.h = 0;
2486
UpdateRect.x = UpdateRect.y = (unsigned short)~0;
2487
UpdateRect.w = UpdateRect.h = 0;
2488
}
2489
2490
void ImTextureData::DestroyPixels()
2491
{
2492
if (Pixels)
2493
IM_FREE(Pixels);
2494
Pixels = NULL;
2495
UseColors = false;
2496
}
2497
2498
//-----------------------------------------------------------------------------
2499
// [SECTION] ImFontAtlas, ImFontAtlasBuilder
2500
//-----------------------------------------------------------------------------
2501
// - Default texture data encoded in ASCII
2502
// - ImFontAtlas()
2503
// - ImFontAtlas::Clear()
2504
// - ImFontAtlas::CompactCache()
2505
// - ImFontAtlas::ClearInputData()
2506
// - ImFontAtlas::ClearTexData()
2507
// - ImFontAtlas::ClearFonts()
2508
//-----------------------------------------------------------------------------
2509
// - ImFontAtlasUpdateNewFrame()
2510
// - ImFontAtlasTextureBlockConvert()
2511
// - ImFontAtlasTextureBlockPostProcess()
2512
// - ImFontAtlasTextureBlockPostProcessMultiply()
2513
// - ImFontAtlasTextureBlockFill()
2514
// - ImFontAtlasTextureBlockCopy()
2515
// - ImFontAtlasTextureBlockQueueUpload()
2516
//-----------------------------------------------------------------------------
2517
// - ImFontAtlas::GetTexDataAsAlpha8() [legacy]
2518
// - ImFontAtlas::GetTexDataAsRGBA32() [legacy]
2519
// - ImFontAtlas::Build() [legacy]
2520
//-----------------------------------------------------------------------------
2521
// - ImFontAtlas::AddFont()
2522
// - ImFontAtlas::AddFontDefault()
2523
// - ImFontAtlas::AddFontDefaultBitmap()
2524
// - ImFontAtlas::AddFontDefaultVector()
2525
// - ImFontAtlas::AddFontFromFileTTF()
2526
// - ImFontAtlas::AddFontFromMemoryTTF()
2527
// - ImFontAtlas::AddFontFromMemoryCompressedTTF()
2528
// - ImFontAtlas::AddFontFromMemoryCompressedBase85TTF()
2529
// - ImFontAtlas::RemoveFont()
2530
// - ImFontAtlasBuildNotifySetFont()
2531
//-----------------------------------------------------------------------------
2532
// - ImFontAtlas::AddCustomRect()
2533
// - ImFontAtlas::RemoveCustomRect()
2534
// - ImFontAtlas::GetCustomRect()
2535
// - ImFontAtlas::AddCustomRectFontGlyph() [legacy]
2536
// - ImFontAtlas::AddCustomRectFontGlyphForSize() [legacy]
2537
// - ImFontAtlasGetMouseCursorTexData()
2538
//-----------------------------------------------------------------------------
2539
// - ImFontAtlasBuildMain()
2540
// - ImFontAtlasBuildSetupFontLoader()
2541
// - ImFontAtlasBuildPreloadAllGlyphRanges()
2542
// - ImFontAtlasBuildUpdatePointers()
2543
// - ImFontAtlasBuildRenderBitmapFromString()
2544
// - ImFontAtlasBuildUpdateBasicTexData()
2545
// - ImFontAtlasBuildUpdateLinesTexData()
2546
// - ImFontAtlasBuildAddFont()
2547
// - ImFontAtlasBuildSetupFontBakedEllipsis()
2548
// - ImFontAtlasBuildSetupFontBakedBlanks()
2549
// - ImFontAtlasBuildSetupFontBakedFallback()
2550
// - ImFontAtlasBuildSetupFontSpecialGlyphs()
2551
// - ImFontAtlasBuildDiscardBakes()
2552
// - ImFontAtlasBuildDiscardFontBakedGlyph()
2553
// - ImFontAtlasBuildDiscardFontBaked()
2554
// - ImFontAtlasBuildDiscardFontBakes()
2555
//-----------------------------------------------------------------------------
2556
// - ImFontAtlasAddDrawListSharedData()
2557
// - ImFontAtlasRemoveDrawListSharedData()
2558
// - ImFontAtlasUpdateDrawListsTextures()
2559
// - ImFontAtlasUpdateDrawListsSharedData()
2560
//-----------------------------------------------------------------------------
2561
// - ImFontAtlasBuildSetTexture()
2562
// - ImFontAtlasBuildAddTexture()
2563
// - ImFontAtlasBuildMakeSpace()
2564
// - ImFontAtlasBuildRepackTexture()
2565
// - ImFontAtlasBuildGrowTexture()
2566
// - ImFontAtlasBuildRepackOrGrowTexture()
2567
// - ImFontAtlasBuildGetTextureSizeEstimate()
2568
// - ImFontAtlasBuildCompactTexture()
2569
// - ImFontAtlasBuildInit()
2570
// - ImFontAtlasBuildDestroy()
2571
//-----------------------------------------------------------------------------
2572
// - ImFontAtlasPackInit()
2573
// - ImFontAtlasPackAllocRectEntry()
2574
// - ImFontAtlasPackReuseRectEntry()
2575
// - ImFontAtlasPackDiscardRect()
2576
// - ImFontAtlasPackAddRect()
2577
// - ImFontAtlasPackGetRect()
2578
//-----------------------------------------------------------------------------
2579
// - ImFontBaked_BuildGrowIndex()
2580
// - ImFontBaked_BuildLoadGlyph()
2581
// - ImFontBaked_BuildLoadGlyphAdvanceX()
2582
// - ImFontAtlasDebugLogTextureRequests()
2583
//-----------------------------------------------------------------------------
2584
// - ImFontAtlasGetFontLoaderForStbTruetype()
2585
//-----------------------------------------------------------------------------
2586
2587
// A work of art lies ahead! (. = white layer, X = black layer, others are blank)
2588
// The 2x2 white texels on the top left are the ones we'll use everywhere in Dear ImGui to render filled shapes.
2589
// (This is used when io.MouseDrawCursor = true)
2590
const int FONT_ATLAS_DEFAULT_TEX_DATA_W = 122; // Actual texture will be 2 times that + 1 spacing.
2591
const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27;
2592
static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W * FONT_ATLAS_DEFAULT_TEX_DATA_H + 1] =
2593
{
2594
"..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX - XX XX "
2595
"..- -X.....X- X.X - X.X -X.....X - X.....X- X..X -X..X X..X"
2596
"--- -XXX.XXX- X...X - X...X -X....X - X....X- X..X -X...X X...X"
2597
"X - X.X - X.....X - X.....X -X...X - X...X- X..X - X...X X...X "
2598
"XX - X.X -X.......X- X.......X -X..X.X - X.X..X- X..X - X...X...X "
2599
"X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X- X..XXX - X.....X "
2600
"X..X - X.X - X.X - X.X -XX X.X - X.X XX- X..X..XXX - X...X "
2601
"X...X - X.X - X.X - XX X.X XX - X.X - X.X - X..X..X..XX - X.X "
2602
"X....X - X.X - X.X - X.X X.X X.X - X.X - X.X - X..X..X..X.X - X...X "
2603
"X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X -XXX X..X..X..X..X- X.....X "
2604
"X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X -X..XX........X..X- X...X...X "
2605
"X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X -X...X...........X- X...X X...X "
2606
"X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X - X..............X-X...X X...X"
2607
"X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X - X.............X-X..X X..X"
2608
"X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X - X.............X- XX XX "
2609
"X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X - X............X--------------"
2610
"X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX - X...........X - "
2611
"X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------- X..........X - "
2612
"X.X X..X - -X.......X- X.......X - XX XX - - X..........X - "
2613
"XX X..X - - X.....X - X.....X - X.X X.X - - X........X - "
2614
" X..X - - X...X - X...X - X..X X..X - - X........X - "
2615
" XX - - X.X - X.X - X...XXXXXXXXXXXXX...X - - XXXXXXXXXX - "
2616
"------------- - X - X -X.....................X- ------------------- "
2617
" ----------------------------------- X...XXXXXXXXXXXXX...X - "
2618
" - X..X X..X - "
2619
" - X.X X.X - "
2620
" - XX XX - "
2621
};
2622
2623
static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_COUNT][3] =
2624
{
2625
// Pos ........ Size ......... Offset ......
2626
{ ImVec2( 0,3), ImVec2(12,19), ImVec2( 0, 0) }, // ImGuiMouseCursor_Arrow
2627
{ ImVec2(13,0), ImVec2( 7,16), ImVec2( 1, 8) }, // ImGuiMouseCursor_TextInput
2628
{ ImVec2(31,0), ImVec2(23,23), ImVec2(11,11) }, // ImGuiMouseCursor_ResizeAll
2629
{ ImVec2(21,0), ImVec2( 9,23), ImVec2( 4,11) }, // ImGuiMouseCursor_ResizeNS
2630
{ ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 4) }, // ImGuiMouseCursor_ResizeEW
2631
{ ImVec2(73,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNESW
2632
{ ImVec2(55,0), ImVec2(17,17), ImVec2( 8, 8) }, // ImGuiMouseCursor_ResizeNWSE
2633
{ ImVec2(91,0), ImVec2(17,22), ImVec2( 5, 0) }, // ImGuiMouseCursor_Hand
2634
{ ImVec2(0,3), ImVec2(12,19), ImVec2(0, 0) }, // ImGuiMouseCursor_Wait // Arrow + custom code in ImGui::RenderMouseCursor()
2635
{ ImVec2(0,3), ImVec2(12,19), ImVec2(0, 0) }, // ImGuiMouseCursor_Progress // Arrow + custom code in ImGui::RenderMouseCursor()
2636
{ ImVec2(109,0),ImVec2(13,15), ImVec2( 6, 7) }, // ImGuiMouseCursor_NotAllowed
2637
};
2638
2639
#define IM_FONTGLYPH_INDEX_UNUSED ((ImU16)-1) // 0xFFFF
2640
#define IM_FONTGLYPH_INDEX_NOT_FOUND ((ImU16)-2) // 0xFFFE
2641
2642
ImFontAtlas::ImFontAtlas()
2643
{
2644
memset(this, 0, sizeof(*this));
2645
TexDesiredFormat = ImTextureFormat_RGBA32;
2646
TexGlyphPadding = 1;
2647
TexMinWidth = 512;
2648
TexMinHeight = 128;
2649
TexMaxWidth = 8192;
2650
TexMaxHeight = 8192;
2651
TexRef._TexID = ImTextureID_Invalid;
2652
RendererHasTextures = false; // Assumed false by default, as apps can call e.g Atlas::Build() after backend init and before ImGui can update.
2653
TexNextUniqueID = 1;
2654
FontNextUniqueID = 1;
2655
Builder = NULL;
2656
}
2657
2658
ImFontAtlas::~ImFontAtlas()
2659
{
2660
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
2661
RendererHasTextures = false; // Full Clear() is supported, but ClearTexData() only isn't.
2662
ClearFonts();
2663
ClearTexData();
2664
TexList.clear_delete();
2665
TexData = NULL;
2666
}
2667
2668
// If you call this mid-frame, you would need to add new font and bind them!
2669
void ImFontAtlas::Clear()
2670
{
2671
bool backup_renderer_has_textures = RendererHasTextures;
2672
RendererHasTextures = false; // Full Clear() is supported, but ClearTexData() only isn't.
2673
ClearFonts();
2674
ClearTexData();
2675
RendererHasTextures = backup_renderer_has_textures;
2676
}
2677
2678
void ImFontAtlas::CompactCache()
2679
{
2680
ImFontAtlasTextureCompact(this);
2681
}
2682
2683
void ImFontAtlas::SetFontLoader(const ImFontLoader* font_loader)
2684
{
2685
ImFontAtlasBuildSetupFontLoader(this, font_loader);
2686
}
2687
2688
void ImFontAtlas::ClearInputData()
2689
{
2690
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
2691
2692
for (ImFont* font : Fonts)
2693
ImFontAtlasFontDestroyOutput(this, font);
2694
for (ImFontConfig& font_cfg : Sources)
2695
ImFontAtlasFontDestroySourceData(this, &font_cfg);
2696
for (ImFont* font : Fonts)
2697
{
2698
// When clearing this we lose access to the font name and other information used to build the font.
2699
font->Sources.clear();
2700
font->Flags |= ImFontFlags_NoLoadGlyphs;
2701
}
2702
Sources.clear();
2703
}
2704
2705
// Clear CPU-side copy of the texture data.
2706
void ImFontAtlas::ClearTexData()
2707
{
2708
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
2709
IM_ASSERT(RendererHasTextures == false && "Not supported for dynamic atlases, but you may call Clear().");
2710
for (ImTextureData* tex : TexList)
2711
tex->DestroyPixels();
2712
//Locked = true; // Hoped to be able to lock this down but some reload patterns may not be happy with it.
2713
}
2714
2715
void ImFontAtlas::ClearFonts()
2716
{
2717
// FIXME-NEWATLAS: Illegal to remove currently bound font.
2718
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
2719
for (ImFont* font : Fonts)
2720
ImFontAtlasBuildNotifySetFont(this, font, NULL);
2721
ImFontAtlasBuildDestroy(this);
2722
ClearInputData();
2723
Fonts.clear_delete();
2724
TexIsBuilt = false;
2725
for (ImDrawListSharedData* shared_data : DrawListSharedDatas)
2726
if (shared_data->FontAtlas == this)
2727
{
2728
shared_data->Font = NULL;
2729
shared_data->FontScale = shared_data->FontSize = 0.0f;
2730
}
2731
}
2732
2733
static void ImFontAtlasBuildUpdateRendererHasTexturesFromContext(ImFontAtlas* atlas)
2734
{
2735
// [LEGACY] Copy back the ImGuiBackendFlags_RendererHasTextures flag from ImGui context.
2736
// - This is the 1% exceptional case where that dependency if useful, to bypass an issue where otherwise at the
2737
// time of an early call to Build(), it would be impossible for us to tell if the backend supports texture update.
2738
// - Without this hack, we would have quite a pitfall as many legacy codebases have an early call to Build().
2739
// Whereas conversely, the portion of people using ImDrawList without ImGui is expected to be pathologically rare.
2740
for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas)
2741
if (ImGuiContext* imgui_ctx = shared_data->Context)
2742
{
2743
atlas->RendererHasTextures = (imgui_ctx->IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures) != 0;
2744
break;
2745
}
2746
}
2747
2748
// Called by NewFrame() for atlases owned by a context.
2749
// If you manually manage font atlases, you'll need to call this yourself.
2750
// - 'frame_count' needs to be provided because we can gc/prioritize baked fonts based on their age.
2751
// - 'frame_count' may not match those of all imgui contexts using this atlas, as contexts may be updated as different frequencies. But generally you can use ImGui::GetFrameCount() on one of your context.
2752
void ImFontAtlasUpdateNewFrame(ImFontAtlas* atlas, int frame_count, bool renderer_has_textures)
2753
{
2754
IM_ASSERT(atlas->Builder == NULL || atlas->Builder->FrameCount < frame_count); // Protection against being called twice.
2755
atlas->RendererHasTextures = renderer_has_textures;
2756
2757
// Check that font atlas was built or backend support texture reload in which case we can build now
2758
if (atlas->RendererHasTextures)
2759
{
2760
atlas->TexIsBuilt = true;
2761
if (atlas->Builder == NULL) // This will only happen if fonts were not already loaded.
2762
ImFontAtlasBuildMain(atlas);
2763
}
2764
// Legacy backend
2765
if (!atlas->RendererHasTextures)
2766
IM_ASSERT_USER_ERROR(atlas->TexIsBuilt, "Backend does not support ImGuiBackendFlags_RendererHasTextures, and font atlas is not built! Update backend OR make sure you called ImGui_ImplXXXX_NewFrame() function for renderer backend, which should call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8().");
2767
if (atlas->TexIsBuilt && atlas->Builder->PreloadedAllGlyphsRanges)
2768
IM_ASSERT_USER_ERROR(atlas->RendererHasTextures == false, "Called ImFontAtlas::Build() before ImGuiBackendFlags_RendererHasTextures got set! With new backends: you don't need to call Build().");
2769
2770
// Clear BakedCurrent cache, this is important because it ensure the uncached path gets taken once.
2771
// We also rely on ImFontBaked* pointers never crossing frames.
2772
ImFontAtlasBuilder* builder = atlas->Builder;
2773
builder->FrameCount = frame_count;
2774
for (ImFont* font : atlas->Fonts)
2775
font->LastBaked = NULL;
2776
2777
// Garbage collect BakedPool
2778
if (builder->BakedDiscardedCount > 0)
2779
{
2780
int dst_n = 0, src_n = 0;
2781
for (; src_n < builder->BakedPool.Size; src_n++)
2782
{
2783
ImFontBaked* p_src = &builder->BakedPool[src_n];
2784
if (p_src->WantDestroy)
2785
continue;
2786
ImFontBaked* p_dst = &builder->BakedPool[dst_n++];
2787
if (p_dst == p_src)
2788
continue;
2789
memcpy(p_dst, p_src, sizeof(ImFontBaked));
2790
builder->BakedMap.SetVoidPtr(p_dst->BakedId, p_dst);
2791
}
2792
IM_ASSERT(dst_n + builder->BakedDiscardedCount == src_n);
2793
builder->BakedPool.Size -= builder->BakedDiscardedCount;
2794
builder->BakedDiscardedCount = 0;
2795
}
2796
2797
// Update texture status
2798
for (int tex_n = 0; tex_n < atlas->TexList.Size; tex_n++)
2799
{
2800
ImTextureData* tex = atlas->TexList[tex_n];
2801
bool remove_from_list = false;
2802
if (tex->Status == ImTextureStatus_OK)
2803
{
2804
tex->Updates.resize(0);
2805
tex->UpdateRect.x = tex->UpdateRect.y = (unsigned short)~0;
2806
tex->UpdateRect.w = tex->UpdateRect.h = 0;
2807
}
2808
if (tex->Status == ImTextureStatus_WantCreate && atlas->RendererHasTextures)
2809
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == NULL && "Backend set texture's TexID/BackendUserData but did not update Status to OK.");
2810
2811
// Request destroy
2812
// - Keep bool to true in order to differentiate a planned destroy vs a destroy decided by the backend.
2813
// - We don't destroy pixels right away, as backend may have an in-flight copy from RAM.
2814
if (tex->WantDestroyNextFrame && tex->Status != ImTextureStatus_Destroyed && tex->Status != ImTextureStatus_WantDestroy)
2815
{
2816
IM_ASSERT(tex->Status == ImTextureStatus_OK || tex->Status == ImTextureStatus_WantCreate || tex->Status == ImTextureStatus_WantUpdates);
2817
tex->Status = ImTextureStatus_WantDestroy;
2818
}
2819
2820
// If a texture has never reached the backend, they don't need to know about it.
2821
// (note: backends between 1.92.0 and 1.92.4 could set an already destroyed texture to ImTextureStatus_WantDestroy
2822
// when invalidating graphics objects twice, which would previously remove it from the list and crash.)
2823
if (tex->Status == ImTextureStatus_WantDestroy && tex->TexID == ImTextureID_Invalid && tex->BackendUserData == NULL)
2824
tex->Status = ImTextureStatus_Destroyed;
2825
2826
// Process texture being destroyed
2827
if (tex->Status == ImTextureStatus_Destroyed)
2828
{
2829
IM_ASSERT(tex->TexID == ImTextureID_Invalid && tex->BackendUserData == NULL && "Backend set texture Status to Destroyed but did not clear TexID/BackendUserData!");
2830
if (tex->WantDestroyNextFrame)
2831
remove_from_list = true; // Destroy was scheduled by us
2832
else
2833
tex->Status = ImTextureStatus_WantCreate; // Destroy was done was backend: recreate it (e.g. freed resources mid-run)
2834
}
2835
2836
// The backend may need defer destroying by a few frames, to handle texture used by previous in-flight rendering.
2837
// We allow the texture staying in _WantDestroy state and increment a counter which the backend can use to take its decision.
2838
if (tex->Status == ImTextureStatus_WantDestroy)
2839
tex->UnusedFrames++;
2840
2841
// Destroy and remove
2842
if (remove_from_list)
2843
{
2844
IM_ASSERT(atlas->TexData != tex);
2845
tex->DestroyPixels();
2846
IM_DELETE(tex);
2847
atlas->TexList.erase(atlas->TexList.begin() + tex_n);
2848
tex_n--;
2849
}
2850
}
2851
}
2852
2853
void ImFontAtlasTextureBlockConvert(const unsigned char* src_pixels, ImTextureFormat src_fmt, int src_pitch, unsigned char* dst_pixels, ImTextureFormat dst_fmt, int dst_pitch, int w, int h)
2854
{
2855
IM_ASSERT(src_pixels != NULL && dst_pixels != NULL);
2856
if (src_fmt == dst_fmt)
2857
{
2858
int line_sz = w * ImTextureDataGetFormatBytesPerPixel(src_fmt);
2859
for (int ny = h; ny > 0; ny--, src_pixels += src_pitch, dst_pixels += dst_pitch)
2860
memcpy(dst_pixels, src_pixels, line_sz);
2861
}
2862
else if (src_fmt == ImTextureFormat_Alpha8 && dst_fmt == ImTextureFormat_RGBA32)
2863
{
2864
for (int ny = h; ny > 0; ny--, src_pixels += src_pitch, dst_pixels += dst_pitch)
2865
{
2866
const ImU8* src_p = (const ImU8*)src_pixels;
2867
ImU32* dst_p = (ImU32*)(void*)dst_pixels;
2868
for (int nx = w; nx > 0; nx--)
2869
*dst_p++ = IM_COL32(255, 255, 255, (unsigned int)(*src_p++));
2870
}
2871
}
2872
else if (src_fmt == ImTextureFormat_RGBA32 && dst_fmt == ImTextureFormat_Alpha8)
2873
{
2874
for (int ny = h; ny > 0; ny--, src_pixels += src_pitch, dst_pixels += dst_pitch)
2875
{
2876
const ImU32* src_p = (const ImU32*)(void*)src_pixels;
2877
ImU8* dst_p = (ImU8*)dst_pixels;
2878
for (int nx = w; nx > 0; nx--)
2879
*dst_p++ = ((*src_p++) >> IM_COL32_A_SHIFT) & 0xFF;
2880
}
2881
}
2882
else
2883
{
2884
IM_ASSERT(0);
2885
}
2886
}
2887
2888
// Source buffer may be written to (used for in-place mods).
2889
// Post-process hooks may eventually be added here.
2890
void ImFontAtlasTextureBlockPostProcess(ImFontAtlasPostProcessData* data)
2891
{
2892
// Multiply operator (legacy)
2893
if (data->FontSrc->RasterizerMultiply != 1.0f)
2894
ImFontAtlasTextureBlockPostProcessMultiply(data, data->FontSrc->RasterizerMultiply);
2895
}
2896
2897
void ImFontAtlasTextureBlockPostProcessMultiply(ImFontAtlasPostProcessData* data, float multiply_factor)
2898
{
2899
unsigned char* pixels = (unsigned char*)data->Pixels;
2900
int pitch = data->Pitch;
2901
if (data->Format == ImTextureFormat_Alpha8)
2902
{
2903
for (int ny = data->Height; ny > 0; ny--, pixels += pitch)
2904
{
2905
ImU8* p = (ImU8*)pixels;
2906
for (int nx = data->Width; nx > 0; nx--, p++)
2907
{
2908
unsigned int v = ImMin((unsigned int)(*p * multiply_factor), (unsigned int)255);
2909
*p = (unsigned char)v;
2910
}
2911
}
2912
}
2913
else if (data->Format == ImTextureFormat_RGBA32) //-V547
2914
{
2915
for (int ny = data->Height; ny > 0; ny--, pixels += pitch)
2916
{
2917
ImU32* p = (ImU32*)(void*)pixels;
2918
for (int nx = data->Width; nx > 0; nx--, p++)
2919
{
2920
unsigned int a = ImMin((unsigned int)(((*p >> IM_COL32_A_SHIFT) & 0xFF) * multiply_factor), (unsigned int)255);
2921
*p = IM_COL32((*p >> IM_COL32_R_SHIFT) & 0xFF, (*p >> IM_COL32_G_SHIFT) & 0xFF, (*p >> IM_COL32_B_SHIFT) & 0xFF, a);
2922
}
2923
}
2924
}
2925
else
2926
{
2927
IM_ASSERT(0);
2928
}
2929
}
2930
2931
// Fill with single color. We don't use this directly but it is convenient for anyone working on uploading custom rects.
2932
void ImFontAtlasTextureBlockFill(ImTextureData* dst_tex, int dst_x, int dst_y, int w, int h, ImU32 col)
2933
{
2934
if (dst_tex->Format == ImTextureFormat_Alpha8)
2935
{
2936
ImU8 col_a = (col >> IM_COL32_A_SHIFT) & 0xFF;
2937
for (int y = 0; y < h; y++)
2938
memset((ImU8*)dst_tex->GetPixelsAt(dst_x, dst_y + y), col_a, w);
2939
}
2940
else
2941
{
2942
for (int y = 0; y < h; y++)
2943
{
2944
ImU32* p = (ImU32*)(void*)dst_tex->GetPixelsAt(dst_x, dst_y + y);
2945
for (int x = w; x > 0; x--, p++)
2946
*p = col;
2947
}
2948
}
2949
}
2950
2951
// Copy block from one texture to another
2952
void ImFontAtlasTextureBlockCopy(ImTextureData* src_tex, int src_x, int src_y, ImTextureData* dst_tex, int dst_x, int dst_y, int w, int h)
2953
{
2954
IM_ASSERT(src_tex->Pixels != NULL && dst_tex->Pixels != NULL);
2955
IM_ASSERT(src_tex->Format == dst_tex->Format);
2956
IM_ASSERT(src_x >= 0 && src_x + w <= src_tex->Width);
2957
IM_ASSERT(src_y >= 0 && src_y + h <= src_tex->Height);
2958
IM_ASSERT(dst_x >= 0 && dst_x + w <= dst_tex->Width);
2959
IM_ASSERT(dst_y >= 0 && dst_y + h <= dst_tex->Height);
2960
for (int y = 0; y < h; y++)
2961
memcpy(dst_tex->GetPixelsAt(dst_x, dst_y + y), src_tex->GetPixelsAt(src_x, src_y + y), w * dst_tex->BytesPerPixel);
2962
}
2963
2964
// Queue texture block update for renderer backend
2965
void ImFontAtlasTextureBlockQueueUpload(ImFontAtlas* atlas, ImTextureData* tex, int x, int y, int w, int h)
2966
{
2967
IM_ASSERT(tex->Status != ImTextureStatus_WantDestroy && tex->Status != ImTextureStatus_Destroyed);
2968
IM_ASSERT(x >= 0 && x <= 0xFFFF && y >= 0 && y <= 0xFFFF && w >= 0 && x + w <= 0x10000 && h >= 0 && y + h <= 0x10000);
2969
IM_UNUSED(atlas);
2970
2971
ImTextureRect req = { (unsigned short)x, (unsigned short)y, (unsigned short)w, (unsigned short)h };
2972
int new_x1 = ImMax(tex->UpdateRect.w == 0 ? 0 : tex->UpdateRect.x + tex->UpdateRect.w, req.x + req.w);
2973
int new_y1 = ImMax(tex->UpdateRect.h == 0 ? 0 : tex->UpdateRect.y + tex->UpdateRect.h, req.y + req.h);
2974
tex->UpdateRect.x = ImMin(tex->UpdateRect.x, req.x);
2975
tex->UpdateRect.y = ImMin(tex->UpdateRect.y, req.y);
2976
tex->UpdateRect.w = (unsigned short)(new_x1 - tex->UpdateRect.x);
2977
tex->UpdateRect.h = (unsigned short)(new_y1 - tex->UpdateRect.y);
2978
tex->UsedRect.x = ImMin(tex->UsedRect.x, req.x);
2979
tex->UsedRect.y = ImMin(tex->UsedRect.y, req.y);
2980
tex->UsedRect.w = (unsigned short)(ImMax(tex->UsedRect.x + tex->UsedRect.w, req.x + req.w) - tex->UsedRect.x);
2981
tex->UsedRect.h = (unsigned short)(ImMax(tex->UsedRect.y + tex->UsedRect.h, req.y + req.h) - tex->UsedRect.y);
2982
atlas->TexIsBuilt = false;
2983
2984
// No need to queue if status is == ImTextureStatus_WantCreate
2985
if (tex->Status == ImTextureStatus_OK || tex->Status == ImTextureStatus_WantUpdates)
2986
{
2987
tex->Status = ImTextureStatus_WantUpdates;
2988
tex->Updates.push_back(req);
2989
}
2990
}
2991
2992
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
2993
static void GetTexDataAsFormat(ImFontAtlas* atlas, ImTextureFormat format, unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel)
2994
{
2995
ImTextureData* tex = atlas->TexData;
2996
if (!atlas->TexIsBuilt || tex == NULL || tex->Pixels == NULL || atlas->TexDesiredFormat != format)
2997
{
2998
atlas->TexDesiredFormat = format;
2999
atlas->Build();
3000
tex = atlas->TexData;
3001
}
3002
if (out_pixels) { *out_pixels = (unsigned char*)tex->Pixels; };
3003
if (out_width) { *out_width = tex->Width; };
3004
if (out_height) { *out_height = tex->Height; };
3005
if (out_bytes_per_pixel) { *out_bytes_per_pixel = tex->BytesPerPixel; }
3006
}
3007
3008
void ImFontAtlas::GetTexDataAsAlpha8(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel)
3009
{
3010
GetTexDataAsFormat(this, ImTextureFormat_Alpha8, out_pixels, out_width, out_height, out_bytes_per_pixel);
3011
}
3012
3013
void ImFontAtlas::GetTexDataAsRGBA32(unsigned char** out_pixels, int* out_width, int* out_height, int* out_bytes_per_pixel)
3014
{
3015
GetTexDataAsFormat(this, ImTextureFormat_RGBA32, out_pixels, out_width, out_height, out_bytes_per_pixel);
3016
}
3017
3018
bool ImFontAtlas::Build()
3019
{
3020
ImFontAtlasBuildMain(this);
3021
return true;
3022
}
3023
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
3024
3025
ImFont* ImFontAtlas::AddFont(const ImFontConfig* font_cfg_in)
3026
{
3027
// Sanity Checks
3028
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
3029
IM_ASSERT((font_cfg_in->FontData != NULL && font_cfg_in->FontDataSize > 0) || (font_cfg_in->FontLoader != NULL));
3030
//IM_ASSERT(font_cfg_in->SizePixels > 0.0f && "Is ImFontConfig struct correctly initialized?");
3031
IM_ASSERT(font_cfg_in->RasterizerDensity > 0.0f && "Is ImFontConfig struct correctly initialized?");
3032
if (font_cfg_in->GlyphOffset.x != 0.0f || font_cfg_in->GlyphOffset.y != 0.0f || font_cfg_in->GlyphMinAdvanceX != 0.0f || font_cfg_in->GlyphMaxAdvanceX != FLT_MAX)
3033
IM_ASSERT(font_cfg_in->SizePixels != 0.0f && "Specifying glyph offset/advances requires a reference size to base it on.");
3034
3035
// Lazily create builder on the first call to AddFont
3036
if (Builder == NULL)
3037
ImFontAtlasBuildInit(this);
3038
3039
// Create new font
3040
ImFont* font;
3041
if (!font_cfg_in->MergeMode)
3042
{
3043
font = IM_NEW(ImFont)();
3044
font->FontId = FontNextUniqueID++;
3045
font->Flags = font_cfg_in->Flags;
3046
font->LegacySize = font_cfg_in->SizePixels;
3047
font->DefaultWeight = font_cfg_in->Weight;
3048
font->CurrentRasterizerDensity = font_cfg_in->RasterizerDensity;
3049
Fonts.push_back(font);
3050
}
3051
else
3052
{
3053
IM_ASSERT(Fonts.Size > 0 && "Cannot use MergeMode for the first font"); // When using MergeMode make sure that a font has already been added before.
3054
font = font_cfg_in->DstFont ? font_cfg_in->DstFont : Fonts.back();
3055
}
3056
3057
// Add to list
3058
Sources.push_back(*font_cfg_in);
3059
ImFontConfig* font_cfg = &Sources.back();
3060
if (font_cfg->DstFont == NULL)
3061
font_cfg->DstFont = font;
3062
font->Sources.push_back(font_cfg);
3063
ImFontAtlasBuildUpdatePointers(this); // Pointers to Sources are otherwise dangling after we called Sources.push_back().
3064
3065
// Sanity check
3066
// We don't round cfg.SizePixels yet as relative size of merged fonts are used afterwards.
3067
if (font_cfg->GlyphExcludeRanges != NULL)
3068
{
3069
int size = 0;
3070
for (const ImWchar* p = font_cfg->GlyphExcludeRanges; p[0] != 0; p++, size++) {}
3071
IM_ASSERT((size & 1) == 0 && "GlyphExcludeRanges[] size must be multiple of two!");
3072
IM_ASSERT((size <= 64) && "GlyphExcludeRanges[] size must be small!");
3073
font_cfg->GlyphExcludeRanges = (ImWchar*)ImMemdup(font_cfg->GlyphExcludeRanges, sizeof(font_cfg->GlyphExcludeRanges[0]) * (size + 1));
3074
}
3075
if (font_cfg->FontLoader != NULL)
3076
{
3077
IM_ASSERT(font_cfg->FontLoader->FontBakedLoadGlyph != NULL);
3078
IM_ASSERT(font_cfg->FontLoader->LoaderInit == NULL && font_cfg->FontLoader->LoaderShutdown == NULL); // FIXME-NEWATLAS: Unsupported yet.
3079
}
3080
IM_ASSERT(font_cfg->FontLoaderData == NULL);
3081
3082
if (!ImFontAtlasFontSourceInit(this, font_cfg))
3083
{
3084
// Rollback (this is a fragile/rarely exercised code-path. TestSuite's "misc_atlas_add_invalid_font" aim to test this)
3085
ImFontAtlasFontDestroySourceData(this, font_cfg);
3086
Sources.pop_back();
3087
font->Sources.pop_back();
3088
if (!font_cfg->MergeMode)
3089
{
3090
IM_DELETE(font);
3091
Fonts.pop_back();
3092
}
3093
return NULL;
3094
}
3095
ImFontAtlasFontSourceAddToFont(this, font, font_cfg);
3096
3097
return font;
3098
}
3099
3100
// Default font TTF is compressed with stb_compress then base85 encoded (see misc/fonts/binary_to_compressed_c.cpp for encoder)
3101
static unsigned int stb_decompress_length(const unsigned char* input);
3102
static unsigned int stb_decompress(unsigned char* output, const unsigned char* input, unsigned int length);
3103
static unsigned int Decode85Byte(char c) { return c >= '\\' ? c-36 : c-35; }
3104
static void Decode85(const unsigned char* src, unsigned char* dst)
3105
{
3106
while (*src)
3107
{
3108
unsigned int tmp = Decode85Byte(src[0]) + 85 * (Decode85Byte(src[1]) + 85 * (Decode85Byte(src[2]) + 85 * (Decode85Byte(src[3]) + 85 * Decode85Byte(src[4]))));
3109
dst[0] = ((tmp >> 0) & 0xFF); dst[1] = ((tmp >> 8) & 0xFF); dst[2] = ((tmp >> 16) & 0xFF); dst[3] = ((tmp >> 24) & 0xFF); // We can't assume little-endianness.
3110
src += 5;
3111
dst += 4;
3112
}
3113
}
3114
#ifndef IMGUI_DISABLE_DEFAULT_FONT
3115
static const char* GetDefaultCompressedFontDataProggyClean(int* out_size);
3116
static const char* GetDefaultCompressedFontDataProggyVector(int* out_size);
3117
#endif
3118
3119
// This duplicates some of the logic in UpdateFontsNewFrame() which is a bit chicken-and-eggy/tricky to extract due to variety of codepaths and possible initialization ordering.
3120
static float GetExpectedContextFontSize(ImGuiContext* ctx)
3121
{
3122
return ((ctx->Style.FontSizeBase > 0.0f) ? ctx->Style.FontSizeBase : 13.0f) * ctx->Style.FontScaleMain * ctx->Style.FontScaleDpi;
3123
}
3124
3125
// Legacy function with heuristic to select Pixel or Vector font.
3126
// The selection is based on (style.FontSizeBase * style.FontScaleMain * style.FontScaleDpi) reaching a small threshold at the time of adding the default font.
3127
// Prefer calling AddFontDefaultVector() or AddFontDefaultBitmap() based on your own logic.
3128
ImFont* ImFontAtlas::AddFontDefault(const ImFontConfig* font_cfg)
3129
{
3130
if (OwnerContext == NULL || GetExpectedContextFontSize(OwnerContext) >= 16.0f)
3131
return AddFontDefaultVector(font_cfg);
3132
else
3133
return AddFontDefaultBitmap(font_cfg);
3134
}
3135
3136
// Load embedded ProggyClean.ttf. Default size 13, disable oversampling.
3137
// If you want a similar font which may be better scaled, consider using AddFontDefaultVector().
3138
ImFont* ImFontAtlas::AddFontDefaultBitmap(const ImFontConfig* font_cfg_template)
3139
{
3140
#ifndef IMGUI_DISABLE_DEFAULT_FONT
3141
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
3142
if (!font_cfg_template)
3143
{
3144
font_cfg.OversampleH = font_cfg.OversampleV = 1;
3145
font_cfg.PixelSnapH = true;
3146
}
3147
if (font_cfg.SizePixels <= 0.0f)
3148
font_cfg.SizePixels = 13.0f; // This only serves (1) as a reference for GlyphOffset.y setting and (2) as a default for pre-1.92 backend.
3149
if (font_cfg.Name[0] == '\0')
3150
ImFormatString(font_cfg.Name, IM_COUNTOF(font_cfg.Name), "ProggyClean.ttf");
3151
font_cfg.EllipsisChar = (ImWchar)0x0085;
3152
font_cfg.GlyphOffset.y += 1.0f * (font_cfg.SizePixels / 13.0f); // Add +1 offset per 13 units
3153
3154
int ttf_compressed_size = 0;
3155
const char* ttf_compressed = GetDefaultCompressedFontDataProggyClean(&ttf_compressed_size);
3156
return AddFontFromMemoryCompressedTTF(ttf_compressed, ttf_compressed_size, font_cfg.SizePixels, &font_cfg);
3157
#else
3158
IM_ASSERT(0 && "Function is disabled in this build.");
3159
IM_UNUSED(font_cfg_template);
3160
return NULL;
3161
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FONT
3162
}
3163
3164
// Load a minimal version of ProggyVector, designed to match our good old ProggyClean, but nicely scalable.
3165
// (See misc/fonts/ProggyVector-ExtractScript.txt for details)
3166
ImFont* ImFontAtlas::AddFontDefaultVector(const ImFontConfig* font_cfg_template)
3167
{
3168
#ifndef IMGUI_DISABLE_DEFAULT_FONT
3169
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
3170
if (font_cfg.SizePixels <= 0.0f)
3171
font_cfg.SizePixels = 16.0f;
3172
if (font_cfg.Name[0] == '\0')
3173
ImFormatString(font_cfg.Name, IM_COUNTOF(font_cfg.Name), "ProggyVector.ttf");
3174
font_cfg.ExtraSizeScale = 1.140f; // Match ProggyClean
3175
font_cfg.GlyphOffset.y += -0.5f * (font_cfg.SizePixels / 13.0f); // Closer match ProggyClean + avoid descenders going too high (with current code).
3176
3177
int ttf_compressed_size = 0;
3178
const char* ttf_compressed = GetDefaultCompressedFontDataProggyVector(&ttf_compressed_size);
3179
return AddFontFromMemoryCompressedTTF(ttf_compressed, ttf_compressed_size, font_cfg.SizePixels, &font_cfg);
3180
#else
3181
IM_ASSERT(0 && "Function is disabled in this build.");
3182
IM_UNUSED(font_cfg_template);
3183
return NULL;
3184
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FONT
3185
}
3186
3187
ImFont* ImFontAtlas::AddFontFromFileTTF(const char* filename, float size_pixels, float weight, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
3188
{
3189
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
3190
size_t data_size = 0;
3191
void* data = ImFileLoadToMemory(filename, "rb", &data_size, 0);
3192
if (!data)
3193
{
3194
if (font_cfg_template == NULL || (font_cfg_template->Flags & ImFontFlags_NoLoadError) == 0)
3195
{
3196
IMGUI_DEBUG_LOG("While loading '%s'\n", filename);
3197
IM_ASSERT_USER_ERROR(0, "Could not load font file!");
3198
}
3199
return NULL;
3200
}
3201
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
3202
if (font_cfg.Name[0] == '\0')
3203
{
3204
// Store a short copy of filename into into the font name for convenience
3205
const char* p;
3206
for (p = filename + ImStrlen(filename); p > filename && p[-1] != '/' && p[-1] != '\\'; p--) {}
3207
ImFormatString(font_cfg.Name, IM_COUNTOF(font_cfg.Name), "%s", p);
3208
}
3209
return AddFontFromMemoryTTF(data, (int)data_size, size_pixels, weight, &font_cfg, glyph_ranges);
3210
}
3211
3212
// NB: Transfer ownership of 'ttf_data' to ImFontAtlas, unless font_cfg_template->FontDataOwnedByAtlas == false. Owned TTF buffer will be deleted after Build().
3213
ImFont* ImFontAtlas::AddFontFromMemoryTTF(void* font_data, int font_data_size, float size_pixels, float weight, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
3214
{
3215
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
3216
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
3217
IM_ASSERT(font_cfg.FontData == NULL);
3218
IM_ASSERT(font_data_size > 100 && "Incorrect value for font_data_size!"); // Heuristic to prevent accidentally passing a wrong value to font_data_size.
3219
font_cfg.FontData = font_data;
3220
font_cfg.FontDataSize = font_data_size;
3221
font_cfg.SizePixels = size_pixels > 0.0f ? size_pixels : font_cfg.SizePixels;
3222
font_cfg.Weight = weight > 0.0f ? weight : font_cfg.Weight;
3223
if (glyph_ranges)
3224
font_cfg.GlyphRanges = glyph_ranges;
3225
return AddFont(&font_cfg);
3226
}
3227
3228
ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_data, int compressed_ttf_size, float size_pixels, float weight, const ImFontConfig* font_cfg_template, const ImWchar* glyph_ranges)
3229
{
3230
const unsigned int buf_decompressed_size = stb_decompress_length((const unsigned char*)compressed_ttf_data);
3231
unsigned char* buf_decompressed_data = (unsigned char*)IM_ALLOC(buf_decompressed_size);
3232
stb_decompress(buf_decompressed_data, (const unsigned char*)compressed_ttf_data, (unsigned int)compressed_ttf_size);
3233
3234
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
3235
IM_ASSERT(font_cfg.FontData == NULL);
3236
font_cfg.FontDataOwnedByAtlas = true;
3237
return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, weight, &font_cfg, glyph_ranges);
3238
}
3239
3240
ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, float weight, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
3241
{
3242
int compressed_ttf_size = (((int)ImStrlen(compressed_ttf_data_base85) + 4) / 5) * 4;
3243
void* compressed_ttf = IM_ALLOC((size_t)compressed_ttf_size);
3244
Decode85((const unsigned char*)compressed_ttf_data_base85, (unsigned char*)compressed_ttf);
3245
ImFont* font = AddFontFromMemoryCompressedTTF(compressed_ttf, compressed_ttf_size, size_pixels, weight, font_cfg, glyph_ranges);
3246
IM_FREE(compressed_ttf);
3247
return font;
3248
}
3249
3250
// On font removal we need to remove references (otherwise we could queue removal?)
3251
// We allow old_font == new_font which forces updating all values (e.g. sizes)
3252
void ImFontAtlasBuildNotifySetFont(ImFontAtlas* atlas, ImFont* old_font, ImFont* new_font)
3253
{
3254
for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas)
3255
{
3256
if (shared_data->Font == old_font)
3257
shared_data->Font = new_font;
3258
if (ImGuiContext* ctx = shared_data->Context)
3259
{
3260
if (ctx->IO.FontDefault == old_font)
3261
ctx->IO.FontDefault = new_font;
3262
if (ctx->Font == old_font)
3263
{
3264
ImGuiContext* curr_ctx = ImGui::GetCurrentContext();
3265
bool need_bind_ctx = ctx != curr_ctx;
3266
if (need_bind_ctx)
3267
ImGui::SetCurrentContext(ctx);
3268
ImGui::SetCurrentFont(new_font, ctx->FontSizeBase, ctx->FontSize, ctx->FontWeight);
3269
if (need_bind_ctx)
3270
ImGui::SetCurrentContext(curr_ctx);
3271
}
3272
for (ImFontStackData& font_stack_data : ctx->FontStack)
3273
if (font_stack_data.Font == old_font)
3274
font_stack_data.Font = new_font;
3275
}
3276
}
3277
}
3278
3279
void ImFontAtlas::RemoveFont(ImFont* font)
3280
{
3281
IM_ASSERT(!Locked && "Cannot modify a locked ImFontAtlas!");
3282
3283
ImFontAtlasFontDestroyOutput(this, font);
3284
for (ImFontConfig* src : font->Sources)
3285
ImFontAtlasFontDestroySourceData(this, src);
3286
for (int src_n = 0; src_n < Sources.Size; src_n++)
3287
if (Sources[src_n].DstFont == font)
3288
Sources.erase(&Sources[src_n--]);
3289
3290
bool removed = Fonts.find_erase(font);
3291
IM_ASSERT(removed);
3292
IM_UNUSED(removed);
3293
3294
ImFontAtlasBuildUpdatePointers(this);
3295
3296
font->OwnerAtlas = NULL;
3297
IM_DELETE(font);
3298
3299
// Notify external systems
3300
ImFont* new_current_font = Fonts.empty() ? NULL : Fonts[0];
3301
ImFontAtlasBuildNotifySetFont(this, font, new_current_font);
3302
}
3303
3304
// At it is common to do an AddCustomRect() followed by a GetCustomRect(), we provide an optional 'ImFontAtlasRect* out_r = NULL' argument to retrieve the info straight away.
3305
ImFontAtlasRectId ImFontAtlas::AddCustomRect(int width, int height, ImFontAtlasRect* out_r)
3306
{
3307
IM_ASSERT(width > 0 && width <= 0xFFFF);
3308
IM_ASSERT(height > 0 && height <= 0xFFFF);
3309
3310
if (Builder == NULL)
3311
ImFontAtlasBuildInit(this);
3312
3313
ImFontAtlasRectId r_id = ImFontAtlasPackAddRect(this, width, height);
3314
if (r_id == ImFontAtlasRectId_Invalid)
3315
return ImFontAtlasRectId_Invalid;
3316
if (out_r != NULL)
3317
GetCustomRect(r_id, out_r);
3318
3319
if (RendererHasTextures)
3320
{
3321
ImTextureRect* r = ImFontAtlasPackGetRect(this, r_id);
3322
ImFontAtlasTextureBlockQueueUpload(this, TexData, r->x, r->y, r->w, r->h);
3323
}
3324
return r_id;
3325
}
3326
3327
void ImFontAtlas::RemoveCustomRect(ImFontAtlasRectId id)
3328
{
3329
if (ImFontAtlasPackGetRectSafe(this, id) == NULL)
3330
return;
3331
ImFontAtlasPackDiscardRect(this, id);
3332
}
3333
3334
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
3335
// This API does not make sense anymore with scalable fonts.
3336
// - Prefer adding a font source (ImFontConfig) using a custom/procedural loader.
3337
// - You may use ImFontFlags_LockBakedSizes to limit an existing font to known baked sizes:
3338
// ImFont* myfont = io.Fonts->AddFontFromFileTTF(....);
3339
// myfont->GetFontBaked(16.0f);
3340
// myfont->Flags |= ImFontFlags_LockBakedSizes;
3341
ImFontAtlasRectId ImFontAtlas::AddCustomRectFontGlyph(ImFont* font, ImWchar codepoint, int width, int height, float advance_x, const ImVec2& offset)
3342
{
3343
float font_size = font->LegacySize;
3344
float font_weight = font->DefaultWeight;
3345
return AddCustomRectFontGlyphForSize(font, font_size, font_weight, codepoint, width, height, advance_x, offset);
3346
}
3347
// FIXME: we automatically set glyph.Colored=true by default.
3348
// If you need to alter this, you can write 'font->Glyphs.back()->Colored' after calling AddCustomRectFontGlyph().
3349
ImFontAtlasRectId ImFontAtlas::AddCustomRectFontGlyphForSize(ImFont* font, float font_size, float font_weight, ImWchar codepoint, int width, int height, float advance_x, const ImVec2& offset)
3350
{
3351
#ifdef IMGUI_USE_WCHAR32
3352
IM_ASSERT(codepoint <= IM_UNICODE_CODEPOINT_MAX);
3353
#endif
3354
IM_ASSERT(font != NULL);
3355
IM_ASSERT(width > 0 && width <= 0xFFFF);
3356
IM_ASSERT(height > 0 && height <= 0xFFFF);
3357
3358
ImFontBaked* baked = font->GetFontBaked(font_size, font_weight);
3359
3360
ImFontAtlasRectId r_id = ImFontAtlasPackAddRect(this, width, height);
3361
if (r_id == ImFontAtlasRectId_Invalid)
3362
return ImFontAtlasRectId_Invalid;
3363
ImTextureRect* r = ImFontAtlasPackGetRect(this, r_id);
3364
if (RendererHasTextures)
3365
ImFontAtlasTextureBlockQueueUpload(this, TexData, r->x, r->y, r->w, r->h);
3366
3367
if (baked->IsGlyphLoaded(codepoint))
3368
ImFontAtlasBakedDiscardFontGlyph(this, font, baked, baked->FindGlyph(codepoint));
3369
3370
ImFontGlyph glyph;
3371
glyph.Codepoint = codepoint;
3372
glyph.AdvanceX = advance_x;
3373
glyph.X0 = offset.x;
3374
glyph.Y0 = offset.y;
3375
glyph.X1 = offset.x + r->w;
3376
glyph.Y1 = offset.y + r->h;
3377
glyph.Visible = true;
3378
glyph.Colored = true; // FIXME: Arbitrary
3379
glyph.PackId = r_id;
3380
ImFontAtlasBakedAddFontGlyph(this, baked, font->Sources[0], &glyph);
3381
return r_id;
3382
}
3383
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
3384
3385
bool ImFontAtlas::GetCustomRect(ImFontAtlasRectId id, ImFontAtlasRect* out_r) const
3386
{
3387
ImTextureRect* r = ImFontAtlasPackGetRectSafe((ImFontAtlas*)this, id);
3388
if (r == NULL)
3389
return false;
3390
IM_ASSERT(TexData->Width > 0 && TexData->Height > 0); // Font atlas needs to be built before we can calculate UV coordinates
3391
if (out_r == NULL)
3392
return true;
3393
out_r->x = r->x;
3394
out_r->y = r->y;
3395
out_r->w = r->w;
3396
out_r->h = r->h;
3397
out_r->uv0 = ImVec2((float)(r->x), (float)(r->y)) * TexUvScale;
3398
out_r->uv1 = ImVec2((float)(r->x + r->w), (float)(r->y + r->h)) * TexUvScale;
3399
return true;
3400
}
3401
3402
bool ImFontAtlasGetMouseCursorTexData(ImFontAtlas* atlas, ImGuiMouseCursor cursor_type, ImVec2* out_offset, ImVec2* out_size, ImVec2 out_uv_border[2], ImVec2 out_uv_fill[2])
3403
{
3404
if (cursor_type <= ImGuiMouseCursor_None || cursor_type >= ImGuiMouseCursor_COUNT)
3405
return false;
3406
if (atlas->Flags & ImFontAtlasFlags_NoMouseCursors)
3407
return false;
3408
3409
ImTextureRect* r = ImFontAtlasPackGetRect(atlas, atlas->Builder->PackIdMouseCursors);
3410
ImVec2 pos = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][0] + ImVec2((float)r->x, (float)r->y);
3411
ImVec2 size = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][1];
3412
*out_size = size;
3413
*out_offset = FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[cursor_type][2];
3414
out_uv_border[0] = (pos) * atlas->TexUvScale;
3415
out_uv_border[1] = (pos + size) * atlas->TexUvScale;
3416
pos.x += FONT_ATLAS_DEFAULT_TEX_DATA_W + 1;
3417
out_uv_fill[0] = (pos) * atlas->TexUvScale;
3418
out_uv_fill[1] = (pos + size) * atlas->TexUvScale;
3419
return true;
3420
}
3421
3422
// When atlas->RendererHasTextures = true, this is only called if no font were loaded.
3423
void ImFontAtlasBuildMain(ImFontAtlas* atlas)
3424
{
3425
IM_ASSERT(!atlas->Locked && "Cannot modify a locked ImFontAtlas!");
3426
if (atlas->TexData && atlas->TexData->Format != atlas->TexDesiredFormat)
3427
ImFontAtlasBuildClear(atlas);
3428
3429
if (atlas->Builder == NULL)
3430
ImFontAtlasBuildInit(atlas);
3431
3432
// Default font is none are specified
3433
if (atlas->Sources.Size == 0)
3434
atlas->AddFontDefault();
3435
3436
// [LEGACY] For backends not supporting RendererHasTextures: preload all glyphs
3437
ImFontAtlasBuildUpdateRendererHasTexturesFromContext(atlas);
3438
if (atlas->RendererHasTextures == false) // ~ImGuiBackendFlags_RendererHasTextures
3439
ImFontAtlasBuildLegacyPreloadAllGlyphRanges(atlas);
3440
atlas->TexIsBuilt = true;
3441
}
3442
3443
void ImFontAtlasBuildGetOversampleFactors(ImFontConfig* src, ImFontBaked* baked, int* out_oversample_h, int* out_oversample_v)
3444
{
3445
// (Only used by stb_truetype builder)
3446
// Automatically disable horizontal oversampling over size 36
3447
const float raster_size = baked->Size * baked->RasterizerDensity * src->RasterizerDensity;
3448
*out_oversample_h = (src->OversampleH != 0) ? src->OversampleH : (raster_size > 36.0f || src->PixelSnapH) ? 1 : 2;
3449
*out_oversample_v = (src->OversampleV != 0) ? src->OversampleV : 1;
3450
}
3451
3452
// Setup main font loader for the atlas
3453
// Every font source (ImFontConfig) will use this unless ImFontConfig::FontLoader specify a custom loader.
3454
void ImFontAtlasBuildSetupFontLoader(ImFontAtlas* atlas, const ImFontLoader* font_loader)
3455
{
3456
if (atlas->FontLoader == font_loader)
3457
return;
3458
IM_ASSERT(!atlas->Locked && "Cannot modify a locked ImFontAtlas!");
3459
3460
for (ImFont* font : atlas->Fonts)
3461
ImFontAtlasFontDestroyOutput(atlas, font);
3462
if (atlas->Builder && atlas->FontLoader && atlas->FontLoader->LoaderShutdown)
3463
atlas->FontLoader->LoaderShutdown(atlas);
3464
3465
atlas->FontLoader = font_loader;
3466
atlas->FontLoaderName = font_loader ? font_loader->Name : "NULL";
3467
IM_ASSERT(atlas->FontLoaderData == NULL);
3468
3469
if (atlas->Builder && atlas->FontLoader && atlas->FontLoader->LoaderInit)
3470
atlas->FontLoader->LoaderInit(atlas);
3471
for (ImFont* font : atlas->Fonts)
3472
ImFontAtlasFontInitOutput(atlas, font);
3473
for (ImFont* font : atlas->Fonts)
3474
for (ImFontConfig* src : font->Sources)
3475
ImFontAtlasFontSourceAddToFont(atlas, font, src);
3476
}
3477
3478
// Preload all glyph ranges for legacy backends.
3479
// This may lead to multiple texture creation which might be a little slower than before.
3480
void ImFontAtlasBuildLegacyPreloadAllGlyphRanges(ImFontAtlas* atlas)
3481
{
3482
atlas->Builder->PreloadedAllGlyphsRanges = true;
3483
for (ImFont* font : atlas->Fonts)
3484
{
3485
ImFontBaked* baked = font->GetFontBaked(font->LegacySize, font->Sources[0]->Weight);
3486
if (font->FallbackChar != 0)
3487
baked->FindGlyph(font->FallbackChar);
3488
if (font->EllipsisChar != 0)
3489
baked->FindGlyph(font->EllipsisChar);
3490
for (ImFontConfig* src : font->Sources)
3491
{
3492
const ImWchar* ranges = src->GlyphRanges ? src->GlyphRanges : atlas->GetGlyphRangesDefault();
3493
for (; ranges[0]; ranges += 2)
3494
for (unsigned int c = ranges[0]; c <= ranges[1] && c <= IM_UNICODE_CODEPOINT_MAX; c++) //-V560
3495
baked->FindGlyph((ImWchar)c);
3496
}
3497
}
3498
}
3499
3500
// FIXME: May make ImFont::Sources a ImSpan<> and move ownership to ImFontAtlas
3501
void ImFontAtlasBuildUpdatePointers(ImFontAtlas* atlas)
3502
{
3503
for (ImFont* font : atlas->Fonts)
3504
font->Sources.resize(0);
3505
for (ImFontConfig& src : atlas->Sources)
3506
src.DstFont->Sources.push_back(&src);
3507
}
3508
3509
// Render a white-colored bitmap encoded in a string
3510
void ImFontAtlasBuildRenderBitmapFromString(ImFontAtlas* atlas, int x, int y, int w, int h, const char* in_str, char in_marker_char)
3511
{
3512
ImTextureData* tex = atlas->TexData;
3513
IM_ASSERT(x >= 0 && x + w <= tex->Width);
3514
IM_ASSERT(y >= 0 && y + h <= tex->Height);
3515
3516
switch (tex->Format)
3517
{
3518
case ImTextureFormat_Alpha8:
3519
{
3520
ImU8* out_p = (ImU8*)tex->GetPixelsAt(x, y);
3521
for (int off_y = 0; off_y < h; off_y++, out_p += tex->Width, in_str += w)
3522
for (int off_x = 0; off_x < w; off_x++)
3523
out_p[off_x] = (in_str[off_x] == in_marker_char) ? 0xFF : 0x00;
3524
break;
3525
}
3526
case ImTextureFormat_RGBA32:
3527
{
3528
ImU32* out_p = (ImU32*)tex->GetPixelsAt(x, y);
3529
for (int off_y = 0; off_y < h; off_y++, out_p += tex->Width, in_str += w)
3530
for (int off_x = 0; off_x < w; off_x++)
3531
out_p[off_x] = (in_str[off_x] == in_marker_char) ? IM_COL32_WHITE : IM_COL32_BLACK_TRANS;
3532
break;
3533
}
3534
}
3535
}
3536
3537
static void ImFontAtlasBuildUpdateBasicTexData(ImFontAtlas* atlas)
3538
{
3539
// Pack and store identifier so we can refresh UV coordinates on texture resize.
3540
// FIXME-NEWATLAS: User/custom rects where user code wants to store UV coordinates will need to do the same thing.
3541
ImFontAtlasBuilder* builder = atlas->Builder;
3542
ImVec2i pack_size = (atlas->Flags & ImFontAtlasFlags_NoMouseCursors) ? ImVec2i(2, 2) : ImVec2i(FONT_ATLAS_DEFAULT_TEX_DATA_W * 2 + 1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
3543
3544
ImFontAtlasRect r;
3545
bool add_and_draw = (atlas->GetCustomRect(builder->PackIdMouseCursors, &r) == false);
3546
if (add_and_draw)
3547
{
3548
builder->PackIdMouseCursors = atlas->AddCustomRect(pack_size.x, pack_size.y, &r);
3549
IM_ASSERT(builder->PackIdMouseCursors != ImFontAtlasRectId_Invalid);
3550
3551
// Draw to texture
3552
if (atlas->Flags & ImFontAtlasFlags_NoMouseCursors)
3553
{
3554
// 2x2 white pixels
3555
ImFontAtlasBuildRenderBitmapFromString(atlas, r.x, r.y, 2, 2, "XX" "XX", 'X');
3556
}
3557
else
3558
{
3559
// 2x2 white pixels + mouse cursors
3560
const int x_for_white = r.x;
3561
const int x_for_black = r.x + FONT_ATLAS_DEFAULT_TEX_DATA_W + 1;
3562
ImFontAtlasBuildRenderBitmapFromString(atlas, x_for_white, r.y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, '.');
3563
ImFontAtlasBuildRenderBitmapFromString(atlas, x_for_black, r.y, FONT_ATLAS_DEFAULT_TEX_DATA_W, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, 'X');
3564
}
3565
}
3566
3567
// Refresh UV coordinates
3568
atlas->TexUvWhitePixel = ImVec2((r.x + 0.5f) * atlas->TexUvScale.x, (r.y + 0.5f) * atlas->TexUvScale.y);
3569
}
3570
3571
static void ImFontAtlasBuildUpdateLinesTexData(ImFontAtlas* atlas)
3572
{
3573
if (atlas->Flags & ImFontAtlasFlags_NoBakedLines)
3574
return;
3575
3576
// Pack and store identifier so we can refresh UV coordinates on texture resize.
3577
ImTextureData* tex = atlas->TexData;
3578
ImFontAtlasBuilder* builder = atlas->Builder;
3579
3580
ImFontAtlasRect r;
3581
bool add_and_draw = atlas->GetCustomRect(builder->PackIdLinesTexData, &r) == false;
3582
if (add_and_draw)
3583
{
3584
ImVec2i pack_size = ImVec2i(IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 2, IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1);
3585
builder->PackIdLinesTexData = atlas->AddCustomRect(pack_size.x, pack_size.y, &r);
3586
IM_ASSERT(builder->PackIdLinesTexData != ImFontAtlasRectId_Invalid);
3587
}
3588
3589
// Register texture region for thick lines
3590
// The +2 here is to give space for the end caps, whilst height +1 is to accommodate the fact we have a zero-width row
3591
// This generates a triangular shape in the texture, with the various line widths stacked on top of each other to allow interpolation between them
3592
for (int n = 0; n < IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1; n++) // +1 because of the zero-width row
3593
{
3594
// Each line consists of at least two empty pixels at the ends, with a line of solid pixels in the middle
3595
const int y = n;
3596
const int line_width = n;
3597
const int pad_left = (r.w - line_width) / 2;
3598
const int pad_right = r.w - (pad_left + line_width);
3599
IM_ASSERT(pad_left + line_width + pad_right == r.w && y < r.h); // Make sure we're inside the texture bounds before we start writing pixels
3600
3601
// Write each slice
3602
if (add_and_draw && tex->Format == ImTextureFormat_Alpha8)
3603
{
3604
ImU8* write_ptr = (ImU8*)tex->GetPixelsAt(r.x, r.y + y);
3605
for (int i = 0; i < pad_left; i++)
3606
*(write_ptr + i) = 0x00;
3607
3608
for (int i = 0; i < line_width; i++)
3609
*(write_ptr + pad_left + i) = 0xFF;
3610
3611
for (int i = 0; i < pad_right; i++)
3612
*(write_ptr + pad_left + line_width + i) = 0x00;
3613
}
3614
else if (add_and_draw && tex->Format == ImTextureFormat_RGBA32)
3615
{
3616
ImU32* write_ptr = (ImU32*)(void*)tex->GetPixelsAt(r.x, r.y + y);
3617
for (int i = 0; i < pad_left; i++)
3618
*(write_ptr + i) = IM_COL32(255, 255, 255, 0);
3619
3620
for (int i = 0; i < line_width; i++)
3621
*(write_ptr + pad_left + i) = IM_COL32_WHITE;
3622
3623
for (int i = 0; i < pad_right; i++)
3624
*(write_ptr + pad_left + line_width + i) = IM_COL32(255, 255, 255, 0);
3625
}
3626
3627
// Refresh UV coordinates
3628
ImVec2 uv0 = ImVec2((float)(r.x + pad_left - 1), (float)(r.y + y)) * atlas->TexUvScale;
3629
ImVec2 uv1 = ImVec2((float)(r.x + pad_left + line_width + 1), (float)(r.y + y + 1)) * atlas->TexUvScale;
3630
float half_v = (uv0.y + uv1.y) * 0.5f; // Calculate a constant V in the middle of the row to avoid sampling artifacts
3631
atlas->TexUvLines[n] = ImVec4(uv0.x, half_v, uv1.x, half_v);
3632
}
3633
}
3634
3635
//-----------------------------------------------------------------------------------------------------------------------------
3636
3637
// Was tempted to lazily init FontSrc but wouldn't save much + makes it more complicated to detect invalid data at AddFont()
3638
bool ImFontAtlasFontInitOutput(ImFontAtlas* atlas, ImFont* font)
3639
{
3640
bool ret = true;
3641
for (ImFontConfig* src : font->Sources)
3642
if (!ImFontAtlasFontSourceInit(atlas, src))
3643
ret = false;
3644
IM_ASSERT(ret); // Unclear how to react to this meaningfully. Assume that result will be same as initial AddFont() call.
3645
return ret;
3646
}
3647
3648
// Keep source/input FontData
3649
void ImFontAtlasFontDestroyOutput(ImFontAtlas* atlas, ImFont* font)
3650
{
3651
font->ClearOutputData();
3652
for (ImFontConfig* src : font->Sources)
3653
{
3654
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
3655
if (loader && loader->FontSrcDestroy != NULL)
3656
loader->FontSrcDestroy(atlas, src);
3657
}
3658
}
3659
3660
void ImFontAtlasFontRebuildOutput(ImFontAtlas* atlas, ImFont* font)
3661
{
3662
ImFontAtlasFontDestroyOutput(atlas, font);
3663
ImFontAtlasFontInitOutput(atlas, font);
3664
}
3665
3666
//-----------------------------------------------------------------------------------------------------------------------------
3667
3668
bool ImFontAtlasFontSourceInit(ImFontAtlas* atlas, ImFontConfig* src)
3669
{
3670
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
3671
if (loader->FontSrcInit != NULL && !loader->FontSrcInit(atlas, src))
3672
return false;
3673
return true;
3674
}
3675
3676
void ImFontAtlasFontSourceAddToFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* src)
3677
{
3678
if (src->MergeMode == false)
3679
{
3680
font->ClearOutputData();
3681
//font->FontSize = src->SizePixels;
3682
font->OwnerAtlas = atlas;
3683
IM_ASSERT(font->Sources[0] == src);
3684
}
3685
atlas->TexIsBuilt = false; // For legacy backends
3686
ImFontAtlasBuildSetupFontSpecialGlyphs(atlas, font, src);
3687
}
3688
3689
void ImFontAtlasFontDestroySourceData(ImFontAtlas* atlas, ImFontConfig* src)
3690
{
3691
IM_UNUSED(atlas);
3692
// IF YOU GET A CRASH IN THE IM_FREE() CALL HERE AND USED AddFontFromMemoryTTF():
3693
// - DUE TO LEGACY REASON AddFontFromMemoryTTF() TRANSFERS MEMORY OWNERSHIP BY DEFAULT.
3694
// - IT WILL THEREFORE CRASH WHEN PASSED DATA WHICH MAY NOT BE FREEED BY IMGUI.
3695
// - USE `ImFontConfig font_cfg; font_cfg.FontDataOwnedByAtlas = false; io.Fonts->AddFontFromMemoryTTF(....., &cfg);` to disable passing ownership/
3696
// WE WILL ADDRESS THIS IN A FUTURE REWORK OF THE API.
3697
if (src->FontDataOwnedByAtlas)
3698
IM_FREE(src->FontData);
3699
src->FontData = NULL;
3700
if (src->GlyphExcludeRanges)
3701
IM_FREE((void*)src->GlyphExcludeRanges);
3702
src->GlyphExcludeRanges = NULL;
3703
}
3704
3705
// Create a compact, baked "..." if it doesn't exist, by using the ".".
3706
// This may seem overly complicated right now but the point is to exercise and improve a technique which should be increasingly used.
3707
// FIXME-NEWATLAS: This borrows too much from FontLoader's FontLoadGlyph() handlers and suggest that we should add further helpers.
3708
static ImFontGlyph* ImFontAtlasBuildSetupFontBakedEllipsis(ImFontAtlas* atlas, ImFontBaked* baked)
3709
{
3710
ImFont* font = baked->OwnerFont;
3711
IM_ASSERT(font->EllipsisChar != 0);
3712
3713
const ImFontGlyph* dot_glyph = baked->FindGlyphNoFallback((ImWchar)'.');
3714
if (dot_glyph == NULL)
3715
dot_glyph = baked->FindGlyphNoFallback((ImWchar)0xFF0E);
3716
if (dot_glyph == NULL)
3717
return NULL;
3718
ImFontAtlasRectId dot_r_id = dot_glyph->PackId; // Deep copy to avoid invalidation of glyphs and rect pointers
3719
ImTextureRect* dot_r = ImFontAtlasPackGetRect(atlas, dot_r_id);
3720
const int dot_spacing = 1;
3721
const float dot_step = (dot_glyph->X1 - dot_glyph->X0) + dot_spacing;
3722
3723
ImFontAtlasRectId pack_id = ImFontAtlasPackAddRect(atlas, (dot_r->w * 3 + dot_spacing * 2), dot_r->h);
3724
ImTextureRect* r = ImFontAtlasPackGetRect(atlas, pack_id);
3725
3726
ImFontGlyph glyph_in = {};
3727
ImFontGlyph* glyph = &glyph_in;
3728
glyph->Codepoint = font->EllipsisChar;
3729
glyph->AdvanceX = ImMax(dot_glyph->AdvanceX, dot_glyph->X0 + dot_step * 3.0f - dot_spacing); // FIXME: Slightly odd for normally mono-space fonts but since this is used for trailing contents.
3730
glyph->X0 = dot_glyph->X0;
3731
glyph->Y0 = dot_glyph->Y0;
3732
glyph->X1 = dot_glyph->X0 + dot_step * 3 - dot_spacing;
3733
glyph->Y1 = dot_glyph->Y1;
3734
glyph->Visible = true;
3735
glyph->PackId = pack_id;
3736
glyph = ImFontAtlasBakedAddFontGlyph(atlas, baked, NULL, glyph);
3737
dot_glyph = NULL; // Invalidated
3738
3739
// Copy to texture, post-process and queue update for backend
3740
// FIXME-NEWATLAS-V2: Dot glyph is already post-processed as this point, so this would damage it.
3741
dot_r = ImFontAtlasPackGetRect(atlas, dot_r_id);
3742
ImTextureData* tex = atlas->TexData;
3743
for (int n = 0; n < 3; n++)
3744
ImFontAtlasTextureBlockCopy(tex, dot_r->x, dot_r->y, tex, r->x + (dot_r->w + dot_spacing) * n, r->y, dot_r->w, dot_r->h);
3745
ImFontAtlasTextureBlockQueueUpload(atlas, tex, r->x, r->y, r->w, r->h);
3746
3747
return glyph;
3748
}
3749
3750
// Load fallback in order to obtain its index
3751
// (this is called from in hot-path so we avoid extraneous parameters to minimize impact on code size)
3752
static void ImFontAtlasBuildSetupFontBakedFallback(ImFontBaked* baked)
3753
{
3754
IM_ASSERT(baked->FallbackGlyphIndex == -1);
3755
IM_ASSERT(baked->FallbackAdvanceX == 0.0f);
3756
ImFont* font = baked->OwnerFont;
3757
ImFontGlyph* fallback_glyph = NULL;
3758
if (font->FallbackChar != 0)
3759
fallback_glyph = baked->FindGlyphNoFallback(font->FallbackChar);
3760
if (fallback_glyph == NULL)
3761
{
3762
ImFontGlyph* space_glyph = baked->FindGlyphNoFallback((ImWchar)' ');
3763
ImFontGlyph glyph;
3764
glyph.Codepoint = 0;
3765
glyph.AdvanceX = space_glyph ? space_glyph->AdvanceX : IM_ROUND(baked->Size * 0.40f);
3766
fallback_glyph = ImFontAtlasBakedAddFontGlyph(font->OwnerAtlas, baked, NULL, &glyph);
3767
}
3768
baked->FallbackGlyphIndex = baked->Glyphs.index_from_ptr(fallback_glyph); // Storing index avoid need to update pointer on growth and simplify inner loop code
3769
baked->FallbackAdvanceX = fallback_glyph->AdvanceX;
3770
}
3771
3772
static void ImFontAtlasBuildSetupFontBakedBlanks(ImFontAtlas* atlas, ImFontBaked* baked)
3773
{
3774
// Mark space as always hidden (not strictly correct/necessary. but some e.g. icons fonts don't have a space. it tends to look neater in previews)
3775
ImFontGlyph* space_glyph = baked->FindGlyphNoFallback((ImWchar)' ');
3776
if (space_glyph != NULL)
3777
space_glyph->Visible = false;
3778
3779
// Setup Tab character.
3780
// FIXME: Needs proper TAB handling but it needs to be contextualized (or we could arbitrary say that each string starts at "column 0" ?)
3781
if (baked->FindGlyphNoFallback('\t') == NULL && space_glyph != NULL)
3782
{
3783
ImFontGlyph tab_glyph;
3784
tab_glyph.Codepoint = '\t';
3785
tab_glyph.AdvanceX = space_glyph->AdvanceX * IM_TABSIZE;
3786
ImFontAtlasBakedAddFontGlyph(atlas, baked, NULL, &tab_glyph);
3787
}
3788
}
3789
3790
// Load/identify special glyphs
3791
// (note that this is called again for fonts with MergeMode)
3792
void ImFontAtlasBuildSetupFontSpecialGlyphs(ImFontAtlas* atlas, ImFont* font, ImFontConfig* src)
3793
{
3794
IM_UNUSED(atlas);
3795
IM_ASSERT(font->Sources.contains(src));
3796
3797
// Find Fallback character. Actual glyph loaded in GetFontBaked().
3798
const ImWchar fallback_chars[] = { font->FallbackChar, (ImWchar)IM_UNICODE_CODEPOINT_INVALID, (ImWchar)'?', (ImWchar)' ' };
3799
if (font->FallbackChar == 0)
3800
for (ImWchar candidate_char : fallback_chars)
3801
if (candidate_char != 0 && font->IsGlyphInFont(candidate_char))
3802
{
3803
font->FallbackChar = (ImWchar)candidate_char;
3804
break;
3805
}
3806
3807
// Setup Ellipsis character. It is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
3808
// However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
3809
// FIXME: Note that 0x2026 is rarely included in our font ranges. Because of this we are more likely to use three individual dots.
3810
const ImWchar ellipsis_chars[] = { src->EllipsisChar, (ImWchar)0x2026, (ImWchar)0x0085 };
3811
if (font->EllipsisChar == 0)
3812
for (ImWchar candidate_char : ellipsis_chars)
3813
if (candidate_char != 0 && font->IsGlyphInFont(candidate_char))
3814
{
3815
font->EllipsisChar = candidate_char;
3816
break;
3817
}
3818
if (font->EllipsisChar == 0)
3819
{
3820
font->EllipsisChar = 0x0085;
3821
font->EllipsisAutoBake = true;
3822
}
3823
}
3824
3825
void ImFontAtlasBakedDiscardFontGlyph(ImFontAtlas* atlas, ImFont* font, ImFontBaked* baked, ImFontGlyph* glyph)
3826
{
3827
if (glyph->PackId != ImFontAtlasRectId_Invalid)
3828
{
3829
ImFontAtlasPackDiscardRect(atlas, glyph->PackId);
3830
glyph->PackId = ImFontAtlasRectId_Invalid;
3831
}
3832
ImWchar c = (ImWchar)glyph->Codepoint;
3833
IM_ASSERT(font->FallbackChar != c && font->EllipsisChar != c); // Unsupported for simplicity
3834
IM_ASSERT(glyph >= baked->Glyphs.Data && glyph < baked->Glyphs.Data + baked->Glyphs.Size);
3835
IM_UNUSED(font);
3836
baked->IndexLookup[c] = IM_FONTGLYPH_INDEX_UNUSED;
3837
baked->IndexAdvanceX[c] = baked->FallbackAdvanceX;
3838
}
3839
3840
ImFontBaked* ImFontAtlasBakedAdd(ImFontAtlas* atlas, ImFont* font, float font_size, float font_weight, float font_rasterizer_density, ImGuiID baked_id)
3841
{
3842
IMGUI_DEBUG_LOG_FONT("[font] Created baked %.2fpx %.2f\n", font_size, font_weight);
3843
ImFontBaked* baked = atlas->Builder->BakedPool.push_back(ImFontBaked());
3844
baked->Size = font_size;
3845
baked->RasterizerDensity = font_rasterizer_density;
3846
baked->Weight = font_weight;
3847
baked->BakedId = baked_id;
3848
baked->OwnerFont = font;
3849
baked->LastUsedFrame = atlas->Builder->FrameCount;
3850
3851
// Initialize backend data
3852
size_t loader_data_size = 0;
3853
for (ImFontConfig* src : font->Sources) // Cannot easily be cached as we allow changing backend
3854
{
3855
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
3856
loader_data_size += loader->FontBakedSrcLoaderDataSize;
3857
}
3858
baked->FontLoaderDatas = (loader_data_size > 0) ? IM_ALLOC(loader_data_size) : NULL;
3859
char* loader_data_p = (char*)baked->FontLoaderDatas;
3860
for (ImFontConfig* src : font->Sources)
3861
{
3862
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
3863
if (loader->FontBakedInit)
3864
loader->FontBakedInit(atlas, src, baked, loader_data_p);
3865
loader_data_p += loader->FontBakedSrcLoaderDataSize;
3866
}
3867
3868
ImFontAtlasBuildSetupFontBakedBlanks(atlas, baked);
3869
return baked;
3870
}
3871
3872
// FIXME-OPT: This is not a fast query. Adding a BakedCount field in Font might allow to take a shortcut for the most common case.
3873
ImFontBaked* ImFontAtlasBakedGetClosestMatch(ImFontAtlas* atlas, ImFont* font, float font_size, float font_weight, float font_rasterizer_density)
3874
{
3875
ImFontAtlasBuilder* builder = atlas->Builder;
3876
for (int step_n = 0; step_n < 2; step_n++)
3877
{
3878
ImFontBaked* closest_larger_match = NULL;
3879
ImFontBaked* closest_smaller_match = NULL;
3880
for (int baked_n = 0; baked_n < builder->BakedPool.Size; baked_n++)
3881
{
3882
ImFontBaked* baked = &builder->BakedPool[baked_n];
3883
if (baked->OwnerFont != font || baked->WantDestroy)
3884
continue;
3885
if (baked->Weight != font_weight)
3886
continue;
3887
if (step_n == 0 && baked->RasterizerDensity != font_rasterizer_density) // First try with same density
3888
continue;
3889
if (baked->Size > font_size && (closest_larger_match == NULL || baked->Size < closest_larger_match->Size))
3890
closest_larger_match = baked;
3891
if (baked->Size < font_size && (closest_smaller_match == NULL || baked->Size > closest_smaller_match->Size))
3892
closest_smaller_match = baked;
3893
}
3894
if (closest_larger_match)
3895
if (closest_smaller_match == NULL || (closest_larger_match->Size >= font_size * 2.0f && closest_smaller_match->Size > font_size * 0.5f))
3896
return closest_larger_match;
3897
if (closest_smaller_match)
3898
return closest_smaller_match;
3899
}
3900
return NULL;
3901
}
3902
3903
void ImFontAtlasBakedDiscard(ImFontAtlas* atlas, ImFont* font, ImFontBaked* baked)
3904
{
3905
ImFontAtlasBuilder* builder = atlas->Builder;
3906
IMGUI_DEBUG_LOG_FONT("[font] Discard baked %.2f/%.2f for \"%s\"\n", baked->Size, baked->Weight, font->GetDebugName());
3907
3908
for (ImFontGlyph& glyph : baked->Glyphs)
3909
if (glyph.PackId != ImFontAtlasRectId_Invalid)
3910
ImFontAtlasPackDiscardRect(atlas, glyph.PackId);
3911
3912
char* loader_data_p = (char*)baked->FontLoaderDatas;
3913
for (ImFontConfig* src : font->Sources)
3914
{
3915
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
3916
if (loader->FontBakedDestroy)
3917
loader->FontBakedDestroy(atlas, src, baked, loader_data_p);
3918
loader_data_p += loader->FontBakedSrcLoaderDataSize;
3919
}
3920
if (baked->FontLoaderDatas)
3921
{
3922
IM_FREE(baked->FontLoaderDatas);
3923
baked->FontLoaderDatas = NULL;
3924
}
3925
builder->BakedMap.SetVoidPtr(baked->BakedId, NULL);
3926
builder->BakedDiscardedCount++;
3927
baked->ClearOutputData();
3928
baked->WantDestroy = true;
3929
font->LastBaked = NULL;
3930
}
3931
3932
// use unused_frames==0 to discard everything.
3933
void ImFontAtlasFontDiscardBakes(ImFontAtlas* atlas, ImFont* font, int unused_frames)
3934
{
3935
if (ImFontAtlasBuilder* builder = atlas->Builder) // This can be called from font destructor
3936
for (int baked_n = 0; baked_n < builder->BakedPool.Size; baked_n++)
3937
{
3938
ImFontBaked* baked = &builder->BakedPool[baked_n];
3939
if (baked->LastUsedFrame + unused_frames > atlas->Builder->FrameCount)
3940
continue;
3941
if (baked->OwnerFont != font || baked->WantDestroy)
3942
continue;
3943
ImFontAtlasBakedDiscard(atlas, font, baked);
3944
}
3945
}
3946
3947
// use unused_frames==0 to discard everything.
3948
void ImFontAtlasBuildDiscardBakes(ImFontAtlas* atlas, int unused_frames)
3949
{
3950
ImFontAtlasBuilder* builder = atlas->Builder;
3951
for (int baked_n = 0; baked_n < builder->BakedPool.Size; baked_n++)
3952
{
3953
ImFontBaked* baked = &builder->BakedPool[baked_n];
3954
if (baked->LastUsedFrame + unused_frames > atlas->Builder->FrameCount)
3955
continue;
3956
if (baked->WantDestroy || (baked->OwnerFont->Flags & ImFontFlags_LockBakedSizes))
3957
continue;
3958
ImFontAtlasBakedDiscard(atlas, baked->OwnerFont, baked);
3959
}
3960
}
3961
3962
// Those functions are designed to facilitate changing the underlying structures for ImFontAtlas to store an array of ImDrawListSharedData*
3963
void ImFontAtlasAddDrawListSharedData(ImFontAtlas* atlas, ImDrawListSharedData* data)
3964
{
3965
IM_ASSERT(!atlas->DrawListSharedDatas.contains(data));
3966
atlas->DrawListSharedDatas.push_back(data);
3967
}
3968
3969
void ImFontAtlasRemoveDrawListSharedData(ImFontAtlas* atlas, ImDrawListSharedData* data)
3970
{
3971
IM_ASSERT(atlas->DrawListSharedDatas.contains(data));
3972
atlas->DrawListSharedDatas.find_erase(data);
3973
}
3974
3975
// Update texture identifier in all active draw lists
3976
void ImFontAtlasUpdateDrawListsTextures(ImFontAtlas* atlas, ImTextureRef old_tex, ImTextureRef new_tex)
3977
{
3978
for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas)
3979
{
3980
// If Context 2 uses font owned by Context 1 which already called EndFrame()/Render(), we don't want to mess with draw commands for Context 1
3981
if (shared_data->Context && !shared_data->Context->WithinFrameScope)
3982
continue;
3983
3984
for (ImDrawList* draw_list : shared_data->DrawLists)
3985
{
3986
// Replace in command-buffer
3987
// (there is not need to replace in ImDrawListSplitter: current channel is in ImDrawList's CmdBuffer[],
3988
// other channels will be on SetCurrentChannel() which already needs to compare CmdHeader anyhow)
3989
if (draw_list->CmdBuffer.Size > 0 && draw_list->_CmdHeader.TexRef == old_tex)
3990
draw_list->_SetTexture(new_tex);
3991
3992
// Replace in stack
3993
for (ImTextureRef& stacked_tex : draw_list->_TextureStack)
3994
if (stacked_tex == old_tex)
3995
stacked_tex = new_tex;
3996
}
3997
}
3998
}
3999
4000
// Update texture coordinates in all draw list shared context
4001
// FIXME-NEWATLAS FIXME-OPT: Doesn't seem necessary to update for all, only one bound to current context?
4002
void ImFontAtlasUpdateDrawListsSharedData(ImFontAtlas* atlas)
4003
{
4004
for (ImDrawListSharedData* shared_data : atlas->DrawListSharedDatas)
4005
if (shared_data->FontAtlas == atlas)
4006
{
4007
shared_data->TexUvWhitePixel = atlas->TexUvWhitePixel;
4008
shared_data->TexUvLines = atlas->TexUvLines;
4009
}
4010
}
4011
4012
// Set current texture. This is mostly called from AddTexture() + to handle a failed resize.
4013
static void ImFontAtlasBuildSetTexture(ImFontAtlas* atlas, ImTextureData* tex)
4014
{
4015
ImTextureRef old_tex_ref = atlas->TexRef;
4016
atlas->TexData = tex;
4017
atlas->TexUvScale = ImVec2(1.0f / tex->Width, 1.0f / tex->Height);
4018
atlas->TexRef._TexData = tex;
4019
//atlas->TexRef._TexID = tex->TexID; // <-- We intentionally don't do that. It would be misleading and betray promise that both fields aren't set.
4020
ImFontAtlasUpdateDrawListsTextures(atlas, old_tex_ref, atlas->TexRef);
4021
}
4022
4023
// Create a new texture, discard previous one
4024
ImTextureData* ImFontAtlasTextureAdd(ImFontAtlas* atlas, int w, int h)
4025
{
4026
ImTextureData* old_tex = atlas->TexData;
4027
ImTextureData* new_tex;
4028
4029
// FIXME: Cannot reuse texture because old UV may have been used already (unless we remap UV).
4030
/*if (old_tex != NULL && old_tex->Status == ImTextureStatus_WantCreate)
4031
{
4032
// Reuse texture not yet used by backend.
4033
IM_ASSERT(old_tex->TexID == ImTextureID_Invalid && old_tex->BackendUserData == NULL);
4034
old_tex->DestroyPixels();
4035
old_tex->Updates.clear();
4036
new_tex = old_tex;
4037
old_tex = NULL;
4038
}
4039
else*/
4040
{
4041
// Add new
4042
new_tex = IM_NEW(ImTextureData)();
4043
new_tex->UniqueID = atlas->TexNextUniqueID++;
4044
atlas->TexList.push_back(new_tex);
4045
}
4046
if (old_tex != NULL)
4047
{
4048
// Queue old as to destroy next frame
4049
old_tex->WantDestroyNextFrame = true;
4050
IM_ASSERT(old_tex->Status == ImTextureStatus_OK || old_tex->Status == ImTextureStatus_WantCreate || old_tex->Status == ImTextureStatus_WantUpdates);
4051
}
4052
4053
new_tex->Create(atlas->TexDesiredFormat, w, h);
4054
atlas->TexIsBuilt = false;
4055
4056
ImFontAtlasBuildSetTexture(atlas, new_tex);
4057
4058
return new_tex;
4059
}
4060
4061
#if 0
4062
#define STB_IMAGE_WRITE_IMPLEMENTATION
4063
#include "../stb/stb_image_write.h"
4064
static void ImFontAtlasDebugWriteTexToDisk(ImTextureData* tex, const char* description)
4065
{
4066
ImGuiContext& g = *GImGui;
4067
char buf[128];
4068
ImFormatString(buf, IM_COUNTOF(buf), "[%05d] Texture #%03d - %s.png", g.FrameCount, tex->UniqueID, description);
4069
stbi_write_png(buf, tex->Width, tex->Height, tex->BytesPerPixel, tex->Pixels, tex->GetPitch()); // tex->BytesPerPixel is technically not component, but ok for the formats we support.
4070
}
4071
#endif
4072
4073
void ImFontAtlasTextureRepack(ImFontAtlas* atlas, int w, int h)
4074
{
4075
ImFontAtlasBuilder* builder = atlas->Builder;
4076
builder->LockDisableResize = true;
4077
4078
ImTextureData* old_tex = atlas->TexData;
4079
ImTextureData* new_tex = ImFontAtlasTextureAdd(atlas, w, h);
4080
new_tex->UseColors = old_tex->UseColors;
4081
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: resize+repack %dx%d => Texture #%03d: %dx%d\n", old_tex->UniqueID, old_tex->Width, old_tex->Height, new_tex->UniqueID, new_tex->Width, new_tex->Height);
4082
//for (int baked_n = 0; baked_n < builder->BakedPool.Size; baked_n++)
4083
// IMGUI_DEBUG_LOG_FONT("[font] - Baked %.2fpx, %d glyphs, want_destroy=%d\n", builder->BakedPool[baked_n].FontSize, builder->BakedPool[baked_n].Glyphs.Size, builder->BakedPool[baked_n].WantDestroy);
4084
//IMGUI_DEBUG_LOG_FONT("[font] - Old packed rects: %d, area %d px\n", builder->RectsPackedCount, builder->RectsPackedSurface);
4085
//ImFontAtlasDebugWriteTexToDisk(old_tex, "Before Pack");
4086
4087
// Repack, lose discarded rectangle, copy pixels
4088
// FIXME-NEWATLAS: This is unstable because packing order is based on RectsIndex
4089
// FIXME-NEWATLAS-V2: Repacking in batch would be beneficial to packing heuristic, and fix stability.
4090
// FIXME-NEWATLAS-TESTS: Test calling RepackTexture with size too small to fits existing rects.
4091
ImFontAtlasPackInit(atlas);
4092
ImVector<ImTextureRect> old_rects;
4093
ImVector<ImFontAtlasRectEntry> old_index = builder->RectsIndex;
4094
old_rects.swap(builder->Rects);
4095
4096
for (ImFontAtlasRectEntry& index_entry : builder->RectsIndex)
4097
{
4098
if (index_entry.IsUsed == false)
4099
continue;
4100
ImTextureRect& old_r = old_rects[index_entry.TargetIndex];
4101
if (old_r.w == 0 && old_r.h == 0)
4102
continue;
4103
ImFontAtlasRectId new_r_id = ImFontAtlasPackAddRect(atlas, old_r.w, old_r.h, &index_entry);
4104
if (new_r_id == ImFontAtlasRectId_Invalid)
4105
{
4106
// Undo, grow texture and try repacking again.
4107
// FIXME-NEWATLAS-TESTS: This is a very rarely exercised path! It needs to be automatically tested properly.
4108
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: resize failed. Will grow.\n", new_tex->UniqueID);
4109
new_tex->WantDestroyNextFrame = true;
4110
builder->Rects.swap(old_rects);
4111
builder->RectsIndex = old_index;
4112
ImFontAtlasBuildSetTexture(atlas, old_tex);
4113
ImFontAtlasTextureGrow(atlas, w, h); // Recurse
4114
return;
4115
}
4116
IM_ASSERT(ImFontAtlasRectId_GetIndex(new_r_id) == builder->RectsIndex.index_from_ptr(&index_entry));
4117
ImTextureRect* new_r = ImFontAtlasPackGetRect(atlas, new_r_id);
4118
ImFontAtlasTextureBlockCopy(old_tex, old_r.x, old_r.y, new_tex, new_r->x, new_r->y, new_r->w, new_r->h);
4119
}
4120
IM_ASSERT(old_rects.Size == builder->Rects.Size + builder->RectsDiscardedCount);
4121
builder->RectsDiscardedCount = 0;
4122
builder->RectsDiscardedSurface = 0;
4123
4124
// Patch glyphs UV
4125
for (int baked_n = 0; baked_n < builder->BakedPool.Size; baked_n++)
4126
for (ImFontGlyph& glyph : builder->BakedPool[baked_n].Glyphs)
4127
if (glyph.PackId != ImFontAtlasRectId_Invalid)
4128
{
4129
ImTextureRect* r = ImFontAtlasPackGetRect(atlas, glyph.PackId);
4130
glyph.U0 = (r->x) * atlas->TexUvScale.x;
4131
glyph.V0 = (r->y) * atlas->TexUvScale.y;
4132
glyph.U1 = (r->x + r->w) * atlas->TexUvScale.x;
4133
glyph.V1 = (r->y + r->h) * atlas->TexUvScale.y;
4134
}
4135
4136
// Update other cached UV
4137
ImFontAtlasBuildUpdateLinesTexData(atlas);
4138
ImFontAtlasBuildUpdateBasicTexData(atlas);
4139
4140
builder->LockDisableResize = false;
4141
ImFontAtlasUpdateDrawListsSharedData(atlas);
4142
//ImFontAtlasDebugWriteTexToDisk(new_tex, "After Pack");
4143
}
4144
4145
void ImFontAtlasTextureGrow(ImFontAtlas* atlas, int old_tex_w, int old_tex_h)
4146
{
4147
//ImFontAtlasDebugWriteTexToDisk(atlas->TexData, "Before Grow");
4148
ImFontAtlasBuilder* builder = atlas->Builder;
4149
if (old_tex_w == -1)
4150
old_tex_w = atlas->TexData->Width;
4151
if (old_tex_h == -1)
4152
old_tex_h = atlas->TexData->Height;
4153
4154
// FIXME-NEWATLAS-V2: What to do when reaching limits exposed by backend?
4155
// FIXME-NEWATLAS-V2: Does ImFontAtlasFlags_NoPowerOfTwoHeight makes sense now? Allow 'lock' and 'compact' operations?
4156
IM_ASSERT(ImIsPowerOfTwo(old_tex_w) && ImIsPowerOfTwo(old_tex_h));
4157
IM_ASSERT(ImIsPowerOfTwo(atlas->TexMinWidth) && ImIsPowerOfTwo(atlas->TexMaxWidth) && ImIsPowerOfTwo(atlas->TexMinHeight) && ImIsPowerOfTwo(atlas->TexMaxHeight));
4158
4159
// Grow texture so it follows roughly a square.
4160
// - Grow height before width, as width imply more packing nodes.
4161
// - Caller should be taking account of RectsDiscardedSurface and may not need to grow.
4162
int new_tex_w = (old_tex_h <= old_tex_w) ? old_tex_w : old_tex_w * 2;
4163
int new_tex_h = (old_tex_h <= old_tex_w) ? old_tex_h * 2 : old_tex_h;
4164
4165
// Handle minimum size first (for pathologically large packed rects)
4166
const int pack_padding = atlas->TexGlyphPadding;
4167
new_tex_w = ImMax(new_tex_w, ImUpperPowerOfTwo(builder->MaxRectSize.x + pack_padding));
4168
new_tex_h = ImMax(new_tex_h, ImUpperPowerOfTwo(builder->MaxRectSize.y + pack_padding));
4169
new_tex_w = ImClamp(new_tex_w, atlas->TexMinWidth, atlas->TexMaxWidth);
4170
new_tex_h = ImClamp(new_tex_h, atlas->TexMinHeight, atlas->TexMaxHeight);
4171
if (new_tex_w == old_tex_w && new_tex_h == old_tex_h)
4172
return;
4173
4174
ImFontAtlasTextureRepack(atlas, new_tex_w, new_tex_h);
4175
}
4176
4177
void ImFontAtlasTextureMakeSpace(ImFontAtlas* atlas)
4178
{
4179
// Can some baked contents be ditched?
4180
//IMGUI_DEBUG_LOG_FONT("[font] ImFontAtlasBuildMakeSpace()\n");
4181
ImFontAtlasBuilder* builder = atlas->Builder;
4182
ImFontAtlasBuildDiscardBakes(atlas, 2);
4183
4184
// Currently using a heuristic for repack without growing.
4185
if (builder->RectsDiscardedSurface < builder->RectsPackedSurface * 0.20f)
4186
ImFontAtlasTextureGrow(atlas);
4187
else
4188
ImFontAtlasTextureRepack(atlas, atlas->TexData->Width, atlas->TexData->Height);
4189
}
4190
4191
ImVec2i ImFontAtlasTextureGetSizeEstimate(ImFontAtlas* atlas)
4192
{
4193
int min_w = ImUpperPowerOfTwo(atlas->TexMinWidth);
4194
int min_h = ImUpperPowerOfTwo(atlas->TexMinHeight);
4195
if (atlas->Builder == NULL || atlas->TexData == NULL || atlas->TexData->Status == ImTextureStatus_WantDestroy)
4196
return ImVec2i(min_w, min_h);
4197
4198
ImFontAtlasBuilder* builder = atlas->Builder;
4199
min_w = ImMax(ImUpperPowerOfTwo(builder->MaxRectSize.x), min_w);
4200
min_h = ImMax(ImUpperPowerOfTwo(builder->MaxRectSize.y), min_h);
4201
const int surface_approx = builder->RectsPackedSurface - builder->RectsDiscardedSurface; // Expected surface after repack
4202
const int surface_sqrt = (int)sqrtf((float)surface_approx);
4203
4204
int new_tex_w;
4205
int new_tex_h;
4206
if (min_w >= min_h)
4207
{
4208
new_tex_w = ImMax(min_w, ImUpperPowerOfTwo(surface_sqrt));
4209
new_tex_h = ImMax(min_h, (int)((surface_approx + new_tex_w - 1) / new_tex_w));
4210
if ((atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) == 0)
4211
new_tex_h = ImUpperPowerOfTwo(new_tex_h);
4212
}
4213
else
4214
{
4215
new_tex_h = ImMax(min_h, ImUpperPowerOfTwo(surface_sqrt));
4216
if ((atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) == 0)
4217
new_tex_h = ImUpperPowerOfTwo(new_tex_h);
4218
new_tex_w = ImMax(min_w, (int)((surface_approx + new_tex_h - 1) / new_tex_h));
4219
}
4220
4221
IM_ASSERT(ImIsPowerOfTwo(new_tex_w) && ImIsPowerOfTwo(new_tex_h));
4222
return ImVec2i(new_tex_w, new_tex_h);
4223
}
4224
4225
// Clear all output. Invalidates all AddCustomRect() return values!
4226
void ImFontAtlasBuildClear(ImFontAtlas* atlas)
4227
{
4228
ImVec2i new_tex_size = ImFontAtlasTextureGetSizeEstimate(atlas);
4229
ImFontAtlasBuildDestroy(atlas);
4230
ImFontAtlasTextureAdd(atlas, new_tex_size.x, new_tex_size.y);
4231
ImFontAtlasBuildInit(atlas);
4232
for (ImFontConfig& src : atlas->Sources)
4233
ImFontAtlasFontSourceInit(atlas, &src);
4234
for (ImFont* font : atlas->Fonts)
4235
for (ImFontConfig* src : font->Sources)
4236
ImFontAtlasFontSourceAddToFont(atlas, font, src);
4237
}
4238
4239
// You should not need to call this manually!
4240
// If you think you do, let us know and we can advise about policies auto-compact.
4241
void ImFontAtlasTextureCompact(ImFontAtlas* atlas)
4242
{
4243
ImFontAtlasBuilder* builder = atlas->Builder;
4244
ImFontAtlasBuildDiscardBakes(atlas, 1);
4245
4246
ImTextureData* old_tex = atlas->TexData;
4247
ImVec2i old_tex_size = ImVec2i(old_tex->Width, old_tex->Height);
4248
ImVec2i new_tex_size = ImFontAtlasTextureGetSizeEstimate(atlas);
4249
if (builder->RectsDiscardedCount == 0 && new_tex_size.x == old_tex_size.x && new_tex_size.y == old_tex_size.y)
4250
return;
4251
4252
ImFontAtlasTextureRepack(atlas, new_tex_size.x, new_tex_size.y);
4253
}
4254
4255
// Start packing over current empty texture
4256
void ImFontAtlasBuildInit(ImFontAtlas* atlas)
4257
{
4258
// Select Backend
4259
// - Note that we do not reassign to atlas->FontLoader, since it is likely to point to static data which
4260
// may mess with some hot-reloading schemes. If you need to assign to this (for dynamic selection) AND are
4261
// using a hot-reloading scheme that messes up static data, store your own instance of FontLoader somewhere
4262
// and point to it instead of pointing directly to return value of the GetFontLoaderXXX functions.
4263
if (atlas->FontLoader == NULL)
4264
{
4265
#ifdef IMGUI_ENABLE_FREETYPE
4266
atlas->SetFontLoader(ImGuiFreeType::GetFontLoader());
4267
#elif defined(IMGUI_ENABLE_STB_TRUETYPE)
4268
atlas->SetFontLoader(ImFontAtlasGetFontLoaderForStbTruetype());
4269
#else
4270
IM_ASSERT(0); // Invalid Build function
4271
#endif
4272
}
4273
4274
// Create initial texture size
4275
if (atlas->TexData == NULL || atlas->TexData->Pixels == NULL)
4276
ImFontAtlasTextureAdd(atlas, ImUpperPowerOfTwo(atlas->TexMinWidth), ImUpperPowerOfTwo(atlas->TexMinHeight));
4277
4278
atlas->Builder = IM_NEW(ImFontAtlasBuilder)();
4279
if (atlas->FontLoader->LoaderInit)
4280
atlas->FontLoader->LoaderInit(atlas);
4281
4282
ImFontAtlasBuildUpdateRendererHasTexturesFromContext(atlas);
4283
4284
ImFontAtlasPackInit(atlas);
4285
4286
// Add required texture data
4287
ImFontAtlasBuildUpdateLinesTexData(atlas);
4288
ImFontAtlasBuildUpdateBasicTexData(atlas);
4289
4290
// Register fonts
4291
ImFontAtlasBuildUpdatePointers(atlas);
4292
4293
// Update UV coordinates etc. stored in bound ImDrawListSharedData instance
4294
ImFontAtlasUpdateDrawListsSharedData(atlas);
4295
4296
//atlas->TexIsBuilt = true;
4297
4298
// Lazily initialize char/text classifier
4299
// FIXME: This could be practically anywhere, and should eventually be parameters to CalcTextSize/word-wrapping code, but there's no obvious spot now.
4300
ImTextInitClassifiers();
4301
}
4302
4303
// Destroy builder and all cached glyphs. Do not destroy actual fonts.
4304
void ImFontAtlasBuildDestroy(ImFontAtlas* atlas)
4305
{
4306
for (ImFont* font : atlas->Fonts)
4307
ImFontAtlasFontDestroyOutput(atlas, font);
4308
if (atlas->Builder && atlas->FontLoader && atlas->FontLoader->LoaderShutdown)
4309
{
4310
atlas->FontLoader->LoaderShutdown(atlas);
4311
IM_ASSERT(atlas->FontLoaderData == NULL);
4312
}
4313
IM_DELETE(atlas->Builder);
4314
atlas->Builder = NULL;
4315
}
4316
4317
void ImFontAtlasPackInit(ImFontAtlas * atlas)
4318
{
4319
ImTextureData* tex = atlas->TexData;
4320
ImFontAtlasBuilder* builder = atlas->Builder;
4321
4322
// In theory we could decide to reduce the number of nodes, e.g. halve them, and waste a little texture space, but it doesn't seem worth it.
4323
const int pack_node_count = tex->Width / 2;
4324
builder->PackNodes.resize(pack_node_count);
4325
IM_STATIC_ASSERT(sizeof(stbrp_context) <= sizeof(stbrp_context_opaque));
4326
stbrp_init_target((stbrp_context*)(void*)&builder->PackContext, tex->Width, tex->Height, builder->PackNodes.Data, builder->PackNodes.Size);
4327
builder->RectsPackedSurface = builder->RectsPackedCount = 0;
4328
builder->MaxRectSize = ImVec2i(0, 0);
4329
builder->MaxRectBounds = ImVec2i(0, 0);
4330
}
4331
4332
// This is essentially a free-list pattern, it may be nice to wrap it into a dedicated type.
4333
static ImFontAtlasRectId ImFontAtlasPackAllocRectEntry(ImFontAtlas* atlas, int rect_idx)
4334
{
4335
ImFontAtlasBuilder* builder = (ImFontAtlasBuilder*)atlas->Builder;
4336
int index_idx;
4337
ImFontAtlasRectEntry* index_entry;
4338
if (builder->RectsIndexFreeListStart < 0)
4339
{
4340
builder->RectsIndex.resize(builder->RectsIndex.Size + 1);
4341
index_idx = builder->RectsIndex.Size - 1;
4342
index_entry = &builder->RectsIndex[index_idx];
4343
memset(index_entry, 0, sizeof(*index_entry));
4344
}
4345
else
4346
{
4347
index_idx = builder->RectsIndexFreeListStart;
4348
index_entry = &builder->RectsIndex[index_idx];
4349
IM_ASSERT(index_entry->IsUsed == false && index_entry->Generation > 0); // Generation is incremented during DiscardRect
4350
builder->RectsIndexFreeListStart = index_entry->TargetIndex;
4351
}
4352
index_entry->TargetIndex = rect_idx;
4353
index_entry->IsUsed = 1;
4354
return ImFontAtlasRectId_Make(index_idx, index_entry->Generation);
4355
}
4356
4357
// Overwrite existing entry
4358
static ImFontAtlasRectId ImFontAtlasPackReuseRectEntry(ImFontAtlas* atlas, ImFontAtlasRectEntry* index_entry)
4359
{
4360
IM_ASSERT(index_entry->IsUsed);
4361
index_entry->TargetIndex = atlas->Builder->Rects.Size - 1;
4362
int index_idx = atlas->Builder->RectsIndex.index_from_ptr(index_entry);
4363
return ImFontAtlasRectId_Make(index_idx, index_entry->Generation);
4364
}
4365
4366
// This is expected to be called in batches and followed by a repack
4367
void ImFontAtlasPackDiscardRect(ImFontAtlas* atlas, ImFontAtlasRectId id)
4368
{
4369
IM_ASSERT(id != ImFontAtlasRectId_Invalid);
4370
4371
ImTextureRect* rect = ImFontAtlasPackGetRect(atlas, id);
4372
if (rect == NULL)
4373
return;
4374
4375
ImFontAtlasBuilder* builder = atlas->Builder;
4376
int index_idx = ImFontAtlasRectId_GetIndex(id);
4377
ImFontAtlasRectEntry* index_entry = &builder->RectsIndex[index_idx];
4378
IM_ASSERT(index_entry->IsUsed && index_entry->TargetIndex >= 0);
4379
index_entry->IsUsed = false;
4380
index_entry->TargetIndex = builder->RectsIndexFreeListStart;
4381
index_entry->Generation++;
4382
if (index_entry->Generation == 0)
4383
index_entry->Generation++; // Keep non-zero on overflow
4384
4385
const int pack_padding = atlas->TexGlyphPadding;
4386
builder->RectsIndexFreeListStart = index_idx;
4387
builder->RectsDiscardedCount++;
4388
builder->RectsDiscardedSurface += (rect->w + pack_padding) * (rect->h + pack_padding);
4389
rect->w = rect->h = 0; // Clear rectangle so it won't be packed again
4390
}
4391
4392
// Important: Calling this may recreate a new texture and therefore change atlas->TexData
4393
// FIXME-NEWFONTS: Expose other glyph padding settings for custom alteration (e.g. drop shadows). See #7962
4394
ImFontAtlasRectId ImFontAtlasPackAddRect(ImFontAtlas* atlas, int w, int h, ImFontAtlasRectEntry* overwrite_entry)
4395
{
4396
IM_ASSERT(w > 0 && w <= 0xFFFF);
4397
IM_ASSERT(h > 0 && h <= 0xFFFF);
4398
4399
ImFontAtlasBuilder* builder = (ImFontAtlasBuilder*)atlas->Builder;
4400
const int pack_padding = atlas->TexGlyphPadding;
4401
builder->MaxRectSize.x = ImMax(builder->MaxRectSize.x, w);
4402
builder->MaxRectSize.y = ImMax(builder->MaxRectSize.y, h);
4403
4404
// Pack
4405
ImTextureRect r = { 0, 0, (unsigned short)w, (unsigned short)h };
4406
for (int attempts_remaining = 3; attempts_remaining >= 0; attempts_remaining--)
4407
{
4408
// Try packing
4409
stbrp_rect pack_r = {};
4410
pack_r.w = w + pack_padding;
4411
pack_r.h = h + pack_padding;
4412
stbrp_pack_rects((stbrp_context*)(void*)&builder->PackContext, &pack_r, 1);
4413
r.x = (unsigned short)pack_r.x;
4414
r.y = (unsigned short)pack_r.y;
4415
if (pack_r.was_packed)
4416
break;
4417
4418
// If we ran out of attempts, return fallback
4419
if (attempts_remaining == 0 || builder->LockDisableResize)
4420
{
4421
IMGUI_DEBUG_LOG_FONT("[font] Failed packing %dx%d rectangle. Returning fallback.\n", w, h);
4422
return ImFontAtlasRectId_Invalid;
4423
}
4424
4425
// Resize or repack atlas! (this should be a rare event)
4426
ImFontAtlasTextureMakeSpace(atlas);
4427
}
4428
4429
builder->MaxRectBounds.x = ImMax(builder->MaxRectBounds.x, r.x + r.w + pack_padding);
4430
builder->MaxRectBounds.y = ImMax(builder->MaxRectBounds.y, r.y + r.h + pack_padding);
4431
builder->RectsPackedCount++;
4432
builder->RectsPackedSurface += (w + pack_padding) * (h + pack_padding);
4433
4434
builder->Rects.push_back(r);
4435
if (overwrite_entry != NULL)
4436
return ImFontAtlasPackReuseRectEntry(atlas, overwrite_entry); // Write into an existing entry instead of adding one (used during repack)
4437
else
4438
return ImFontAtlasPackAllocRectEntry(atlas, builder->Rects.Size - 1);
4439
}
4440
4441
// Generally for non-user facing functions: assert on invalid ID.
4442
ImTextureRect* ImFontAtlasPackGetRect(ImFontAtlas* atlas, ImFontAtlasRectId id)
4443
{
4444
IM_ASSERT(id != ImFontAtlasRectId_Invalid);
4445
int index_idx = ImFontAtlasRectId_GetIndex(id);
4446
ImFontAtlasBuilder* builder = (ImFontAtlasBuilder*)atlas->Builder;
4447
ImFontAtlasRectEntry* index_entry = &builder->RectsIndex[index_idx];
4448
IM_ASSERT(index_entry->Generation == ImFontAtlasRectId_GetGeneration(id));
4449
IM_ASSERT(index_entry->IsUsed);
4450
return &builder->Rects[index_entry->TargetIndex];
4451
}
4452
4453
// For user-facing functions: return NULL on invalid ID.
4454
// Important: return pointer is valid until next call to AddRect(), e.g. FindGlyph(), CalcTextSize() can all potentially invalidate previous pointers.
4455
ImTextureRect* ImFontAtlasPackGetRectSafe(ImFontAtlas* atlas, ImFontAtlasRectId id)
4456
{
4457
if (id == ImFontAtlasRectId_Invalid)
4458
return NULL;
4459
int index_idx = ImFontAtlasRectId_GetIndex(id);
4460
if (atlas->Builder == NULL)
4461
ImFontAtlasBuildInit(atlas);
4462
ImFontAtlasBuilder* builder = (ImFontAtlasBuilder*)atlas->Builder;
4463
IM_MSVC_WARNING_SUPPRESS(28182); // Static Analysis false positive "warning C28182: Dereferencing NULL pointer 'builder'"
4464
if (index_idx >= builder->RectsIndex.Size)
4465
return NULL;
4466
ImFontAtlasRectEntry* index_entry = &builder->RectsIndex[index_idx];
4467
if (index_entry->Generation != ImFontAtlasRectId_GetGeneration(id) || !index_entry->IsUsed)
4468
return NULL;
4469
return &builder->Rects[index_entry->TargetIndex];
4470
}
4471
4472
// Important! This assume by ImFontConfig::GlyphExcludeRanges[] is a SMALL ARRAY (e.g. <10 entries)
4473
// Use "Input Glyphs Overlap Detection Tool" to display a list of glyphs provided by multiple sources in order to set this array up.
4474
static bool ImFontAtlasBuildAcceptCodepointForSource(ImFontConfig* src, ImWchar codepoint)
4475
{
4476
if (const ImWchar* exclude_list = src->GlyphExcludeRanges)
4477
for (; exclude_list[0] != 0; exclude_list += 2)
4478
if (codepoint >= exclude_list[0] && codepoint <= exclude_list[1])
4479
return false;
4480
return true;
4481
}
4482
4483
static void ImFontBaked_BuildGrowIndex(ImFontBaked* baked, int new_size)
4484
{
4485
IM_ASSERT(baked->IndexAdvanceX.Size == baked->IndexLookup.Size);
4486
if (new_size <= baked->IndexLookup.Size)
4487
return;
4488
baked->IndexAdvanceX.resize(new_size, -1.0f);
4489
baked->IndexLookup.resize(new_size, IM_FONTGLYPH_INDEX_UNUSED);
4490
}
4491
4492
static ImWchar ImFontAtlas_FontHookRemapCodepoint(ImFontAtlas* atlas, ImFont* font, ImWchar c)
4493
{
4494
IM_UNUSED(atlas);
4495
if (font->RemapPairs.Data.Size != 0)
4496
{
4497
const ImWchar remap_c = (ImWchar)font->RemapPairs.GetInt((ImGuiID)c, 0);
4498
if (remap_c != 0)
4499
return remap_c;
4500
}
4501
4502
// Handle non-breaking spaces. The non-breaking space isn't handled by ImCharIsBlankW(),
4503
// so word wrapping should behave correctly if we remap it to a regular space here.
4504
// MacOS likes to use NNBSP in formatting, so need to handle that here. Strictly speaking,
4505
// it should be narrower, but it doesn't exist in our fonts so shrug.
4506
return (c == 0x00A0 || c == 0x202F) ? ImWchar(' ') : c; // NBSP/NNBSP
4507
}
4508
4509
static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codepoint, float* only_load_advance_x)
4510
{
4511
ImFont* font = baked->OwnerFont;
4512
ImFontAtlas* atlas = font->OwnerAtlas;
4513
if (atlas->Locked || (font->Flags & ImFontFlags_NoLoadGlyphs))
4514
{
4515
// Lazily load fallback glyph
4516
if (baked->FallbackGlyphIndex == -1 && baked->LoadNoFallback == 0)
4517
ImFontAtlasBuildSetupFontBakedFallback(baked);
4518
return NULL;
4519
}
4520
4521
// User remapping hooks
4522
ImWchar src_codepoint = codepoint;
4523
codepoint = ImFontAtlas_FontHookRemapCodepoint(atlas, font, codepoint);
4524
4525
//char utf8_buf[5];
4526
//IMGUI_DEBUG_LOG("[font] BuildLoadGlyph U+%04X (%s)\n", (unsigned int)codepoint, ImTextCharToUtf8(utf8_buf, (unsigned int)codepoint));
4527
4528
// Special hook
4529
// FIXME-NEWATLAS: it would be nicer if this used a more standardized way of hooking
4530
if (codepoint == font->EllipsisChar && font->EllipsisAutoBake)
4531
if (ImFontGlyph* glyph = ImFontAtlasBuildSetupFontBakedEllipsis(atlas, baked))
4532
return glyph;
4533
4534
// Call backend
4535
char* loader_user_data_p = (char*)baked->FontLoaderDatas;
4536
int src_n = 0;
4537
for (ImFontConfig* src : font->Sources)
4538
{
4539
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
4540
if (!src->GlyphExcludeRanges || ImFontAtlasBuildAcceptCodepointForSource(src, codepoint))
4541
{
4542
if (only_load_advance_x == NULL)
4543
{
4544
ImFontGlyph glyph_buf;
4545
if (loader->FontBakedLoadGlyph(atlas, src, baked, loader_user_data_p, codepoint, &glyph_buf, NULL))
4546
{
4547
// FIXME: Add hooks for e.g. #7962
4548
glyph_buf.Codepoint = src_codepoint;
4549
glyph_buf.SourceIdx = src_n;
4550
return ImFontAtlasBakedAddFontGlyph(atlas, baked, src, &glyph_buf);
4551
}
4552
}
4553
else
4554
{
4555
// Special mode but only loading glyphs metrics. Will rasterize and pack later.
4556
if (loader->FontBakedLoadGlyph(atlas, src, baked, loader_user_data_p, codepoint, NULL, only_load_advance_x))
4557
{
4558
ImFontAtlasBakedAddFontGlyphAdvancedX(atlas, baked, src, codepoint, *only_load_advance_x);
4559
return NULL;
4560
}
4561
}
4562
}
4563
loader_user_data_p += loader->FontBakedSrcLoaderDataSize;
4564
src_n++;
4565
}
4566
4567
// Lazily load fallback glyph
4568
if (baked->LoadNoFallback)
4569
return NULL;
4570
if (baked->FallbackGlyphIndex == -1)
4571
ImFontAtlasBuildSetupFontBakedFallback(baked);
4572
4573
// Mark index as not found, so we don't attempt the search twice
4574
ImFontBaked_BuildGrowIndex(baked, codepoint + 1);
4575
baked->IndexAdvanceX[codepoint] = baked->FallbackAdvanceX;
4576
baked->IndexLookup[codepoint] = IM_FONTGLYPH_INDEX_NOT_FOUND;
4577
return NULL;
4578
}
4579
4580
static float ImFontBaked_BuildLoadGlyphAdvanceX(ImFontBaked* baked, ImWchar codepoint)
4581
{
4582
if (baked->Size >= IMGUI_FONT_SIZE_THRESHOLD_FOR_LOADADVANCEXONLYMODE || baked->LoadNoRenderOnLayout)
4583
{
4584
// First load AdvanceX value used by CalcTextSize() API then load the rest when loaded by drawing API.
4585
float only_advance_x = 0.0f;
4586
ImFontGlyph* glyph = ImFontBaked_BuildLoadGlyph(baked, (ImWchar)codepoint, &only_advance_x);
4587
return glyph ? glyph->AdvanceX : only_advance_x;
4588
}
4589
else
4590
{
4591
ImFontGlyph* glyph = ImFontBaked_BuildLoadGlyph(baked, (ImWchar)codepoint, NULL);
4592
return glyph ? glyph->AdvanceX : baked->FallbackAdvanceX;
4593
}
4594
}
4595
4596
// The point of this indirection is to not be inlined in debug mode in order to not bloat inner loop.b
4597
IM_MSVC_RUNTIME_CHECKS_OFF
4598
static float BuildLoadGlyphGetAdvanceOrFallback(ImFontBaked* baked, unsigned int codepoint)
4599
{
4600
return ImFontBaked_BuildLoadGlyphAdvanceX(baked, (ImWchar)codepoint);
4601
}
4602
IM_MSVC_RUNTIME_CHECKS_RESTORE
4603
4604
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
4605
void ImFontAtlasDebugLogTextureRequests(ImFontAtlas* atlas)
4606
{
4607
// [DEBUG] Log texture update requests
4608
ImGuiContext& g = *GImGui;
4609
IM_UNUSED(g);
4610
for (ImTextureData* tex : atlas->TexList)
4611
{
4612
if ((g.IO.BackendFlags & ImGuiBackendFlags_RendererHasTextures) == 0)
4613
IM_ASSERT(tex->Updates.Size == 0);
4614
if (tex->Status == ImTextureStatus_WantCreate)
4615
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: create %dx%d\n", tex->UniqueID, tex->Width, tex->Height);
4616
else if (tex->Status == ImTextureStatus_WantDestroy)
4617
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: destroy %dx%d, texid=0x%" IM_PRIX64 ", backend_data=%p\n", tex->UniqueID, tex->Width, tex->Height, ImGui::DebugTextureIDToU64(tex->TexID), tex->BackendUserData);
4618
else if (tex->Status == ImTextureStatus_WantUpdates)
4619
{
4620
IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: update %d regions, texid=0x%" IM_PRIX64 ", backend_data=0x%" IM_PRIX64 "\n", tex->UniqueID, tex->Updates.Size, ImGui::DebugTextureIDToU64(tex->TexID), (ImU64)(intptr_t)tex->BackendUserData);
4621
for (const ImTextureRect& r : tex->Updates)
4622
{
4623
IM_UNUSED(r);
4624
IM_ASSERT(r.x >= 0 && r.y >= 0);
4625
IM_ASSERT(r.x + r.w <= tex->Width && r.y + r.h <= tex->Height); // In theory should subtract PackPadding but it's currently part of atlas and mid-frame change would wreck assert.
4626
//IMGUI_DEBUG_LOG_FONT("[font] Texture #%03d: update (% 4d..%-4d)->(% 4d..%-4d), texid=0x%" IM_PRIX64 ", backend_data=0x%" IM_PRIX64 "\n", tex->UniqueID, r.x, r.y, r.x + r.w, r.y + r.h, ImGui::DebugTextureIDToU64(tex->TexID), (ImU64)(intptr_t)tex->BackendUserData);
4627
}
4628
}
4629
}
4630
}
4631
#endif
4632
4633
//-------------------------------------------------------------------------
4634
// [SECTION] ImFontAtlas: backend for stb_truetype
4635
//-------------------------------------------------------------------------
4636
// (imstb_truetype.h in included near the top of this file, when IMGUI_ENABLE_STB_TRUETYPE is set)
4637
//-------------------------------------------------------------------------
4638
4639
#ifdef IMGUI_ENABLE_STB_TRUETYPE
4640
4641
// One for each ConfigData
4642
struct ImGui_ImplStbTrueType_FontSrcData
4643
{
4644
stbtt_fontinfo FontInfo;
4645
float ScaleFactor;
4646
};
4647
4648
static bool ImGui_ImplStbTrueType_FontSrcInit(ImFontAtlas* atlas, ImFontConfig* src)
4649
{
4650
IM_UNUSED(atlas);
4651
4652
ImGui_ImplStbTrueType_FontSrcData* bd_font_data = IM_NEW(ImGui_ImplStbTrueType_FontSrcData);
4653
IM_ASSERT(src->FontLoaderData == NULL);
4654
4655
// Initialize helper structure for font loading and verify that the TTF/OTF data is correct
4656
const int font_offset = stbtt_GetFontOffsetForIndex((const unsigned char*)src->FontData, src->FontNo);
4657
if (font_offset < 0)
4658
{
4659
IM_DELETE(bd_font_data);
4660
IM_ASSERT_USER_ERROR(0, "stbtt_GetFontOffsetForIndex(): FontData is incorrect, or FontNo cannot be found.");
4661
return false;
4662
}
4663
if (!stbtt_InitFont(&bd_font_data->FontInfo, (const unsigned char*)src->FontData, font_offset))
4664
{
4665
IM_DELETE(bd_font_data);
4666
IM_ASSERT_USER_ERROR(0, "stbtt_InitFont(): failed to parse FontData. It is correct and complete? Check FontDataSize.");
4667
return false;
4668
}
4669
src->FontLoaderData = bd_font_data;
4670
4671
const float ref_size = src->DstFont->Sources[0]->SizePixels;
4672
if (src->MergeMode && src->SizePixels == 0.0f)
4673
src->SizePixels = ref_size;
4674
4675
bd_font_data->ScaleFactor = stbtt_ScaleForPixelHeight(&bd_font_data->FontInfo, 1.0f);
4676
if (src->MergeMode && src->SizePixels != 0.0f && ref_size != 0.0f)
4677
bd_font_data->ScaleFactor *= src->SizePixels / ref_size; // FIXME-NEWATLAS: Should tidy up that a bit
4678
bd_font_data->ScaleFactor *= src->ExtraSizeScale;
4679
4680
return true;
4681
}
4682
4683
static void ImGui_ImplStbTrueType_FontSrcDestroy(ImFontAtlas* atlas, ImFontConfig* src)
4684
{
4685
IM_UNUSED(atlas);
4686
ImGui_ImplStbTrueType_FontSrcData* bd_font_data = (ImGui_ImplStbTrueType_FontSrcData*)src->FontLoaderData;
4687
IM_DELETE(bd_font_data);
4688
src->FontLoaderData = NULL;
4689
}
4690
4691
static bool ImGui_ImplStbTrueType_FontSrcContainsGlyph(ImFontAtlas* atlas, ImFontConfig* src, ImWchar codepoint)
4692
{
4693
IM_UNUSED(atlas);
4694
4695
ImGui_ImplStbTrueType_FontSrcData* bd_font_data = (ImGui_ImplStbTrueType_FontSrcData*)src->FontLoaderData;
4696
IM_ASSERT(bd_font_data != NULL);
4697
4698
int glyph_index = stbtt_FindGlyphIndex(&bd_font_data->FontInfo, (int)codepoint);
4699
return glyph_index != 0;
4700
}
4701
4702
static bool ImGui_ImplStbTrueType_FontBakedInit(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void*)
4703
{
4704
IM_UNUSED(atlas);
4705
4706
ImGui_ImplStbTrueType_FontSrcData* bd_font_data = (ImGui_ImplStbTrueType_FontSrcData*)src->FontLoaderData;
4707
if (src->MergeMode == false)
4708
{
4709
// FIXME-NEWFONTS: reevaluate how to use sizing metrics
4710
// FIXME-NEWFONTS: make use of line gap value
4711
float scale_for_layout = bd_font_data->ScaleFactor * baked->Size;
4712
int unscaled_ascent, unscaled_descent, unscaled_line_gap;
4713
stbtt_GetFontVMetrics(&bd_font_data->FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
4714
baked->Ascent = ImCeil(unscaled_ascent * scale_for_layout);
4715
baked->Descent = ImFloor(unscaled_descent * scale_for_layout);
4716
}
4717
return true;
4718
}
4719
4720
static bool ImGui_ImplStbTrueType_FontBakedLoadGlyph(ImFontAtlas* atlas, ImFontConfig* src, ImFontBaked* baked, void*, ImWchar codepoint, ImFontGlyph* out_glyph, float* out_advance_x)
4721
{
4722
// Search for first font which has the glyph
4723
ImGui_ImplStbTrueType_FontSrcData* bd_font_data = (ImGui_ImplStbTrueType_FontSrcData*)src->FontLoaderData;
4724
IM_ASSERT(bd_font_data);
4725
int glyph_index = stbtt_FindGlyphIndex(&bd_font_data->FontInfo, (int)codepoint);
4726
if (glyph_index == 0)
4727
return false;
4728
4729
// Fonts unit to pixels
4730
int oversample_h, oversample_v;
4731
ImFontAtlasBuildGetOversampleFactors(src, baked, &oversample_h, &oversample_v);
4732
const float scale_for_layout = bd_font_data->ScaleFactor * baked->Size;
4733
const float rasterizer_density = src->RasterizerDensity * baked->RasterizerDensity;
4734
const float scale_for_raster_x = bd_font_data->ScaleFactor * baked->Size * rasterizer_density * oversample_h;
4735
const float scale_for_raster_y = bd_font_data->ScaleFactor * baked->Size * rasterizer_density * oversample_v;
4736
4737
// Obtain size and advance
4738
int x0, y0, x1, y1;
4739
int advance, lsb;
4740
stbtt_GetGlyphBitmapBoxSubpixel(&bd_font_data->FontInfo, glyph_index, scale_for_raster_x, scale_for_raster_y, 0, 0, &x0, &y0, &x1, &y1);
4741
stbtt_GetGlyphHMetrics(&bd_font_data->FontInfo, glyph_index, &advance, &lsb);
4742
4743
// Load metrics only mode
4744
if (out_advance_x != NULL)
4745
{
4746
IM_ASSERT(out_glyph == NULL);
4747
*out_advance_x = advance * scale_for_layout;
4748
return true;
4749
}
4750
4751
// Prepare glyph
4752
out_glyph->Codepoint = codepoint;
4753
out_glyph->AdvanceX = advance * scale_for_layout;
4754
4755
// Pack and retrieve position inside texture atlas
4756
// (generally based on stbtt_PackFontRangesRenderIntoRects)
4757
const bool is_visible = (x0 != x1 && y0 != y1);
4758
if (is_visible)
4759
{
4760
const int w = (x1 - x0 + oversample_h - 1);
4761
const int h = (y1 - y0 + oversample_v - 1);
4762
ImFontAtlasRectId pack_id = ImFontAtlasPackAddRect(atlas, w, h);
4763
if (pack_id == ImFontAtlasRectId_Invalid)
4764
{
4765
// Pathological out of memory case (TexMaxWidth/TexMaxHeight set too small?)
4766
IM_ASSERT(pack_id != ImFontAtlasRectId_Invalid && "Out of texture memory.");
4767
return false;
4768
}
4769
ImTextureRect* r = ImFontAtlasPackGetRect(atlas, pack_id);
4770
4771
// Render
4772
stbtt_GetGlyphBitmapBox(&bd_font_data->FontInfo, glyph_index, scale_for_raster_x, scale_for_raster_y, &x0, &y0, &x1, &y1);
4773
ImFontAtlasBuilder* builder = atlas->Builder;
4774
builder->TempBuffer.resize(w * h * 1);
4775
unsigned char* bitmap_pixels = builder->TempBuffer.Data;
4776
memset(bitmap_pixels, 0, w * h * 1);
4777
4778
// Render with oversampling
4779
// (those functions conveniently assert if pixels are not cleared, which is another safety layer)
4780
float sub_x, sub_y;
4781
stbtt_MakeGlyphBitmapSubpixelPrefilter(&bd_font_data->FontInfo, bitmap_pixels, w, h, w,
4782
scale_for_raster_x, scale_for_raster_y, 0, 0, oversample_h, oversample_v, &sub_x, &sub_y, glyph_index);
4783
4784
const float ref_size = baked->OwnerFont->Sources[0]->SizePixels;
4785
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
4786
float font_off_x = ImFloor(src->GlyphOffset.x * offsets_scale + 0.5f); // Snap scaled offset.
4787
float font_off_y = ImFloor(src->GlyphOffset.y * offsets_scale + 0.5f);
4788
font_off_x += sub_x;
4789
font_off_y += sub_y + IM_ROUND(baked->Ascent);
4790
float recip_h = 1.0f / (oversample_h * rasterizer_density);
4791
float recip_v = 1.0f / (oversample_v * rasterizer_density);
4792
4793
// Register glyph
4794
// r->x r->y are coordinates inside texture (in pixels)
4795
// glyph.X0, glyph.Y0 are drawing coordinates from base text position, and accounting for oversampling.
4796
out_glyph->X0 = x0 * recip_h + font_off_x;
4797
out_glyph->Y0 = y0 * recip_v + font_off_y;
4798
out_glyph->X1 = (x0 + (int)r->w) * recip_h + font_off_x;
4799
out_glyph->Y1 = (y0 + (int)r->h) * recip_v + font_off_y;
4800
out_glyph->Visible = true;
4801
out_glyph->PackId = pack_id;
4802
ImFontAtlasBakedSetFontGlyphBitmap(atlas, baked, src, out_glyph, r, bitmap_pixels, ImTextureFormat_Alpha8, w);
4803
}
4804
4805
return true;
4806
}
4807
4808
const ImFontLoader* ImFontAtlasGetFontLoaderForStbTruetype()
4809
{
4810
static ImFontLoader loader;
4811
loader.Name = "stb_truetype";
4812
loader.FontSrcInit = ImGui_ImplStbTrueType_FontSrcInit;
4813
loader.FontSrcDestroy = ImGui_ImplStbTrueType_FontSrcDestroy;
4814
loader.FontSrcContainsGlyph = ImGui_ImplStbTrueType_FontSrcContainsGlyph;
4815
loader.FontBakedInit = ImGui_ImplStbTrueType_FontBakedInit;
4816
loader.FontBakedDestroy = NULL;
4817
loader.FontBakedLoadGlyph = ImGui_ImplStbTrueType_FontBakedLoadGlyph;
4818
return &loader;
4819
}
4820
4821
#endif // IMGUI_ENABLE_STB_TRUETYPE
4822
4823
//-------------------------------------------------------------------------
4824
// [SECTION] ImFontAtlas: glyph ranges helpers
4825
//-------------------------------------------------------------------------
4826
// - GetGlyphRangesDefault()
4827
// Obsolete functions since 1.92:
4828
// - GetGlyphRangesGreek()
4829
// - GetGlyphRangesKorean()
4830
// - GetGlyphRangesChineseFull()
4831
// - GetGlyphRangesChineseSimplifiedCommon()
4832
// - GetGlyphRangesJapanese()
4833
// - GetGlyphRangesCyrillic()
4834
// - GetGlyphRangesThai()
4835
// - GetGlyphRangesVietnamese()
4836
//-----------------------------------------------------------------------------
4837
4838
// Retrieve list of range (2 int per range, values are inclusive)
4839
const ImWchar* ImFontAtlas::GetGlyphRangesDefault()
4840
{
4841
static const ImWchar ranges[] =
4842
{
4843
0x0020, 0x00FF, // Basic Latin + Latin Supplement
4844
0,
4845
};
4846
return &ranges[0];
4847
}
4848
4849
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
4850
const ImWchar* ImFontAtlas::GetGlyphRangesGreek()
4851
{
4852
static const ImWchar ranges[] =
4853
{
4854
0x0020, 0x00FF, // Basic Latin + Latin Supplement
4855
0x0370, 0x03FF, // Greek and Coptic
4856
0,
4857
};
4858
return &ranges[0];
4859
}
4860
4861
const ImWchar* ImFontAtlas::GetGlyphRangesKorean()
4862
{
4863
static const ImWchar ranges[] =
4864
{
4865
0x0020, 0x00FF, // Basic Latin + Latin Supplement
4866
0x3131, 0x3163, // Korean alphabets
4867
0xAC00, 0xD7A3, // Korean characters
4868
0xFFFD, 0xFFFD, // Invalid
4869
0,
4870
};
4871
return &ranges[0];
4872
}
4873
4874
const ImWchar* ImFontAtlas::GetGlyphRangesChineseFull()
4875
{
4876
static const ImWchar ranges[] =
4877
{
4878
0x0020, 0x00FF, // Basic Latin + Latin Supplement
4879
0x2000, 0x206F, // General Punctuation
4880
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
4881
0x31F0, 0x31FF, // Katakana Phonetic Extensions
4882
0xFF00, 0xFFEF, // Half-width characters
4883
0xFFFD, 0xFFFD, // Invalid
4884
0x4e00, 0x9FAF, // CJK Ideograms
4885
0,
4886
};
4887
return &ranges[0];
4888
}
4889
4890
static void UnpackAccumulativeOffsetsIntoRanges(int base_codepoint, const short* accumulative_offsets, int accumulative_offsets_count, ImWchar* out_ranges)
4891
{
4892
for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2)
4893
{
4894
out_ranges[0] = out_ranges[1] = (ImWchar)(base_codepoint + accumulative_offsets[n]);
4895
base_codepoint += accumulative_offsets[n];
4896
}
4897
out_ranges[0] = 0;
4898
}
4899
4900
const ImWchar* ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon()
4901
{
4902
// Store 2500 regularly used characters for Simplified Chinese.
4903
// Sourced from https://zh.wiktionary.org/wiki/%E9%99%84%E5%BD%95:%E7%8E%B0%E4%BB%A3%E6%B1%89%E8%AF%AD%E5%B8%B8%E7%94%A8%E5%AD%97%E8%A1%A8
4904
// This table covers 97.97% of all characters used during the month in July, 1987.
4905
// You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters.
4906
// (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.)
4907
static const short accumulative_offsets_from_0x4E00[] =
4908
{
4909
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,5,2,3,1,2,1,2,1,1,2,1,1,2,2,1,4,1,1,1,1,5,10,1,2,19,2,1,2,1,2,1,2,1,2,
4910
1,5,1,6,3,2,1,2,2,1,1,1,4,8,5,1,1,4,1,1,3,1,2,1,5,1,2,1,1,1,10,1,1,5,2,4,6,1,4,2,2,2,12,2,1,1,6,1,1,1,4,1,1,4,6,5,1,4,2,2,4,10,7,1,1,4,2,4,
4911
2,1,4,3,6,10,12,5,7,2,14,2,9,1,1,6,7,10,4,7,13,1,5,4,8,4,1,1,2,28,5,6,1,1,5,2,5,20,2,2,9,8,11,2,9,17,1,8,6,8,27,4,6,9,20,11,27,6,68,2,2,1,1,
4912
1,2,1,2,2,7,6,11,3,3,1,1,3,1,2,1,1,1,1,1,3,1,1,8,3,4,1,5,7,2,1,4,4,8,4,2,1,2,1,1,4,5,6,3,6,2,12,3,1,3,9,2,4,3,4,1,5,3,3,1,3,7,1,5,1,1,1,1,2,
4913
3,4,5,2,3,2,6,1,1,2,1,7,1,7,3,4,5,15,2,2,1,5,3,22,19,2,1,1,1,1,2,5,1,1,1,6,1,1,12,8,2,9,18,22,4,1,1,5,1,16,1,2,7,10,15,1,1,6,2,4,1,2,4,1,6,
4914
1,1,3,2,4,1,6,4,5,1,2,1,1,2,1,10,3,1,3,2,1,9,3,2,5,7,2,19,4,3,6,1,1,1,1,1,4,3,2,1,1,1,2,5,3,1,1,1,2,2,1,1,2,1,1,2,1,3,1,1,1,3,7,1,4,1,1,2,1,
4915
1,2,1,2,4,4,3,8,1,1,1,2,1,3,5,1,3,1,3,4,6,2,2,14,4,6,6,11,9,1,15,3,1,28,5,2,5,5,3,1,3,4,5,4,6,14,3,2,3,5,21,2,7,20,10,1,2,19,2,4,28,28,2,3,
4916
2,1,14,4,1,26,28,42,12,40,3,52,79,5,14,17,3,2,2,11,3,4,6,3,1,8,2,23,4,5,8,10,4,2,7,3,5,1,1,6,3,1,2,2,2,5,28,1,1,7,7,20,5,3,29,3,17,26,1,8,4,
4917
27,3,6,11,23,5,3,4,6,13,24,16,6,5,10,25,35,7,3,2,3,3,14,3,6,2,6,1,4,2,3,8,2,1,1,3,3,3,4,1,1,13,2,2,4,5,2,1,14,14,1,2,2,1,4,5,2,3,1,14,3,12,
4918
3,17,2,16,5,1,2,1,8,9,3,19,4,2,2,4,17,25,21,20,28,75,1,10,29,103,4,1,2,1,1,4,2,4,1,2,3,24,2,2,2,1,1,2,1,3,8,1,1,1,2,1,1,3,1,1,1,6,1,5,3,1,1,
4919
1,3,4,1,1,5,2,1,5,6,13,9,16,1,1,1,1,3,2,3,2,4,5,2,5,2,2,3,7,13,7,2,2,1,1,1,1,2,3,3,2,1,6,4,9,2,1,14,2,14,2,1,18,3,4,14,4,11,41,15,23,15,23,
4920
176,1,3,4,1,1,1,1,5,3,1,2,3,7,3,1,1,2,1,2,4,4,6,2,4,1,9,7,1,10,5,8,16,29,1,1,2,2,3,1,3,5,2,4,5,4,1,1,2,2,3,3,7,1,6,10,1,17,1,44,4,6,2,1,1,6,
4921
5,4,2,10,1,6,9,2,8,1,24,1,2,13,7,8,8,2,1,4,1,3,1,3,3,5,2,5,10,9,4,9,12,2,1,6,1,10,1,1,7,7,4,10,8,3,1,13,4,3,1,6,1,3,5,2,1,2,17,16,5,2,16,6,
4922
1,4,2,1,3,3,6,8,5,11,11,1,3,3,2,4,6,10,9,5,7,4,7,4,7,1,1,4,2,1,3,6,8,7,1,6,11,5,5,3,24,9,4,2,7,13,5,1,8,82,16,61,1,1,1,4,2,2,16,10,3,8,1,1,
4923
6,4,2,1,3,1,1,1,4,3,8,4,2,2,1,1,1,1,1,6,3,5,1,1,4,6,9,2,1,1,1,2,1,7,2,1,6,1,5,4,4,3,1,8,1,3,3,1,3,2,2,2,2,3,1,6,1,2,1,2,1,3,7,1,8,2,1,2,1,5,
4924
2,5,3,5,10,1,2,1,1,3,2,5,11,3,9,3,5,1,1,5,9,1,2,1,5,7,9,9,8,1,3,3,3,6,8,2,3,2,1,1,32,6,1,2,15,9,3,7,13,1,3,10,13,2,14,1,13,10,2,1,3,10,4,15,
4925
2,15,15,10,1,3,9,6,9,32,25,26,47,7,3,2,3,1,6,3,4,3,2,8,5,4,1,9,4,2,2,19,10,6,2,3,8,1,2,2,4,2,1,9,4,4,4,6,4,8,9,2,3,1,1,1,1,3,5,5,1,3,8,4,6,
4926
2,1,4,12,1,5,3,7,13,2,5,8,1,6,1,2,5,14,6,1,5,2,4,8,15,5,1,23,6,62,2,10,1,1,8,1,2,2,10,4,2,2,9,2,1,1,3,2,3,1,5,3,3,2,1,3,8,1,1,1,11,3,1,1,4,
4927
3,7,1,14,1,2,3,12,5,2,5,1,6,7,5,7,14,11,1,3,1,8,9,12,2,1,11,8,4,4,2,6,10,9,13,1,1,3,1,5,1,3,2,4,4,1,18,2,3,14,11,4,29,4,2,7,1,3,13,9,2,2,5,
4928
3,5,20,7,16,8,5,72,34,6,4,22,12,12,28,45,36,9,7,39,9,191,1,1,1,4,11,8,4,9,2,3,22,1,1,1,1,4,17,1,7,7,1,11,31,10,2,4,8,2,3,2,1,4,2,16,4,32,2,
4929
3,19,13,4,9,1,5,2,14,8,1,1,3,6,19,6,5,1,16,6,2,10,8,5,1,2,3,1,5,5,1,11,6,6,1,3,3,2,6,3,8,1,1,4,10,7,5,7,7,5,8,9,2,1,3,4,1,1,3,1,3,3,2,6,16,
4930
1,4,6,3,1,10,6,1,3,15,2,9,2,10,25,13,9,16,6,2,2,10,11,4,3,9,1,2,6,6,5,4,30,40,1,10,7,12,14,33,6,3,6,7,3,1,3,1,11,14,4,9,5,12,11,49,18,51,31,
4931
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,
4932
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,
4933
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,
4934
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,
4935
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,
4936
4,22,39,95,38,8,14,9,5,1,13,5,4,3,13,12,11,1,9,1,27,37,2,5,4,4,63,211,95,2,2,2,1,3,5,2,1,1,2,2,1,1,1,3,2,4,1,2,1,1,5,2,2,1,1,2,3,1,3,1,1,1,
4937
3,1,4,2,1,3,6,1,1,3,7,15,5,3,2,5,3,9,11,4,2,22,1,6,3,8,7,1,4,28,4,16,3,3,25,4,4,27,27,1,4,1,2,2,7,1,3,5,2,28,8,2,14,1,8,6,16,25,3,3,3,14,3,
4938
3,1,1,2,1,4,6,3,8,4,1,1,1,2,3,6,10,6,2,3,18,3,2,5,5,4,3,1,5,2,5,4,23,7,6,12,6,4,17,11,9,5,1,1,10,5,12,1,1,11,26,33,7,3,6,1,17,7,1,5,12,1,11,
4939
2,4,1,8,14,17,23,1,2,1,7,8,16,11,9,6,5,2,6,4,16,2,8,14,1,11,8,9,1,1,1,9,25,4,11,19,7,2,15,2,12,8,52,7,5,19,2,16,4,36,8,1,16,8,24,26,4,6,2,9,
4940
5,4,36,3,28,12,25,15,37,27,17,12,59,38,5,32,127,1,2,9,17,14,4,1,2,1,1,8,11,50,4,14,2,19,16,4,17,5,4,5,26,12,45,2,23,45,104,30,12,8,3,10,2,2,
4941
3,3,1,4,20,7,2,9,6,15,2,20,1,3,16,4,11,15,6,134,2,5,59,1,2,2,2,1,9,17,3,26,137,10,211,59,1,2,4,1,4,1,1,1,2,6,2,3,1,1,2,3,2,3,1,3,4,4,2,3,3,
4942
1,4,3,1,7,2,2,3,1,2,1,3,3,3,2,2,3,2,1,3,14,6,1,3,2,9,6,15,27,9,34,145,1,1,2,1,1,1,1,2,1,1,1,1,2,2,2,3,1,2,1,1,1,2,3,5,8,3,5,2,4,1,3,2,2,2,12,
4943
4,1,1,1,10,4,5,1,20,4,16,1,15,9,5,12,2,9,2,5,4,2,26,19,7,1,26,4,30,12,15,42,1,6,8,172,1,1,4,2,1,1,11,2,2,4,2,1,2,1,10,8,1,2,1,4,5,1,2,5,1,8,
4944
4,1,3,4,2,1,6,2,1,3,4,1,2,1,1,1,1,12,5,7,2,4,3,1,1,1,3,3,6,1,2,2,3,3,3,2,1,2,12,14,11,6,6,4,12,2,8,1,7,10,1,35,7,4,13,15,4,3,23,21,28,52,5,
4945
26,5,6,1,7,10,2,7,53,3,2,1,1,1,2,163,532,1,10,11,1,3,3,4,8,2,8,6,2,2,23,22,4,2,2,4,2,1,3,1,3,3,5,9,8,2,1,2,8,1,10,2,12,21,20,15,105,2,3,1,1,
4946
3,2,3,1,1,2,5,1,4,15,11,19,1,1,1,1,5,4,5,1,1,2,5,3,5,12,1,2,5,1,11,1,1,15,9,1,4,5,3,26,8,2,1,3,1,1,15,19,2,12,1,2,5,2,7,2,19,2,20,6,26,7,5,
4947
2,2,7,34,21,13,70,2,128,1,1,2,1,1,2,1,1,3,2,2,2,15,1,4,1,3,4,42,10,6,1,49,85,8,1,2,1,1,4,4,2,3,6,1,5,7,4,3,211,4,1,2,1,2,5,1,2,4,2,2,6,5,6,
4948
10,3,4,48,100,6,2,16,296,5,27,387,2,2,3,7,16,8,5,38,15,39,21,9,10,3,7,59,13,27,21,47,5,21,6
4949
};
4950
static ImWchar base_ranges[] = // not zero-terminated
4951
{
4952
0x0020, 0x00FF, // Basic Latin + Latin Supplement
4953
0x2000, 0x206F, // General Punctuation
4954
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
4955
0x31F0, 0x31FF, // Katakana Phonetic Extensions
4956
0xFF00, 0xFFEF, // Half-width characters
4957
0xFFFD, 0xFFFD // Invalid
4958
};
4959
static ImWchar full_ranges[IM_COUNTOF(base_ranges) + IM_COUNTOF(accumulative_offsets_from_0x4E00) * 2 + 1] = { 0 };
4960
if (!full_ranges[0])
4961
{
4962
memcpy(full_ranges, base_ranges, sizeof(base_ranges));
4963
UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_COUNTOF(accumulative_offsets_from_0x4E00), full_ranges + IM_COUNTOF(base_ranges));
4964
}
4965
return &full_ranges[0];
4966
}
4967
4968
const ImWchar* ImFontAtlas::GetGlyphRangesJapanese()
4969
{
4970
// 2999 ideograms code points for Japanese
4971
// - 2136 Joyo (meaning "for regular use" or "for common use") Kanji code points
4972
// - 863 Jinmeiyo (meaning "for personal name") Kanji code points
4973
// - Sourced from official information provided by the government agencies of Japan:
4974
// - List of Joyo Kanji by the Agency for Cultural Affairs
4975
// - https://www.bunka.go.jp/kokugo_nihongo/sisaku/joho/joho/kijun/naikaku/kanji/
4976
// - List of Jinmeiyo Kanji by the Ministry of Justice
4977
// - http://www.moj.go.jp/MINJI/minji86.html
4978
// - Available under the terms of the Creative Commons Attribution 4.0 International (CC BY 4.0).
4979
// - https://creativecommons.org/licenses/by/4.0/legalcode
4980
// - You can generate this code by the script at:
4981
// - https://github.com/vaiorabbit/everyday_use_kanji
4982
// - References:
4983
// - List of Joyo Kanji
4984
// - (Wikipedia) https://en.wikipedia.org/wiki/List_of_j%C5%8Dy%C5%8D_kanji
4985
// - List of Jinmeiyo Kanji
4986
// - (Wikipedia) https://en.wikipedia.org/wiki/Jinmeiy%C5%8D_kanji
4987
// - Missing 1 Joyo Kanji: U+20B9F (Kun'yomi: Shikaru, On'yomi: Shitsu,shichi), see https://github.com/ocornut/imgui/pull/3627 for details.
4988
// You can use ImFontGlyphRangesBuilder to create your own ranges derived from this, by merging existing ranges or adding new characters.
4989
// (Stored as accumulative offsets from the initial unicode codepoint 0x4E00. This encoding is designed to helps us compact the source code size.)
4990
static const short accumulative_offsets_from_0x4E00[] =
4991
{
4992
0,1,2,4,1,1,1,1,2,1,3,3,2,2,1,5,3,5,7,5,6,1,2,1,7,2,6,3,1,8,1,1,4,1,1,18,2,11,2,6,2,1,2,1,5,1,2,1,3,1,2,1,2,3,3,1,1,2,3,1,1,1,12,7,9,1,4,5,1,
4993
1,2,1,10,1,1,9,2,2,4,5,6,9,3,1,1,1,1,9,3,18,5,2,2,2,2,1,6,3,7,1,1,1,1,2,2,4,2,1,23,2,10,4,3,5,2,4,10,2,4,13,1,6,1,9,3,1,1,6,6,7,6,3,1,2,11,3,
4994
2,2,3,2,15,2,2,5,4,3,6,4,1,2,5,2,12,16,6,13,9,13,2,1,1,7,16,4,7,1,19,1,5,1,2,2,7,7,8,2,6,5,4,9,18,7,4,5,9,13,11,8,15,2,1,1,1,2,1,2,2,1,2,2,8,
4995
2,9,3,3,1,1,4,4,1,1,1,4,9,1,4,3,5,5,2,7,5,3,4,8,2,1,13,2,3,3,1,14,1,1,4,5,1,3,6,1,5,2,1,1,3,3,3,3,1,1,2,7,6,6,7,1,4,7,6,1,1,1,1,1,12,3,3,9,5,
4996
2,6,1,5,6,1,2,3,18,2,4,14,4,1,3,6,1,1,6,3,5,5,3,2,2,2,2,12,3,1,4,2,3,2,3,11,1,7,4,1,2,1,3,17,1,9,1,24,1,1,4,2,2,4,1,2,7,1,1,1,3,1,2,2,4,15,1,
4997
1,2,1,1,2,1,5,2,5,20,2,5,9,1,10,8,7,6,1,1,1,1,1,1,6,2,1,2,8,1,1,1,1,5,1,1,3,1,1,1,1,3,1,1,12,4,1,3,1,1,1,1,1,10,3,1,7,5,13,1,2,3,4,6,1,1,30,
4998
2,9,9,1,15,38,11,3,1,8,24,7,1,9,8,10,2,1,9,31,2,13,6,2,9,4,49,5,2,15,2,1,10,2,1,1,1,2,2,6,15,30,35,3,14,18,8,1,16,10,28,12,19,45,38,1,3,2,3,
4999
13,2,1,7,3,6,5,3,4,3,1,5,7,8,1,5,3,18,5,3,6,1,21,4,24,9,24,40,3,14,3,21,3,2,1,2,4,2,3,1,15,15,6,5,1,1,3,1,5,6,1,9,7,3,3,2,1,4,3,8,21,5,16,4,
5000
5,2,10,11,11,3,6,3,2,9,3,6,13,1,2,1,1,1,1,11,12,6,6,1,4,2,6,5,2,1,1,3,3,6,13,3,1,1,5,1,2,3,3,14,2,1,2,2,2,5,1,9,5,1,1,6,12,3,12,3,4,13,2,14,
5001
2,8,1,17,5,1,16,4,2,2,21,8,9,6,23,20,12,25,19,9,38,8,3,21,40,25,33,13,4,3,1,4,1,2,4,1,2,5,26,2,1,1,2,1,3,6,2,1,1,1,1,1,1,2,3,1,1,1,9,2,3,1,1,
5002
1,3,6,3,2,1,1,6,6,1,8,2,2,2,1,4,1,2,3,2,7,3,2,4,1,2,1,2,2,1,1,1,1,1,3,1,2,5,4,10,9,4,9,1,1,1,1,1,1,5,3,2,1,6,4,9,6,1,10,2,31,17,8,3,7,5,40,1,
5003
7,7,1,6,5,2,10,7,8,4,15,39,25,6,28,47,18,10,7,1,3,1,1,2,1,1,1,3,3,3,1,1,1,3,4,2,1,4,1,3,6,10,7,8,6,2,2,1,3,3,2,5,8,7,9,12,2,15,1,1,4,1,2,1,1,
5004
1,3,2,1,3,3,5,6,2,3,2,10,1,4,2,8,1,1,1,11,6,1,21,4,16,3,1,3,1,4,2,3,6,5,1,3,1,1,3,3,4,6,1,1,10,4,2,7,10,4,7,4,2,9,4,3,1,1,1,4,1,8,3,4,1,3,1,
5005
6,1,4,2,1,4,7,2,1,8,1,4,5,1,1,2,2,4,6,2,7,1,10,1,1,3,4,11,10,8,21,4,6,1,3,5,2,1,2,28,5,5,2,3,13,1,2,3,1,4,2,1,5,20,3,8,11,1,3,3,3,1,8,10,9,2,
5006
10,9,2,3,1,1,2,4,1,8,3,6,1,7,8,6,11,1,4,29,8,4,3,1,2,7,13,1,4,1,6,2,6,12,12,2,20,3,2,3,6,4,8,9,2,7,34,5,1,18,6,1,1,4,4,5,7,9,1,2,2,4,3,4,1,7,
5007
2,2,2,6,2,3,25,5,3,6,1,4,6,7,4,2,1,4,2,13,6,4,4,3,1,5,3,4,4,3,2,1,1,4,1,2,1,1,3,1,11,1,6,3,1,7,3,6,2,8,8,6,9,3,4,11,3,2,10,12,2,5,11,1,6,4,5,
5008
3,1,8,5,4,6,6,3,5,1,1,3,2,1,2,2,6,17,12,1,10,1,6,12,1,6,6,19,9,6,16,1,13,4,4,15,7,17,6,11,9,15,12,6,7,2,1,2,2,15,9,3,21,4,6,49,18,7,3,2,3,1,
5009
6,8,2,2,6,2,9,1,3,6,4,4,1,2,16,2,5,2,1,6,2,3,5,3,1,2,5,1,2,1,9,3,1,8,6,4,8,11,3,1,1,1,1,3,1,13,8,4,1,3,2,2,1,4,1,11,1,5,2,1,5,2,5,8,6,1,1,7,
5010
4,3,8,3,2,7,2,1,5,1,5,2,4,7,6,2,8,5,1,11,4,5,3,6,18,1,2,13,3,3,1,21,1,1,4,1,4,1,1,1,8,1,2,2,7,1,2,4,2,2,9,2,1,1,1,4,3,6,3,12,5,1,1,1,5,6,3,2,
5011
4,8,2,2,4,2,7,1,8,9,5,2,3,2,1,3,2,13,7,14,6,5,1,1,2,1,4,2,23,2,1,1,6,3,1,4,1,15,3,1,7,3,9,14,1,3,1,4,1,1,5,8,1,3,8,3,8,15,11,4,14,4,4,2,5,5,
5012
1,7,1,6,14,7,7,8,5,15,4,8,6,5,6,2,1,13,1,20,15,11,9,2,5,6,2,11,2,6,2,5,1,5,8,4,13,19,25,4,1,1,11,1,34,2,5,9,14,6,2,2,6,1,1,14,1,3,14,13,1,6,
5013
12,21,14,14,6,32,17,8,32,9,28,1,2,4,11,8,3,1,14,2,5,15,1,1,1,1,3,6,4,1,3,4,11,3,1,1,11,30,1,5,1,4,1,5,8,1,1,3,2,4,3,17,35,2,6,12,17,3,1,6,2,
5014
1,1,12,2,7,3,3,2,1,16,2,8,3,6,5,4,7,3,3,8,1,9,8,5,1,2,1,3,2,8,1,2,9,12,1,1,2,3,8,3,24,12,4,3,7,5,8,3,3,3,3,3,3,1,23,10,3,1,2,2,6,3,1,16,1,16,
5015
22,3,10,4,11,6,9,7,7,3,6,2,2,2,4,10,2,1,1,2,8,7,1,6,4,1,3,3,3,5,10,12,12,2,3,12,8,15,1,1,16,6,6,1,5,9,11,4,11,4,2,6,12,1,17,5,13,1,4,9,5,1,11,
5016
2,1,8,1,5,7,28,8,3,5,10,2,17,3,38,22,1,2,18,12,10,4,38,18,1,4,44,19,4,1,8,4,1,12,1,4,31,12,1,14,7,75,7,5,10,6,6,13,3,2,11,11,3,2,5,28,15,6,18,
5017
18,5,6,4,3,16,1,7,18,7,36,3,5,3,1,7,1,9,1,10,7,2,4,2,6,2,9,7,4,3,32,12,3,7,10,2,23,16,3,1,12,3,31,4,11,1,3,8,9,5,1,30,15,6,12,3,2,2,11,19,9,
5018
14,2,6,2,3,19,13,17,5,3,3,25,3,14,1,1,1,36,1,3,2,19,3,13,36,9,13,31,6,4,16,34,2,5,4,2,3,3,5,1,1,1,4,3,1,17,3,2,3,5,3,1,3,2,3,5,6,3,12,11,1,3,
5019
1,2,26,7,12,7,2,14,3,3,7,7,11,25,25,28,16,4,36,1,2,1,6,2,1,9,3,27,17,4,3,4,13,4,1,3,2,2,1,10,4,2,4,6,3,8,2,1,18,1,1,24,2,2,4,33,2,3,63,7,1,6,
5020
40,7,3,4,4,2,4,15,18,1,16,1,1,11,2,41,14,1,3,18,13,3,2,4,16,2,17,7,15,24,7,18,13,44,2,2,3,6,1,1,7,5,1,7,1,4,3,3,5,10,8,2,3,1,8,1,1,27,4,2,1,
5021
12,1,2,1,10,6,1,6,7,5,2,3,7,11,5,11,3,6,6,2,3,15,4,9,1,1,2,1,2,11,2,8,12,8,5,4,2,3,1,5,2,2,1,14,1,12,11,4,1,11,17,17,4,3,2,5,5,7,3,1,5,9,9,8,
5022
2,5,6,6,13,13,2,1,2,6,1,2,2,49,4,9,1,2,10,16,7,8,4,3,2,23,4,58,3,29,1,14,19,19,11,11,2,7,5,1,3,4,6,2,18,5,12,12,17,17,3,3,2,4,1,6,2,3,4,3,1,
5023
1,1,1,5,1,1,9,1,3,1,3,6,1,8,1,1,2,6,4,14,3,1,4,11,4,1,3,32,1,2,4,13,4,1,2,4,2,1,3,1,11,1,4,2,1,4,4,6,3,5,1,6,5,7,6,3,23,3,5,3,5,3,3,13,3,9,10,
5024
1,12,10,2,3,18,13,7,160,52,4,2,2,3,2,14,5,4,12,4,6,4,1,20,4,11,6,2,12,27,1,4,1,2,2,7,4,5,2,28,3,7,25,8,3,19,3,6,10,2,2,1,10,2,5,4,1,3,4,1,5,
5025
3,2,6,9,3,6,2,16,3,3,16,4,5,5,3,2,1,2,16,15,8,2,6,21,2,4,1,22,5,8,1,1,21,11,2,1,11,11,19,13,12,4,2,3,2,3,6,1,8,11,1,4,2,9,5,2,1,11,2,9,1,1,2,
5026
14,31,9,3,4,21,14,4,8,1,7,2,2,2,5,1,4,20,3,3,4,10,1,11,9,8,2,1,4,5,14,12,14,2,17,9,6,31,4,14,1,20,13,26,5,2,7,3,6,13,2,4,2,19,6,2,2,18,9,3,5,
5027
12,12,14,4,6,2,3,6,9,5,22,4,5,25,6,4,8,5,2,6,27,2,35,2,16,3,7,8,8,6,6,5,9,17,2,20,6,19,2,13,3,1,1,1,4,17,12,2,14,7,1,4,18,12,38,33,2,10,1,1,
5028
2,13,14,17,11,50,6,33,20,26,74,16,23,45,50,13,38,33,6,6,7,4,4,2,1,3,2,5,8,7,8,9,3,11,21,9,13,1,3,10,6,7,1,2,2,18,5,5,1,9,9,2,68,9,19,13,2,5,
5029
1,4,4,7,4,13,3,9,10,21,17,3,26,2,1,5,2,4,5,4,1,7,4,7,3,4,2,1,6,1,1,20,4,1,9,2,2,1,3,3,2,3,2,1,1,1,20,2,3,1,6,2,3,6,2,4,8,1,3,2,10,3,5,3,4,4,
5030
3,4,16,1,6,1,10,2,4,2,1,1,2,10,11,2,2,3,1,24,31,4,10,10,2,5,12,16,164,15,4,16,7,9,15,19,17,1,2,1,1,5,1,1,1,1,1,3,1,4,3,1,3,1,3,1,2,1,1,3,3,7,
5031
2,8,1,2,2,2,1,3,4,3,7,8,12,92,2,10,3,1,3,14,5,25,16,42,4,7,7,4,2,21,5,27,26,27,21,25,30,31,2,1,5,13,3,22,5,6,6,11,9,12,1,5,9,7,5,5,22,60,3,5,
5032
13,1,1,8,1,1,3,3,2,1,9,3,3,18,4,1,2,3,7,6,3,1,2,3,9,1,3,1,3,2,1,3,1,1,1,2,1,11,3,1,6,9,1,3,2,3,1,2,1,5,1,1,4,3,4,1,2,2,4,4,1,7,2,1,2,2,3,5,13,
5033
18,3,4,14,9,9,4,16,3,7,5,8,2,6,48,28,3,1,1,4,2,14,8,2,9,2,1,15,2,4,3,2,10,16,12,8,7,1,1,3,1,1,1,2,7,4,1,6,4,38,39,16,23,7,15,15,3,2,12,7,21,
5034
37,27,6,5,4,8,2,10,8,8,6,5,1,2,1,3,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,
5035
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,
5036
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,
5037
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,
5038
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,
5039
3,2,1,1,1,1,2,1,1,
5040
};
5041
static ImWchar base_ranges[] = // not zero-terminated
5042
{
5043
0x0020, 0x00FF, // Basic Latin + Latin Supplement
5044
0x3000, 0x30FF, // CJK Symbols and Punctuations, Hiragana, Katakana
5045
0x31F0, 0x31FF, // Katakana Phonetic Extensions
5046
0xFF00, 0xFFEF, // Half-width characters
5047
0xFFFD, 0xFFFD // Invalid
5048
};
5049
static ImWchar full_ranges[IM_COUNTOF(base_ranges) + IM_COUNTOF(accumulative_offsets_from_0x4E00)*2 + 1] = { 0 };
5050
if (!full_ranges[0])
5051
{
5052
memcpy(full_ranges, base_ranges, sizeof(base_ranges));
5053
UnpackAccumulativeOffsetsIntoRanges(0x4E00, accumulative_offsets_from_0x4E00, IM_COUNTOF(accumulative_offsets_from_0x4E00), full_ranges + IM_COUNTOF(base_ranges));
5054
}
5055
return &full_ranges[0];
5056
}
5057
5058
const ImWchar* ImFontAtlas::GetGlyphRangesCyrillic()
5059
{
5060
static const ImWchar ranges[] =
5061
{
5062
0x0020, 0x00FF, // Basic Latin + Latin Supplement
5063
0x0400, 0x052F, // Cyrillic + Cyrillic Supplement
5064
0x2DE0, 0x2DFF, // Cyrillic Extended-A
5065
0xA640, 0xA69F, // Cyrillic Extended-B
5066
0,
5067
};
5068
return &ranges[0];
5069
}
5070
5071
const ImWchar* ImFontAtlas::GetGlyphRangesThai()
5072
{
5073
static const ImWchar ranges[] =
5074
{
5075
0x0020, 0x00FF, // Basic Latin
5076
0x2010, 0x205E, // Punctuations
5077
0x0E00, 0x0E7F, // Thai
5078
0,
5079
};
5080
return &ranges[0];
5081
}
5082
5083
const ImWchar* ImFontAtlas::GetGlyphRangesVietnamese()
5084
{
5085
static const ImWchar ranges[] =
5086
{
5087
0x0020, 0x00FF, // Basic Latin
5088
0x0102, 0x0103,
5089
0x0110, 0x0111,
5090
0x0128, 0x0129,
5091
0x0168, 0x0169,
5092
0x01A0, 0x01A1,
5093
0x01AF, 0x01B0,
5094
0x1EA0, 0x1EF9,
5095
0,
5096
};
5097
return &ranges[0];
5098
}
5099
#endif // #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
5100
5101
//-----------------------------------------------------------------------------
5102
// [SECTION] ImFontGlyphRangesBuilder
5103
//-----------------------------------------------------------------------------
5104
5105
void ImFontGlyphRangesBuilder::AddText(const char* text, const char* text_end)
5106
{
5107
if (text_end == NULL)
5108
text_end = text + strlen(text);
5109
while (text < text_end)
5110
{
5111
unsigned int c = 0;
5112
int c_len = ImTextCharFromUtf8(&c, text, text_end);
5113
text += c_len;
5114
if (c_len == 0)
5115
break;
5116
AddChar((ImWchar)c);
5117
}
5118
}
5119
5120
void ImFontGlyphRangesBuilder::AddRanges(const ImWchar* ranges)
5121
{
5122
for (; ranges[0]; ranges += 2)
5123
for (unsigned int c = ranges[0]; c <= ranges[1] && c <= IM_UNICODE_CODEPOINT_MAX; c++) //-V560
5124
AddChar((ImWchar)c);
5125
}
5126
5127
void ImFontGlyphRangesBuilder::BuildRanges(ImVector<ImWchar>* out_ranges)
5128
{
5129
const int max_codepoint = IM_UNICODE_CODEPOINT_MAX;
5130
for (int n = 0; n <= max_codepoint; n++)
5131
if (GetBit(n))
5132
{
5133
out_ranges->push_back((ImWchar)n);
5134
while (n < max_codepoint && GetBit(n + 1))
5135
n++;
5136
out_ranges->push_back((ImWchar)n);
5137
}
5138
out_ranges->push_back(0);
5139
}
5140
5141
//-----------------------------------------------------------------------------
5142
// [SECTION] ImFontBaked, ImFont
5143
//-----------------------------------------------------------------------------
5144
5145
ImFontBaked::ImFontBaked()
5146
{
5147
memset(this, 0, sizeof(*this));
5148
FallbackGlyphIndex = -1;
5149
}
5150
5151
void ImFontBaked::ClearOutputData()
5152
{
5153
FallbackAdvanceX = 0.0f;
5154
Glyphs.clear();
5155
IndexAdvanceX.clear();
5156
IndexLookup.clear();
5157
FallbackGlyphIndex = -1;
5158
Ascent = Descent = 0.0f;
5159
MetricsTotalSurface = 0;
5160
}
5161
5162
ImFont::ImFont()
5163
{
5164
memset(this, 0, sizeof(*this));
5165
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
5166
Scale = 1.0f;
5167
#endif
5168
}
5169
5170
ImFont::~ImFont()
5171
{
5172
ClearOutputData();
5173
}
5174
5175
void ImFont::ClearOutputData()
5176
{
5177
if (ImFontAtlas* atlas = OwnerAtlas)
5178
ImFontAtlasFontDiscardBakes(atlas, this, 0);
5179
//FallbackChar = EllipsisChar = 0;
5180
memset(Used8kPagesMap, 0, sizeof(Used8kPagesMap));
5181
LastBaked = NULL;
5182
}
5183
5184
// API is designed this way to avoid exposing the 8K page size
5185
// e.g. use with IsGlyphRangeUnused(0, 255)
5186
bool ImFont::IsGlyphRangeUnused(unsigned int c_begin, unsigned int c_last)
5187
{
5188
unsigned int page_begin = (c_begin / 8192);
5189
unsigned int page_last = (c_last / 8192);
5190
for (unsigned int page_n = page_begin; page_n <= page_last; page_n++)
5191
if ((page_n >> 3) < sizeof(Used8kPagesMap))
5192
if (Used8kPagesMap[page_n >> 3] & (1 << (page_n & 7)))
5193
return false;
5194
return true;
5195
}
5196
5197
// x0/y0/x1/y1 are offset from the character upper-left layout position, in pixels. Therefore x0/y0 are often fairly close to zero.
5198
// Not to be mistaken with texture coordinates, which are held by u0/v0/u1/v1 in normalized format (0.0..1.0 on each texture axis).
5199
// - 'src' is not necessarily == 'this->Sources' because multiple source fonts+configs can be used to build one target font.
5200
ImFontGlyph* ImFontAtlasBakedAddFontGlyph(ImFontAtlas* atlas, ImFontBaked* baked, ImFontConfig* src, const ImFontGlyph* in_glyph)
5201
{
5202
int glyph_idx = baked->Glyphs.Size;
5203
baked->Glyphs.push_back(*in_glyph);
5204
ImFontGlyph* glyph = &baked->Glyphs[glyph_idx];
5205
IM_ASSERT(baked->Glyphs.Size < 0xFFFE); // IndexLookup[] hold 16-bit values and -1/-2 are reserved.
5206
5207
// Set UV from packed rectangle
5208
if (glyph->PackId != ImFontAtlasRectId_Invalid)
5209
{
5210
ImTextureRect* r = ImFontAtlasPackGetRect(atlas, glyph->PackId);
5211
IM_ASSERT(glyph->U0 == 0.0f && glyph->V0 == 0.0f && glyph->U1 == 0.0f && glyph->V1 == 0.0f);
5212
glyph->U0 = (r->x) * atlas->TexUvScale.x;
5213
glyph->V0 = (r->y) * atlas->TexUvScale.y;
5214
glyph->U1 = (r->x + r->w) * atlas->TexUvScale.x;
5215
glyph->V1 = (r->y + r->h) * atlas->TexUvScale.y;
5216
baked->MetricsTotalSurface += r->w * r->h;
5217
}
5218
5219
if (src != NULL)
5220
{
5221
// Clamp & recenter if needed
5222
const float ref_size = baked->OwnerFont->Sources[0]->SizePixels;
5223
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
5224
float advance_x = ImClamp(glyph->AdvanceX, src->GlyphMinAdvanceX * offsets_scale, src->GlyphMaxAdvanceX * offsets_scale);
5225
if (advance_x != glyph->AdvanceX)
5226
{
5227
float char_off_x = src->PixelSnapH ? ImTrunc((advance_x - glyph->AdvanceX) * 0.5f) : (advance_x - glyph->AdvanceX) * 0.5f;
5228
glyph->X0 += char_off_x;
5229
glyph->X1 += char_off_x;
5230
}
5231
5232
// Snap to pixel
5233
if (src->PixelSnapH)
5234
advance_x = IM_ROUND(advance_x);
5235
5236
// Bake spacing
5237
glyph->AdvanceX = advance_x + src->GlyphExtraAdvanceX;
5238
}
5239
if (glyph->Colored)
5240
atlas->TexPixelsUseColors = atlas->TexData->UseColors = true;
5241
5242
// Update lookup tables
5243
const int codepoint = glyph->Codepoint;
5244
ImFontBaked_BuildGrowIndex(baked, codepoint + 1);
5245
baked->IndexAdvanceX[codepoint] = glyph->AdvanceX;
5246
baked->IndexLookup[codepoint] = (ImU16)glyph_idx;
5247
const int page_n = codepoint / 8192;
5248
baked->OwnerFont->Used8kPagesMap[page_n >> 3] |= 1 << (page_n & 7);
5249
5250
return glyph;
5251
}
5252
5253
// FIXME: Code is duplicated with code above.
5254
void ImFontAtlasBakedAddFontGlyphAdvancedX(ImFontAtlas* atlas, ImFontBaked* baked, ImFontConfig* src, ImWchar codepoint, float advance_x)
5255
{
5256
IM_UNUSED(atlas);
5257
if (src != NULL)
5258
{
5259
// Clamp & recenter if needed
5260
const float ref_size = baked->OwnerFont->Sources[0]->SizePixels;
5261
const float offsets_scale = (ref_size != 0.0f) ? (baked->Size / ref_size) : 1.0f;
5262
advance_x = ImClamp(advance_x, src->GlyphMinAdvanceX * offsets_scale, src->GlyphMaxAdvanceX * offsets_scale);
5263
5264
// Snap to pixel
5265
if (src->PixelSnapH)
5266
advance_x = IM_ROUND(advance_x);
5267
5268
// Bake spacing
5269
advance_x += src->GlyphExtraAdvanceX;
5270
}
5271
5272
ImFontBaked_BuildGrowIndex(baked, codepoint + 1);
5273
baked->IndexAdvanceX[codepoint] = advance_x;
5274
}
5275
5276
// Copy to texture, post-process and queue update for backend
5277
void ImFontAtlasBakedSetFontGlyphBitmap(ImFontAtlas* atlas, ImFontBaked* baked, ImFontConfig* src, ImFontGlyph* glyph, ImTextureRect* r, const unsigned char* src_pixels, ImTextureFormat src_fmt, int src_pitch)
5278
{
5279
ImTextureData* tex = atlas->TexData;
5280
IM_ASSERT(r->x + r->w <= tex->Width && r->y + r->h <= tex->Height);
5281
ImFontAtlasTextureBlockConvert(src_pixels, src_fmt, src_pitch, (unsigned char*)tex->GetPixelsAt(r->x, r->y), tex->Format, tex->GetPitch(), r->w, r->h);
5282
ImFontAtlasPostProcessData pp_data = { atlas, baked->OwnerFont, src, baked, glyph, tex->GetPixelsAt(r->x, r->y), tex->Format, tex->GetPitch(), r->w, r->h };
5283
ImFontAtlasTextureBlockPostProcess(&pp_data);
5284
ImFontAtlasTextureBlockQueueUpload(atlas, tex, r->x, r->y, r->w, r->h);
5285
}
5286
5287
void ImFont::AddRemapChar(ImWchar from_codepoint, ImWchar to_codepoint)
5288
{
5289
RemapPairs.SetInt((ImGuiID)from_codepoint, (int)to_codepoint);
5290
}
5291
5292
// Find glyph, load if necessary, return fallback if missing
5293
ImFontGlyph* ImFontBaked::FindGlyph(ImWchar c)
5294
{
5295
if (c < (size_t)IndexLookup.Size) IM_LIKELY
5296
{
5297
const int i = (int)IndexLookup.Data[c];
5298
if (i == IM_FONTGLYPH_INDEX_NOT_FOUND)
5299
return &Glyphs.Data[FallbackGlyphIndex];
5300
if (i != IM_FONTGLYPH_INDEX_UNUSED)
5301
return &Glyphs.Data[i];
5302
}
5303
ImFontGlyph* glyph = ImFontBaked_BuildLoadGlyph(this, c, NULL);
5304
return glyph ? glyph : &Glyphs.Data[FallbackGlyphIndex];
5305
}
5306
5307
// Attempt to load but when missing, return NULL instead of FallbackGlyph
5308
ImFontGlyph* ImFontBaked::FindGlyphNoFallback(ImWchar c)
5309
{
5310
if (c < (size_t)IndexLookup.Size) IM_LIKELY
5311
{
5312
const int i = (int)IndexLookup.Data[c];
5313
if (i == IM_FONTGLYPH_INDEX_NOT_FOUND)
5314
return NULL;
5315
if (i != IM_FONTGLYPH_INDEX_UNUSED)
5316
return &Glyphs.Data[i];
5317
}
5318
LoadNoFallback = true; // This is actually a rare call, not done in hot-loop, so we prioritize not adding extra cruft to ImFontBaked_BuildLoadGlyph() call sites.
5319
ImFontGlyph* glyph = ImFontBaked_BuildLoadGlyph(this, c, NULL);
5320
LoadNoFallback = false;
5321
return glyph;
5322
}
5323
5324
bool ImFontBaked::IsGlyphLoaded(ImWchar c)
5325
{
5326
if (c < (size_t)IndexLookup.Size) IM_LIKELY
5327
{
5328
const int i = (int)IndexLookup.Data[c];
5329
if (i == IM_FONTGLYPH_INDEX_NOT_FOUND)
5330
return false;
5331
if (i != IM_FONTGLYPH_INDEX_UNUSED)
5332
return true;
5333
}
5334
return false;
5335
}
5336
5337
// This is not fast query
5338
bool ImFont::IsGlyphInFont(ImWchar c)
5339
{
5340
ImFontAtlas* atlas = OwnerAtlas;
5341
c = ImFontAtlas_FontHookRemapCodepoint(atlas, this, c);
5342
for (ImFontConfig* src : Sources)
5343
{
5344
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
5345
if (loader->FontSrcContainsGlyph != NULL && loader->FontSrcContainsGlyph(atlas, src, c))
5346
return true;
5347
}
5348
return false;
5349
}
5350
5351
// This is manually inlined in CalcTextSizeA() and CalcWordWrapPosition(), with a non-inline call to BuildLoadGlyphGetAdvanceOrFallback().
5352
IM_MSVC_RUNTIME_CHECKS_OFF
5353
float ImFontBaked::GetCharAdvance(ImWchar c)
5354
{
5355
if ((int)c < IndexAdvanceX.Size)
5356
{
5357
// Missing glyphs fitting inside index will have stored FallbackAdvanceX already.
5358
const float x = IndexAdvanceX.Data[c];
5359
if (x >= 0.0f)
5360
return x;
5361
}
5362
return ImFontBaked_BuildLoadGlyphAdvanceX(this, c);
5363
}
5364
IM_MSVC_RUNTIME_CHECKS_RESTORE
5365
5366
ImGuiID ImFontAtlasBakedGetId(ImGuiID font_id, float baked_size, float baked_weight, float rasterizer_density)
5367
{
5368
struct { ImGuiID FontId; float BakedSize; float BakedWeight; float RasterizerDensity; } hashed_data;
5369
hashed_data.FontId = font_id;
5370
hashed_data.BakedSize = baked_size;
5371
hashed_data.BakedWeight = baked_weight;
5372
hashed_data.RasterizerDensity = rasterizer_density;
5373
return ImHashData(&hashed_data, sizeof(hashed_data));
5374
}
5375
5376
// ImFontBaked pointers are valid for the entire frame but shall never be kept between frames.
5377
ImFontBaked* ImFont::GetFontBaked(float size, float font_weight, float density)
5378
{
5379
ImFontBaked* baked = LastBaked;
5380
5381
// Round font size
5382
// - ImGui::PushFont() will already round, but other paths calling GetFontBaked() directly also needs it (e.g. ImFontAtlasBuildPreloadAllGlyphRanges)
5383
size = ImGui::GetRoundedFontSize(size);
5384
font_weight = (font_weight > 0.0f) ? font_weight : DefaultWeight;
5385
5386
if (density < 0.0f)
5387
density = CurrentRasterizerDensity;
5388
if (baked && baked->Size == size && baked->Weight == font_weight && baked->RasterizerDensity == density)
5389
return baked;
5390
5391
ImFontAtlas* atlas = OwnerAtlas;
5392
ImFontAtlasBuilder* builder = atlas->Builder;
5393
baked = ImFontAtlasBakedGetOrAdd(atlas, this, size, font_weight, density);
5394
if (baked == NULL)
5395
return NULL;
5396
baked->LastUsedFrame = builder->FrameCount;
5397
LastBaked = baked;
5398
return baked;
5399
}
5400
5401
ImFontBaked* ImFontAtlasBakedGetOrAdd(ImFontAtlas* atlas, ImFont* font, float font_size, float font_weight, float font_rasterizer_density)
5402
{
5403
// FIXME-NEWATLAS: Design for picking a nearest size based on some criteria?
5404
// FIXME-NEWATLAS: Altering font density won't work right away.
5405
IM_ASSERT(font_size > 0.0f && font_rasterizer_density > 0.0f);
5406
ImGuiID baked_id = ImFontAtlasBakedGetId(font->FontId, font_size, font_weight, font_rasterizer_density);
5407
ImFontAtlasBuilder* builder = atlas->Builder;
5408
ImFontBaked** p_baked_in_map = (ImFontBaked**)builder->BakedMap.GetVoidPtrRef(baked_id);
5409
ImFontBaked* baked = *p_baked_in_map;
5410
if (baked != NULL)
5411
{
5412
IM_ASSERT(baked->Size == font_size && baked->Weight == font_weight && baked->OwnerFont == font && baked->BakedId == baked_id);
5413
return baked;
5414
}
5415
5416
// If atlas is locked, find closest match
5417
// FIXME-OPT: This is not an optimal query.
5418
if ((font->Flags & ImFontFlags_LockBakedSizes) || atlas->Locked)
5419
{
5420
baked = ImFontAtlasBakedGetClosestMatch(atlas, font, font_size, font_weight, font_rasterizer_density);
5421
if (baked != NULL)
5422
return baked;
5423
if (atlas->Locked)
5424
{
5425
IM_ASSERT(!atlas->Locked && "Cannot use dynamic font size with a locked ImFontAtlas!"); // Locked because rendering backend does not support ImGuiBackendFlags_RendererHasTextures!
5426
return NULL;
5427
}
5428
}
5429
5430
// Create new
5431
baked = ImFontAtlasBakedAdd(atlas, font, font_size, font_weight, font_rasterizer_density, baked_id);
5432
*p_baked_in_map = baked; // To avoid 'builder->BakedMap.SetVoidPtr(baked_id, baked);' while we can.
5433
return baked;
5434
}
5435
5436
// Trim trailing space and find beginning of next line
5437
const char* ImTextCalcWordWrapNextLineStart(const char* text, const char* text_end, ImDrawTextFlags flags)
5438
{
5439
if ((flags & ImDrawTextFlags_WrapKeepBlanks) == 0)
5440
while (text < text_end && ImCharIsBlankA(*text))
5441
text++;
5442
if (text < text_end && *text == '\n')
5443
text++;
5444
return text;
5445
}
5446
5447
void ImTextClassifierClear(ImU32* bits, unsigned int codepoint_min, unsigned int codepoint_end, ImWcharClass char_class)
5448
{
5449
for (unsigned int c = codepoint_min; c < codepoint_end; c++)
5450
ImTextClassifierSetCharClass(bits, codepoint_min, codepoint_end, char_class, c);
5451
}
5452
5453
void ImTextClassifierSetCharClass(ImU32* bits, unsigned int codepoint_min, unsigned int codepoint_end, ImWcharClass char_class, unsigned int c)
5454
{
5455
IM_ASSERT(c >= codepoint_min && c < codepoint_end);
5456
IM_UNUSED(codepoint_end);
5457
c -= codepoint_min;
5458
const ImU32 shift = (c & 15) << 1;
5459
bits[c >> 4] = (bits[c >> 4] & ~(0x03 << shift)) | (char_class << shift);
5460
}
5461
5462
void ImTextClassifierSetCharClassFromStr(ImU32* bits, unsigned int codepoint_min, unsigned int codepoint_end, ImWcharClass char_class, const char* s)
5463
{
5464
const char* s_end = s + strlen(s);
5465
while (*s)
5466
{
5467
unsigned int c;
5468
s += ImTextCharFromUtf8(&c, s, s_end);
5469
ImTextClassifierSetCharClass(bits, codepoint_min, codepoint_end, char_class, c);
5470
}
5471
}
5472
5473
#define ImTextClassifierGet(_BITS, _CHAR_OFFSET) ((_BITS[(_CHAR_OFFSET) >> 4] >> (((_CHAR_OFFSET) & 15) << 1)) & 0x03)
5474
5475
// 2-bit per character
5476
static ImU32 g_CharClassifierIsSeparator_0000_007f[128 / 16] = {};
5477
static ImU32 g_CharClassifierIsSeparator_3000_300f[ 16 / 16] = {};
5478
5479
void ImTextInitClassifiers()
5480
{
5481
if (ImTextClassifierGet(g_CharClassifierIsSeparator_0000_007f, ',') != 0)
5482
return;
5483
5484
// List of hardcoded separators: .,;!?'"
5485
// Making this dynamic given known ranges is trivial BUT requires us to standardize where you pass them as parameters. (#3002, #8503)
5486
ImTextClassifierClear(g_CharClassifierIsSeparator_0000_007f, 0, 128, ImWcharClass_Other);
5487
ImTextClassifierSetCharClassFromStr(g_CharClassifierIsSeparator_0000_007f, 0, 128, ImWcharClass_Blank, " \t");
5488
ImTextClassifierSetCharClassFromStr(g_CharClassifierIsSeparator_0000_007f, 0, 128, ImWcharClass_Punct, ".,;!?\"");
5489
5490
ImTextClassifierClear(g_CharClassifierIsSeparator_3000_300f, 0x3000, 0x300F, ImWcharClass_Other);
5491
ImTextClassifierSetCharClass(g_CharClassifierIsSeparator_3000_300f, 0x3000, 0x300F, ImWcharClass_Blank, 0x3000);
5492
ImTextClassifierSetCharClass(g_CharClassifierIsSeparator_3000_300f, 0x3000, 0x300F, ImWcharClass_Punct, 0x3001);
5493
ImTextClassifierSetCharClass(g_CharClassifierIsSeparator_3000_300f, 0x3000, 0x300F, ImWcharClass_Punct, 0x3002);
5494
}
5495
5496
// Simple word-wrapping for English, not full-featured. Please submit failing cases!
5497
// This will return the next location to wrap from. If no wrapping if necessary, this will fast-forward to e.g. text_end.
5498
// Refer to imgui_test_suite's "drawlist_text_wordwrap_1" for tests.
5499
const char* ImFontCalcWordWrapPositionEx(ImFont* font, float size, float weight, const char* text, const char* text_end, float wrap_width, ImDrawTextFlags flags)
5500
{
5501
// For references, possible wrap point marked with ^
5502
// "aaa bbb, ccc,ddd. eee fff. ggg!"
5503
// ^ ^ ^ ^ ^__ ^ ^
5504
5505
// Skip extra blanks after a line returns (that includes not counting them in width computation)
5506
// e.g. "Hello world" --> "Hello" "World"
5507
5508
// Cut words that cannot possibly fit within one line.
5509
// e.g.: "The tropical fish" with ~5 characters worth of width --> "The tr" "opical" "fish"
5510
5511
ImFontBaked* baked = font->GetFontBaked(size, weight);
5512
const float scale = size / baked->Size;
5513
5514
float line_width = 0.0f;
5515
float blank_width = 0.0f;
5516
wrap_width /= scale; // We work with unscaled widths to avoid scaling every characters
5517
5518
const char* s = text;
5519
IM_ASSERT(text_end != NULL);
5520
5521
int prev_type = ImWcharClass_Other;
5522
const bool keep_blanks = (flags & ImDrawTextFlags_WrapKeepBlanks) != 0;
5523
5524
// Find next wrapping point
5525
//const char* span_begin = s;
5526
const char* span_end = s;
5527
float span_width = 0.0f;
5528
5529
while (s < text_end)
5530
{
5531
unsigned int c = (unsigned int)*s;
5532
const char* next_s;
5533
if (c < 0x80)
5534
next_s = s + 1;
5535
else
5536
next_s = s + ImTextCharFromUtf8(&c, s, text_end);
5537
5538
if (c < 32)
5539
{
5540
if (c == '\n')
5541
return s; // Direct return, skip "Wrap_width is too small to fit anything" path.
5542
if (c == '\r')
5543
{
5544
s = next_s; // Fast-skip
5545
continue;
5546
}
5547
}
5548
5549
// Optimized inline version of 'float char_width = GetCharAdvance((ImWchar)c);'
5550
float char_width = (c < (unsigned int)baked->IndexAdvanceX.Size) ? baked->IndexAdvanceX.Data[c] : -1.0f;
5551
if (char_width < 0.0f)
5552
char_width = BuildLoadGlyphGetAdvanceOrFallback(baked, c);
5553
5554
// Classify current character
5555
int curr_type;
5556
if (c < 128)
5557
curr_type = ImTextClassifierGet(g_CharClassifierIsSeparator_0000_007f, c);
5558
else if (c >= 0x3000 && c < 0x3010)
5559
curr_type = ImTextClassifierGet(g_CharClassifierIsSeparator_3000_300f, c & 15); //-V578
5560
else
5561
curr_type = ImWcharClass_Other;
5562
5563
if (curr_type == ImWcharClass_Blank)
5564
{
5565
// End span: 'A ' or '. '
5566
if (prev_type != ImWcharClass_Blank && !keep_blanks)
5567
{
5568
span_end = s;
5569
line_width += span_width;
5570
span_width = 0.0f;
5571
}
5572
blank_width += char_width;
5573
}
5574
else
5575
{
5576
// End span: '.X' unless X is a digit
5577
if (prev_type == ImWcharClass_Punct && curr_type != ImWcharClass_Punct && !(c >= '0' && c <= '9')) // FIXME: Digit checks might be removed if allow custom separators (#8503)
5578
{
5579
span_end = s;
5580
line_width += span_width + blank_width;
5581
span_width = blank_width = 0.0f;
5582
}
5583
// End span: 'A ' or '. '
5584
else if (prev_type == ImWcharClass_Blank && keep_blanks)
5585
{
5586
span_end = s;
5587
line_width += span_width + blank_width;
5588
span_width = blank_width = 0.0f;
5589
}
5590
span_width += char_width;
5591
}
5592
5593
if (span_width + blank_width + line_width > wrap_width)
5594
{
5595
if (span_width + blank_width > wrap_width)
5596
break;
5597
// FIXME: Narrow wrapping e.g. "A quick brown" -> "Quic|k br|own", would require knowing if span is going to be longer than wrap_width.
5598
//if (span_width > wrap_width && !is_blank && !was_blank)
5599
// return s;
5600
return span_end;
5601
}
5602
5603
prev_type = curr_type;
5604
s = next_s;
5605
}
5606
5607
// Wrap_width is too small to fit anything. Force displaying 1 character to minimize the height discontinuity.
5608
// +1 may not be a character start point in UTF-8 but it's ok because caller loops use (text >= word_wrap_eol).
5609
if (s == text && text < text_end)
5610
return s + ImTextCountUtf8BytesFromChar(s, text_end);
5611
return s;
5612
}
5613
5614
const char* ImFont::CalcWordWrapPosition(float size, float weight, const char* text, const char* text_end, float wrap_width)
5615
{
5616
return ImFontCalcWordWrapPositionEx(this, size, weight, text, text_end, wrap_width, ImDrawTextFlags_None);
5617
}
5618
5619
ImVec2 ImFontCalcTextSizeEx(ImFont* font, float size, float weight, float max_width, float wrap_width, const char* text_begin, const char* text_end_display, const char* text_end, const char** out_remaining, ImVec2* out_offset, ImDrawTextFlags flags)
5620
{
5621
if (!text_end)
5622
text_end = text_begin + ImStrlen(text_begin); // FIXME-OPT: Need to avoid this.
5623
if (!text_end_display)
5624
text_end_display = text_end;
5625
5626
ImFontBaked* baked = font->GetFontBaked(size, weight);
5627
const float line_height = size;
5628
const float scale = line_height / baked->Size;
5629
5630
ImVec2 text_size = ImVec2(0, 0);
5631
float line_width = 0.0f;
5632
5633
const bool word_wrap_enabled = (wrap_width > 0.0f);
5634
const char* word_wrap_eol = NULL;
5635
5636
const char* s = text_begin;
5637
while (s < text_end_display)
5638
{
5639
// Word-wrapping
5640
if (word_wrap_enabled)
5641
{
5642
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
5643
if (!word_wrap_eol)
5644
word_wrap_eol = ImFontCalcWordWrapPositionEx(font, size, weight, s, text_end, wrap_width - line_width, flags);
5645
5646
if (s >= word_wrap_eol)
5647
{
5648
if (text_size.x < line_width)
5649
text_size.x = line_width;
5650
text_size.y += line_height;
5651
line_width = 0.0f;
5652
s = ImTextCalcWordWrapNextLineStart(s, text_end, flags); // Wrapping skips upcoming blanks
5653
if (flags & ImDrawTextFlags_StopOnNewLine)
5654
break;
5655
word_wrap_eol = NULL;
5656
continue;
5657
}
5658
}
5659
5660
// Decode and advance source
5661
const char* prev_s = s;
5662
unsigned int c = (unsigned int)*s;
5663
if (c < 0x80)
5664
s += 1;
5665
else
5666
s += ImTextCharFromUtf8(&c, s, text_end);
5667
5668
if (c == '\n')
5669
{
5670
text_size.x = ImMax(text_size.x, line_width);
5671
text_size.y += line_height;
5672
line_width = 0.0f;
5673
if (flags & ImDrawTextFlags_StopOnNewLine)
5674
break;
5675
continue;
5676
}
5677
if (c == '\r')
5678
continue;
5679
5680
// Optimized inline version of 'float char_width = GetCharAdvance((ImWchar)c);'
5681
float char_width = (c < (unsigned int)baked->IndexAdvanceX.Size) ? baked->IndexAdvanceX.Data[c] : -1.0f;
5682
if (char_width < 0.0f)
5683
char_width = BuildLoadGlyphGetAdvanceOrFallback(baked, c);
5684
char_width *= scale;
5685
5686
if (line_width + char_width >= max_width)
5687
{
5688
s = prev_s;
5689
break;
5690
}
5691
5692
line_width += char_width;
5693
}
5694
5695
if (text_size.x < line_width)
5696
text_size.x = line_width;
5697
5698
if (out_offset != NULL)
5699
*out_offset = ImVec2(line_width, text_size.y + line_height); // offset allow for the possibility of sitting after a trailing \n
5700
5701
if (line_width > 0 || text_size.y == 0.0f) // whereas size.y will ignore the trailing \n
5702
text_size.y += line_height;
5703
5704
if (out_remaining != NULL)
5705
*out_remaining = s;
5706
5707
return text_size;
5708
}
5709
5710
ImVec2 ImFont::CalcTextSizeA(float size, float weight, float max_width, float wrap_width, const char* text_begin, const char* text_end, const char** out_remaining)
5711
{
5712
return ImFontCalcTextSizeEx(this, size, weight, max_width, wrap_width, text_begin, text_end, text_end, out_remaining, NULL, ImDrawTextFlags_None);
5713
}
5714
5715
// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound.
5716
void ImFont::RenderChar(ImDrawList* draw_list, float size, float weight, const ImVec2& pos, ImU32 col, ImWchar c, const ImVec4* cpu_fine_clip)
5717
{
5718
ImFontBaked* baked = GetFontBaked(size, weight);
5719
const ImFontGlyph* glyph = baked->FindGlyph(c);
5720
if (!glyph || !glyph->Visible)
5721
return;
5722
if (glyph->Colored)
5723
col |= ~IM_COL32_A_MASK;
5724
float scale = (size >= 0.0f) ? (size / baked->Size) : 1.0f;
5725
float x = IM_TRUNC(pos.x);
5726
float y = IM_TRUNC(pos.y);
5727
5728
float x1 = x + glyph->X0 * scale;
5729
float x2 = x + glyph->X1 * scale;
5730
if (cpu_fine_clip && (x1 > cpu_fine_clip->z || x2 < cpu_fine_clip->x))
5731
return;
5732
float y1 = y + glyph->Y0 * scale;
5733
float y2 = y + glyph->Y1 * scale;
5734
float u1 = glyph->U0;
5735
float v1 = glyph->V0;
5736
float u2 = glyph->U1;
5737
float v2 = glyph->V1;
5738
5739
// Always CPU fine clip. Code extracted from RenderText().
5740
// CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads.
5741
if (cpu_fine_clip != NULL)
5742
{
5743
if (x1 < cpu_fine_clip->x) { u1 = u1 + (1.0f - (x2 - cpu_fine_clip->x) / (x2 - x1)) * (u2 - u1); x1 = cpu_fine_clip->x; }
5744
if (y1 < cpu_fine_clip->y) { v1 = v1 + (1.0f - (y2 - cpu_fine_clip->y) / (y2 - y1)) * (v2 - v1); y1 = cpu_fine_clip->y; }
5745
if (x2 > cpu_fine_clip->z) { u2 = u1 + ((cpu_fine_clip->z - x1) / (x2 - x1)) * (u2 - u1); x2 = cpu_fine_clip->z; }
5746
if (y2 > cpu_fine_clip->w) { v2 = v1 + ((cpu_fine_clip->w - y1) / (y2 - y1)) * (v2 - v1); y2 = cpu_fine_clip->w; }
5747
if (y1 >= y2)
5748
return;
5749
}
5750
draw_list->PrimReserve(6, 4);
5751
draw_list->PrimRectUV(ImVec2(x1, y1), ImVec2(x2, y2), ImVec2(u1, v1), ImVec2(u2, v2), col);
5752
}
5753
5754
// Note: as with every ImDrawList drawing function, this expects that the font atlas texture is bound.
5755
// DO NOT CALL DIRECTLY THIS WILL CHANGE WILDLY IN 2026. Use ImDrawList::AddText().
5756
void ImFont::RenderText(ImDrawList* draw_list, float size, float weight, const ImVec2& pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, ImDrawTextFlags flags)
5757
{
5758
// Align to be pixel perfect
5759
begin:
5760
float x = IM_TRUNC(pos.x);
5761
float y = IM_TRUNC(pos.y);
5762
if (y > clip_rect.w)
5763
return;
5764
5765
if (!text_end)
5766
text_end = text_begin + ImStrlen(text_begin); // ImGui:: functions generally already provides a valid text_end, so this is merely to handle direct calls.
5767
5768
const float line_height = size;
5769
ImFontBaked* baked = GetFontBaked(size, weight);
5770
5771
const float scale = size / baked->Size;
5772
const float origin_x = x;
5773
const bool word_wrap_enabled = (wrap_width > 0.0f);
5774
5775
// Fast-forward to first visible line
5776
const char* s = text_begin;
5777
if (y + line_height < clip_rect.y)
5778
while (y + line_height < clip_rect.y && s < text_end)
5779
{
5780
const char* line_end = (const char*)ImMemchr(s, '\n', text_end - s);
5781
if (word_wrap_enabled)
5782
{
5783
// FIXME-OPT: This is not optimal as do first do a search for \n before calling CalcWordWrapPosition().
5784
// If the specs for CalcWordWrapPosition() were reworked to optionally return on \n we could combine both.
5785
// However it is still better than nothing performing the fast-forward!
5786
s = ImFontCalcWordWrapPositionEx(this, size, weight, s, line_end ? line_end : text_end, wrap_width, flags);
5787
s = ImTextCalcWordWrapNextLineStart(s, text_end, flags);
5788
}
5789
else
5790
{
5791
s = line_end ? line_end + 1 : text_end;
5792
}
5793
y += line_height;
5794
}
5795
5796
// For large text, scan for the last visible line in order to avoid over-reserving in the call to PrimReserve()
5797
// Note that very large horizontal line will still be affected by the issue (e.g. a one megabyte string buffer without a newline will likely crash atm)
5798
if (text_end - s > 10000 && !word_wrap_enabled)
5799
{
5800
const char* s_end = s;
5801
float y_end = y;
5802
while (y_end < clip_rect.w && s_end < text_end)
5803
{
5804
s_end = (const char*)ImMemchr(s_end, '\n', text_end - s_end);
5805
s_end = s_end ? s_end + 1 : text_end;
5806
y_end += line_height;
5807
}
5808
text_end = s_end;
5809
}
5810
if (s == text_end)
5811
return;
5812
5813
// Reserve vertices for remaining worse case (over-reserving is useful and easily amortized)
5814
const int vtx_count_max = (int)(text_end - s) * 4;
5815
const int idx_count_max = (int)(text_end - s) * 6;
5816
const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max;
5817
draw_list->PrimReserve(idx_count_max, vtx_count_max);
5818
ImDrawVert* vtx_write = draw_list->_VtxWritePtr;
5819
ImDrawIdx* idx_write = draw_list->_IdxWritePtr;
5820
unsigned int vtx_index = draw_list->_VtxCurrentIdx;
5821
const int cmd_count = draw_list->CmdBuffer.Size;
5822
const bool cpu_fine_clip = (flags & ImDrawTextFlags_CpuFineClip) != 0;
5823
5824
const ImU32 col_untinted = col | ~IM_COL32_A_MASK;
5825
const char* word_wrap_eol = NULL;
5826
5827
while (s < text_end)
5828
{
5829
if (word_wrap_enabled)
5830
{
5831
// Calculate how far we can render. Requires two passes on the string data but keeps the code simple and not intrusive for what's essentially an uncommon feature.
5832
if (!word_wrap_eol)
5833
word_wrap_eol = ImFontCalcWordWrapPositionEx(this, size, weight, s, text_end, wrap_width - (x - origin_x), flags);
5834
5835
if (s >= word_wrap_eol)
5836
{
5837
x = origin_x;
5838
y += line_height;
5839
if (y > clip_rect.w)
5840
break; // break out of main loop
5841
word_wrap_eol = NULL;
5842
s = ImTextCalcWordWrapNextLineStart(s, text_end, flags); // Wrapping skips upcoming blanks
5843
continue;
5844
}
5845
}
5846
5847
// Decode and advance source
5848
unsigned int c = (unsigned int)*s;
5849
if (c < 0x80)
5850
s += 1;
5851
else
5852
s += ImTextCharFromUtf8(&c, s, text_end);
5853
5854
if (c < 32)
5855
{
5856
if (c == '\n')
5857
{
5858
x = origin_x;
5859
y += line_height;
5860
if (y > clip_rect.w)
5861
break; // break out of main loop
5862
continue;
5863
}
5864
if (c == '\r')
5865
continue;
5866
}
5867
5868
const ImFontGlyph* glyph = baked->FindGlyph((ImWchar)c);
5869
//if (glyph == NULL)
5870
// continue;
5871
5872
float char_width = glyph->AdvanceX * scale;
5873
if (glyph->Visible)
5874
{
5875
// We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
5876
float x1 = x + glyph->X0 * scale;
5877
float x2 = x + glyph->X1 * scale;
5878
float y1 = y + glyph->Y0 * scale;
5879
float y2 = y + glyph->Y1 * scale;
5880
if (x1 <= clip_rect.z && x2 >= clip_rect.x)
5881
{
5882
// Render a character
5883
float u1 = glyph->U0;
5884
float v1 = glyph->V0;
5885
float u2 = glyph->U1;
5886
float v2 = glyph->V1;
5887
5888
// CPU side clipping used to fit text in their frame when the frame is too small. Only does clipping for axis aligned quads.
5889
if (cpu_fine_clip)
5890
{
5891
if (x1 < clip_rect.x)
5892
{
5893
u1 = u1 + (1.0f - (x2 - clip_rect.x) / (x2 - x1)) * (u2 - u1);
5894
x1 = clip_rect.x;
5895
}
5896
if (y1 < clip_rect.y)
5897
{
5898
v1 = v1 + (1.0f - (y2 - clip_rect.y) / (y2 - y1)) * (v2 - v1);
5899
y1 = clip_rect.y;
5900
}
5901
if (x2 > clip_rect.z)
5902
{
5903
u2 = u1 + ((clip_rect.z - x1) / (x2 - x1)) * (u2 - u1);
5904
x2 = clip_rect.z;
5905
}
5906
if (y2 > clip_rect.w)
5907
{
5908
v2 = v1 + ((clip_rect.w - y1) / (y2 - y1)) * (v2 - v1);
5909
y2 = clip_rect.w;
5910
}
5911
if (y1 >= y2)
5912
{
5913
x += char_width;
5914
continue;
5915
}
5916
}
5917
5918
// Support for untinted glyphs
5919
ImU32 glyph_col = glyph->Colored ? col_untinted : col;
5920
5921
// We are NOT calling PrimRectUV() here because non-inlined causes too much overhead in a debug builds. Inlined here:
5922
{
5923
vtx_write[0].pos.x = x1; vtx_write[0].pos.y = y1; vtx_write[0].col = glyph_col; vtx_write[0].uv.x = u1; vtx_write[0].uv.y = v1;
5924
vtx_write[1].pos.x = x2; vtx_write[1].pos.y = y1; vtx_write[1].col = glyph_col; vtx_write[1].uv.x = u2; vtx_write[1].uv.y = v1;
5925
vtx_write[2].pos.x = x2; vtx_write[2].pos.y = y2; vtx_write[2].col = glyph_col; vtx_write[2].uv.x = u2; vtx_write[2].uv.y = v2;
5926
vtx_write[3].pos.x = x1; vtx_write[3].pos.y = y2; vtx_write[3].col = glyph_col; vtx_write[3].uv.x = u1; vtx_write[3].uv.y = v2;
5927
idx_write[0] = (ImDrawIdx)(vtx_index); idx_write[1] = (ImDrawIdx)(vtx_index + 1); idx_write[2] = (ImDrawIdx)(vtx_index + 2);
5928
idx_write[3] = (ImDrawIdx)(vtx_index); idx_write[4] = (ImDrawIdx)(vtx_index + 2); idx_write[5] = (ImDrawIdx)(vtx_index + 3);
5929
vtx_write += 4;
5930
vtx_index += 4;
5931
idx_write += 6;
5932
}
5933
}
5934
}
5935
x += char_width;
5936
}
5937
5938
// Edge case: calling RenderText() with unloaded glyphs triggering texture change. It doesn't happen via ImGui:: calls because CalcTextSize() is always used.
5939
if (cmd_count != draw_list->CmdBuffer.Size) //-V547
5940
{
5941
IM_ASSERT(draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 1].ElemCount == 0);
5942
draw_list->CmdBuffer.pop_back();
5943
draw_list->PrimUnreserve(idx_count_max, vtx_count_max);
5944
draw_list->AddDrawCmd();
5945
//IMGUI_DEBUG_LOG("RenderText: cancel and retry to missing glyphs.\n"); // [DEBUG]
5946
//draw_list->AddRectFilled(pos, pos + ImVec2(10, 10), IM_COL32(255, 0, 0, 255)); // [DEBUG]
5947
goto begin;
5948
//RenderText(draw_list, size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip); // FIXME-OPT: Would a 'goto begin' be better for code-gen?
5949
//return;
5950
}
5951
5952
// Give back unused vertices (clipped ones, blanks) ~ this is essentially a PrimUnreserve() action.
5953
draw_list->VtxBuffer.Size = (int)(vtx_write - draw_list->VtxBuffer.Data); // Same as calling shrink()
5954
draw_list->IdxBuffer.Size = (int)(idx_write - draw_list->IdxBuffer.Data);
5955
draw_list->CmdBuffer[draw_list->CmdBuffer.Size - 1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
5956
draw_list->_VtxWritePtr = vtx_write;
5957
draw_list->_IdxWritePtr = idx_write;
5958
draw_list->_VtxCurrentIdx = vtx_index;
5959
}
5960
5961
//-----------------------------------------------------------------------------
5962
// [SECTION] ImGui Internal Render Helpers
5963
//-----------------------------------------------------------------------------
5964
// Vaguely redesigned to stop accessing ImGui global state:
5965
// - RenderArrow()
5966
// - RenderBullet()
5967
// - RenderCheckMark()
5968
// - RenderArrowPointingAt()
5969
// - RenderRectFilledInRangeH()
5970
// - RenderRectFilledWithHole()
5971
//-----------------------------------------------------------------------------
5972
// Function in need of a redesign (legacy mess)
5973
// - RenderColorRectWithAlphaCheckerboard()
5974
//-----------------------------------------------------------------------------
5975
5976
// Render an arrow aimed to be aligned with text (p_min is a position in the same space text would be positioned). To e.g. denote expanded/collapsed state
5977
void ImGui::RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImU32 col, ImGuiDir dir, float scale)
5978
{
5979
const float h = draw_list->_Data->FontSize * 1.00f;
5980
float r = h * 0.40f * scale;
5981
ImVec2 center = pos + ImVec2(h * 0.50f, h * 0.50f * scale);
5982
5983
ImVec2 a, b, c;
5984
switch (dir)
5985
{
5986
case ImGuiDir_Up:
5987
case ImGuiDir_Down:
5988
if (dir == ImGuiDir_Up) r = -r;
5989
a = ImVec2(+0.000f, +0.750f) * r;
5990
b = ImVec2(-0.866f, -0.750f) * r;
5991
c = ImVec2(+0.866f, -0.750f) * r;
5992
break;
5993
case ImGuiDir_Left:
5994
case ImGuiDir_Right:
5995
if (dir == ImGuiDir_Left) r = -r;
5996
a = ImVec2(+0.750f, +0.000f) * r;
5997
b = ImVec2(-0.750f, +0.866f) * r;
5998
c = ImVec2(-0.750f, -0.866f) * r;
5999
break;
6000
case ImGuiDir_None:
6001
case ImGuiDir_COUNT:
6002
IM_ASSERT(0);
6003
break;
6004
}
6005
draw_list->AddTriangleFilled(center + a, center + b, center + c, col);
6006
}
6007
6008
void ImGui::RenderBullet(ImDrawList* draw_list, ImVec2 pos, ImU32 col)
6009
{
6010
// FIXME-OPT: This should be baked in font now that it's easier.
6011
float font_size = draw_list->_Data->FontSize;
6012
draw_list->AddCircleFilled(pos, font_size * 0.20f, col, (font_size < 22) ? 8 : (font_size < 40) ? 12 : 0); // Hardcode optimal/nice tessellation threshold
6013
}
6014
6015
void ImGui::RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz)
6016
{
6017
float thickness = ImMax(sz / 5.0f, 1.0f);
6018
sz -= thickness * 0.5f;
6019
pos += ImVec2(thickness * 0.25f, thickness * 0.25f);
6020
6021
float third = sz / 3.0f;
6022
float bx = pos.x + third;
6023
float by = pos.y + sz - third * 0.5f;
6024
draw_list->PathLineTo(ImVec2(bx - third, by - third));
6025
draw_list->PathLineTo(ImVec2(bx, by));
6026
draw_list->PathLineTo(ImVec2(bx + third * 2.0f, by - third * 2.0f));
6027
draw_list->PathStroke(col, 0, thickness);
6028
}
6029
6030
// Render an arrow. 'pos' is position of the arrow tip. half_sz.x is length from base to tip. half_sz.y is length on each side.
6031
void ImGui::RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col)
6032
{
6033
switch (direction)
6034
{
6035
case ImGuiDir_Left: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), pos, col); return;
6036
case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return;
6037
case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return;
6038
case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return;
6039
case ImGuiDir_None: case ImGuiDir_COUNT: break; // Fix warnings
6040
}
6041
}
6042
6043
static inline float ImAcos01(float x)
6044
{
6045
if (x <= 0.0f) return IM_PI * 0.5f;
6046
if (x >= 1.0f) return 0.0f;
6047
return ImAcos(x);
6048
//return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do.
6049
}
6050
6051
// FIXME: Cleanup and move code to ImDrawList.
6052
// - Before 2025-12-04: RenderRectFilledRangeH() with 'float x_start_norm, float x_end_norm` <- normalized
6053
// - After 2025-12-04: RenderRectFilledInRangeH() with 'float x1, float x2' <- absolute coords!!
6054
void ImGui::RenderRectFilledInRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float fill_x0, float fill_x1, float rounding)
6055
{
6056
if (fill_x0 > fill_x1)
6057
return;
6058
6059
ImVec2 p0 = ImVec2(fill_x0, rect.Min.y);
6060
ImVec2 p1 = ImVec2(fill_x1, rect.Max.y);
6061
if (rounding == 0.0f)
6062
{
6063
draw_list->AddRectFilled(p0, p1, col, 0.0f);
6064
return;
6065
}
6066
6067
rounding = ImClamp(ImMin((rect.Max.x - rect.Min.x) * 0.5f, (rect.Max.y - rect.Min.y) * 0.5f) - 1.0f, 0.0f, rounding);
6068
const float inv_rounding = 1.0f / rounding;
6069
const float arc0_b = ImAcos01(1.0f - (p0.x - rect.Min.x) * inv_rounding);
6070
const float arc0_e = ImAcos01(1.0f - (p1.x - rect.Min.x) * inv_rounding);
6071
const float half_pi = IM_PI * 0.5f; // We will == compare to this because we know this is the exact value ImAcos01 can return.
6072
const float x0 = ImMax(p0.x, rect.Min.x + rounding);
6073
if (arc0_b == arc0_e)
6074
{
6075
draw_list->PathLineTo(ImVec2(x0, p1.y));
6076
draw_list->PathLineTo(ImVec2(x0, p0.y));
6077
}
6078
else if (arc0_b == 0.0f && arc0_e == half_pi)
6079
{
6080
draw_list->PathArcToFast(ImVec2(x0, p1.y - rounding), rounding, 3, 6); // BL
6081
draw_list->PathArcToFast(ImVec2(x0, p0.y + rounding), rounding, 6, 9); // TR
6082
}
6083
else
6084
{
6085
draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b); // BL
6086
draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e); // TR
6087
}
6088
if (p1.x > rect.Min.x + rounding)
6089
{
6090
const float arc1_b = ImAcos01(1.0f - (rect.Max.x - p1.x) * inv_rounding);
6091
const float arc1_e = ImAcos01(1.0f - (rect.Max.x - p0.x) * inv_rounding);
6092
const float x1 = ImMin(p1.x, rect.Max.x - rounding);
6093
if (arc1_b == arc1_e)
6094
{
6095
draw_list->PathLineTo(ImVec2(x1, p0.y));
6096
draw_list->PathLineTo(ImVec2(x1, p1.y));
6097
}
6098
else if (arc1_b == 0.0f && arc1_e == half_pi)
6099
{
6100
draw_list->PathArcToFast(ImVec2(x1, p0.y + rounding), rounding, 9, 12); // TR
6101
draw_list->PathArcToFast(ImVec2(x1, p1.y - rounding), rounding, 0, 3); // BR
6102
}
6103
else
6104
{
6105
draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b); // TR
6106
draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e); // BR
6107
}
6108
}
6109
draw_list->PathFillConvex(col);
6110
}
6111
6112
void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer, const ImRect& inner, ImU32 col, float rounding)
6113
{
6114
const bool fill_L = (inner.Min.x > outer.Min.x);
6115
const bool fill_R = (inner.Max.x < outer.Max.x);
6116
const bool fill_U = (inner.Min.y > outer.Min.y);
6117
const bool fill_D = (inner.Max.y < outer.Max.y);
6118
if (fill_L) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Min.y), ImVec2(inner.Min.x, inner.Max.y), col, rounding, ImDrawFlags_RoundCornersNone | (fill_U ? 0 : ImDrawFlags_RoundCornersTopLeft) | (fill_D ? 0 : ImDrawFlags_RoundCornersBottomLeft));
6119
if (fill_R) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Min.y), ImVec2(outer.Max.x, inner.Max.y), col, rounding, ImDrawFlags_RoundCornersNone | (fill_U ? 0 : ImDrawFlags_RoundCornersTopRight) | (fill_D ? 0 : ImDrawFlags_RoundCornersBottomRight));
6120
if (fill_U) draw_list->AddRectFilled(ImVec2(inner.Min.x, outer.Min.y), ImVec2(inner.Max.x, inner.Min.y), col, rounding, ImDrawFlags_RoundCornersNone | (fill_L ? 0 : ImDrawFlags_RoundCornersTopLeft) | (fill_R ? 0 : ImDrawFlags_RoundCornersTopRight));
6121
if (fill_D) draw_list->AddRectFilled(ImVec2(inner.Min.x, inner.Max.y), ImVec2(inner.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersNone | (fill_L ? 0 : ImDrawFlags_RoundCornersBottomLeft) | (fill_R ? 0 : ImDrawFlags_RoundCornersBottomRight));
6122
if (fill_L && fill_U) draw_list->AddRectFilled(ImVec2(outer.Min.x, outer.Min.y), ImVec2(inner.Min.x, inner.Min.y), col, rounding, ImDrawFlags_RoundCornersTopLeft);
6123
if (fill_R && fill_U) draw_list->AddRectFilled(ImVec2(inner.Max.x, outer.Min.y), ImVec2(outer.Max.x, inner.Min.y), col, rounding, ImDrawFlags_RoundCornersTopRight);
6124
if (fill_L && fill_D) draw_list->AddRectFilled(ImVec2(outer.Min.x, inner.Max.y), ImVec2(inner.Min.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomLeft);
6125
if (fill_R && fill_D) draw_list->AddRectFilled(ImVec2(inner.Max.x, inner.Max.y), ImVec2(outer.Max.x, outer.Max.y), col, rounding, ImDrawFlags_RoundCornersBottomRight);
6126
}
6127
6128
// Helper for ColorPicker4()
6129
// NB: This is rather brittle and will show artifact when rounding this enabled if rounded corners overlap multiple cells. Caller currently responsible for avoiding that.
6130
// Spent a non reasonable amount of time trying to getting this right for ColorButton with rounding+anti-aliasing+ImGuiColorEditFlags_HalfAlphaPreview flag + various grid sizes and offsets, and eventually gave up... probably more reasonable to disable rounding altogether.
6131
// FIXME: uses ImGui::GetColorU32
6132
void ImGui::RenderColorRectWithAlphaCheckerboard(ImDrawList* draw_list, ImVec2 p_min, ImVec2 p_max, ImU32 col, float grid_step, ImVec2 grid_off, float rounding, ImDrawFlags flags)
6133
{
6134
if ((flags & ImDrawFlags_RoundCornersMask_) == 0)
6135
flags = ImDrawFlags_RoundCornersDefault_;
6136
if (((col & IM_COL32_A_MASK) >> IM_COL32_A_SHIFT) < 0xFF)
6137
{
6138
ImU32 col_bg1 = GetColorU32(ImAlphaBlendColors(IM_COL32(204, 204, 204, 255), col));
6139
ImU32 col_bg2 = GetColorU32(ImAlphaBlendColors(IM_COL32(128, 128, 128, 255), col));
6140
draw_list->AddRectFilled(p_min, p_max, col_bg1, rounding, flags);
6141
6142
int yi = 0;
6143
for (float y = p_min.y + grid_off.y; y < p_max.y; y += grid_step, yi++)
6144
{
6145
float y1 = ImClamp(y, p_min.y, p_max.y), y2 = ImMin(y + grid_step, p_max.y);
6146
if (y2 <= y1)
6147
continue;
6148
for (float x = p_min.x + grid_off.x + (yi & 1) * grid_step; x < p_max.x; x += grid_step * 2.0f)
6149
{
6150
float x1 = ImClamp(x, p_min.x, p_max.x), x2 = ImMin(x + grid_step, p_max.x);
6151
if (x2 <= x1)
6152
continue;
6153
ImDrawFlags cell_flags = ImDrawFlags_RoundCornersNone;
6154
if (y1 <= p_min.y) { if (x1 <= p_min.x) cell_flags |= ImDrawFlags_RoundCornersTopLeft; if (x2 >= p_max.x) cell_flags |= ImDrawFlags_RoundCornersTopRight; }
6155
if (y2 >= p_max.y) { if (x1 <= p_min.x) cell_flags |= ImDrawFlags_RoundCornersBottomLeft; if (x2 >= p_max.x) cell_flags |= ImDrawFlags_RoundCornersBottomRight; }
6156
6157
// Combine flags
6158
cell_flags = (flags == ImDrawFlags_RoundCornersNone || cell_flags == ImDrawFlags_RoundCornersNone) ? ImDrawFlags_RoundCornersNone : (cell_flags & flags);
6159
draw_list->AddRectFilled(ImVec2(x1, y1), ImVec2(x2, y2), col_bg2, rounding, cell_flags);
6160
}
6161
}
6162
}
6163
else
6164
{
6165
draw_list->AddRectFilled(p_min, p_max, col, rounding, flags);
6166
}
6167
}
6168
6169
//-----------------------------------------------------------------------------
6170
// [SECTION] Decompression code
6171
//-----------------------------------------------------------------------------
6172
// Compressed with stb_compress() then converted to a C array and encoded as base85.
6173
// Use the program in misc/fonts/binary_to_compressed_c.cpp to create the array from a TTF file.
6174
// The purpose of encoding as base85 instead of "0x00,0x01,..." style is only save on _source code_ size.
6175
// Decompression from stb.h (public domain) by Sean Barrett https://github.com/nothings/stb/blob/master/stb.h
6176
//-----------------------------------------------------------------------------
6177
6178
static unsigned int stb_decompress_length(const unsigned char *input)
6179
{
6180
return (input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11];
6181
}
6182
6183
static unsigned char *stb__barrier_out_e, *stb__barrier_out_b;
6184
static const unsigned char *stb__barrier_in_b;
6185
static unsigned char *stb__dout;
6186
static void stb__match(const unsigned char *data, unsigned int length)
6187
{
6188
// INVERSE of memmove... write each byte before copying the next...
6189
IM_ASSERT(stb__dout + length <= stb__barrier_out_e);
6190
if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; }
6191
if (data < stb__barrier_out_b) { stb__dout = stb__barrier_out_e+1; return; }
6192
while (length--) *stb__dout++ = *data++;
6193
}
6194
6195
static void stb__lit(const unsigned char *data, unsigned int length)
6196
{
6197
IM_ASSERT(stb__dout + length <= stb__barrier_out_e);
6198
if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; }
6199
if (data < stb__barrier_in_b) { stb__dout = stb__barrier_out_e+1; return; }
6200
memcpy(stb__dout, data, length);
6201
stb__dout += length;
6202
}
6203
6204
#define stb__in2(x) ((i[x] << 8) + i[(x)+1])
6205
#define stb__in3(x) ((i[x] << 16) + stb__in2((x)+1))
6206
#define stb__in4(x) ((i[x] << 24) + stb__in3((x)+1))
6207
6208
static const unsigned char *stb_decompress_token(const unsigned char *i)
6209
{
6210
if (*i >= 0x20) { // use fewer if's for cases that expand small
6211
if (*i >= 0x80) stb__match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2;
6212
else if (*i >= 0x40) stb__match(stb__dout-(stb__in2(0) - 0x4000 + 1), i[2]+1), i += 3;
6213
else /* *i >= 0x20 */ stb__lit(i+1, i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1);
6214
} else { // more ifs for cases that expand large, since overhead is amortized
6215
if (*i >= 0x18) stb__match(stb__dout-(stb__in3(0) - 0x180000 + 1), i[3]+1), i += 4;
6216
else if (*i >= 0x10) stb__match(stb__dout-(stb__in3(0) - 0x100000 + 1), stb__in2(3)+1), i += 5;
6217
else if (*i >= 0x08) stb__lit(i+2, stb__in2(0) - 0x0800 + 1), i += 2 + (stb__in2(0) - 0x0800 + 1);
6218
else if (*i == 0x07) stb__lit(i+3, stb__in2(1) + 1), i += 3 + (stb__in2(1) + 1);
6219
else if (*i == 0x06) stb__match(stb__dout-(stb__in3(1)+1), i[4]+1), i += 5;
6220
else if (*i == 0x04) stb__match(stb__dout-(stb__in3(1)+1), stb__in2(4)+1), i += 6;
6221
}
6222
return i;
6223
}
6224
6225
static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen)
6226
{
6227
const unsigned long ADLER_MOD = 65521;
6228
unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
6229
unsigned long blocklen = buflen % 5552;
6230
6231
unsigned long i;
6232
while (buflen) {
6233
for (i=0; i + 7 < blocklen; i += 8) {
6234
s1 += buffer[0], s2 += s1;
6235
s1 += buffer[1], s2 += s1;
6236
s1 += buffer[2], s2 += s1;
6237
s1 += buffer[3], s2 += s1;
6238
s1 += buffer[4], s2 += s1;
6239
s1 += buffer[5], s2 += s1;
6240
s1 += buffer[6], s2 += s1;
6241
s1 += buffer[7], s2 += s1;
6242
6243
buffer += 8;
6244
}
6245
6246
for (; i < blocklen; ++i)
6247
s1 += *buffer++, s2 += s1;
6248
6249
s1 %= ADLER_MOD, s2 %= ADLER_MOD;
6250
buflen -= blocklen;
6251
blocklen = 5552;
6252
}
6253
return (unsigned int)(s2 << 16) + (unsigned int)s1;
6254
}
6255
6256
static unsigned int stb_decompress(unsigned char *output, const unsigned char *i, unsigned int /*length*/)
6257
{
6258
if (stb__in4(0) != 0x57bC0000) return 0;
6259
if (stb__in4(4) != 0) return 0; // error! stream is > 4GB
6260
const unsigned int olen = stb_decompress_length(i);
6261
stb__barrier_in_b = i;
6262
stb__barrier_out_e = output + olen;
6263
stb__barrier_out_b = output;
6264
i += 16;
6265
6266
stb__dout = output;
6267
for (;;) {
6268
const unsigned char *old_i = i;
6269
i = stb_decompress_token(i);
6270
if (i == old_i) {
6271
if (*i == 0x05 && i[1] == 0xfa) {
6272
IM_ASSERT(stb__dout == output + olen);
6273
if (stb__dout != output + olen) return 0;
6274
if (stb_adler32(1, output, olen) != (unsigned int) stb__in4(2))
6275
return 0;
6276
return olen;
6277
} else {
6278
IM_ASSERT(0); /* NOTREACHED */
6279
return 0;
6280
}
6281
}
6282
IM_ASSERT(stb__dout <= output + olen);
6283
if (stb__dout > output + olen)
6284
return 0;
6285
}
6286
}
6287
6288
//-----------------------------------------------------------------------------
6289
// [SECTION] Default font data (ProggyClean.ttf)
6290
//-----------------------------------------------------------------------------
6291
// ProggyClean.ttf
6292
// Copyright (c) 2004, 2005 Tristan Grimmer
6293
// MIT license (see License.txt in http://www.proggyfonts.net/index.php?menu=download)
6294
// Download and more information at http://www.proggyfonts.net or http://upperboundsinteractive.com/fonts.php
6295
// If you want a similar font which may be better scaled, consider using ProggyVector from the same author!
6296
//-----------------------------------------------------------------------------
6297
6298
#ifndef IMGUI_DISABLE_DEFAULT_FONT
6299
6300
// File: 'ProggyClean.ttf' (41208 bytes)
6301
// Exported using binary_to_compressed_c.exe -u8 "ProggyClean.ttf" proggy_clean_ttf
6302
static const unsigned int proggy_clean_ttf_compressed_size = 9583;
6303
static const unsigned char proggy_clean_ttf_compressed_data[9583] =
6304
{
6305
87,188,0,0,0,0,0,0,0,0,160,248,0,4,0,0,55,0,1,0,0,0,12,0,128,0,3,0,64,79,83,47,50,136,235,116,144,0,0,1,72,130,21,44,78,99,109,97,112,2,18,35,117,0,0,3,160,130,19,36,82,99,118,116,
6306
32,130,23,130,2,33,4,252,130,4,56,2,103,108,121,102,18,175,137,86,0,0,7,4,0,0,146,128,104,101,97,100,215,145,102,211,130,27,32,204,130,3,33,54,104,130,16,39,8,66,1,195,0,0,1,4,130,
6307
15,59,36,104,109,116,120,138,0,126,128,0,0,1,152,0,0,2,6,108,111,99,97,140,115,176,216,0,0,5,130,30,41,2,4,109,97,120,112,1,174,0,218,130,31,32,40,130,16,44,32,110,97,109,101,37,89,
6308
187,150,0,0,153,132,130,19,44,158,112,111,115,116,166,172,131,239,0,0,155,36,130,51,44,210,112,114,101,112,105,2,1,18,0,0,4,244,130,47,32,8,132,203,46,1,0,0,60,85,233,213,95,15,60,
6309
245,0,3,8,0,131,0,34,183,103,119,130,63,43,0,0,189,146,166,215,0,0,254,128,3,128,131,111,130,241,33,2,0,133,0,32,1,130,65,38,192,254,64,0,0,3,128,131,16,130,5,32,1,131,7,138,3,33,2,
6310
0,130,17,36,1,1,0,144,0,130,121,130,23,38,2,0,8,0,64,0,10,130,9,32,118,130,9,130,6,32,0,130,59,33,1,144,131,200,35,2,188,2,138,130,16,32,143,133,7,37,1,197,0,50,2,0,131,0,33,4,9,131,
6311
5,145,3,43,65,108,116,115,0,64,0,0,32,172,8,0,131,0,35,5,0,1,128,131,77,131,3,33,3,128,191,1,33,1,128,130,184,35,0,0,128,0,130,3,131,11,32,1,130,7,33,0,128,131,1,32,1,136,9,32,0,132,
6312
15,135,5,32,1,131,13,135,27,144,35,32,1,149,25,131,21,32,0,130,0,32,128,132,103,130,35,132,39,32,0,136,45,136,97,133,17,130,5,33,0,0,136,19,34,0,128,1,133,13,133,5,32,128,130,15,132,
6313
131,32,3,130,5,32,3,132,27,144,71,32,0,133,27,130,29,130,31,136,29,131,63,131,3,65,63,5,132,5,132,205,130,9,33,0,0,131,9,137,119,32,3,132,19,138,243,130,55,32,1,132,35,135,19,131,201,
6314
136,11,132,143,137,13,130,41,32,0,131,3,144,35,33,128,0,135,1,131,223,131,3,141,17,134,13,136,63,134,15,136,53,143,15,130,96,33,0,3,131,4,130,3,34,28,0,1,130,5,34,0,0,76,130,17,131,
6315
9,36,28,0,4,0,48,130,17,46,8,0,8,0,2,0,0,0,127,0,255,32,172,255,255,130,9,34,0,0,129,132,9,130,102,33,223,213,134,53,132,22,33,1,6,132,6,64,4,215,32,129,165,216,39,177,0,1,141,184,
6316
1,255,133,134,45,33,198,0,193,1,8,190,244,1,28,1,158,2,20,2,136,2,252,3,20,3,88,3,156,3,222,4,20,4,50,4,80,4,98,4,162,5,22,5,102,5,188,6,18,6,116,6,214,7,56,7,126,7,236,8,78,8,108,
6317
8,150,8,208,9,16,9,74,9,136,10,22,10,128,11,4,11,86,11,200,12,46,12,130,12,234,13,94,13,164,13,234,14,80,14,150,15,40,15,176,16,18,16,116,16,224,17,82,17,182,18,4,18,110,18,196,19,
6318
76,19,172,19,246,20,88,20,174,20,234,21,64,21,128,21,166,21,184,22,18,22,126,22,198,23,52,23,142,23,224,24,86,24,186,24,238,25,54,25,150,25,212,26,72,26,156,26,240,27,92,27,200,28,
6319
4,28,76,28,150,28,234,29,42,29,146,29,210,30,64,30,142,30,224,31,36,31,118,31,166,31,166,32,16,130,1,52,46,32,138,32,178,32,200,33,20,33,116,33,152,33,238,34,98,34,134,35,12,130,1,
6320
33,128,35,131,1,60,152,35,176,35,216,36,0,36,74,36,104,36,144,36,174,37,6,37,96,37,130,37,248,37,248,38,88,38,170,130,1,8,190,216,39,64,39,154,40,10,40,104,40,168,41,14,41,32,41,184,
6321
41,248,42,54,42,96,42,96,43,2,43,42,43,94,43,172,43,230,44,32,44,52,44,154,45,40,45,92,45,120,45,170,45,232,46,38,46,166,47,38,47,182,47,244,48,94,48,200,49,62,49,180,50,30,50,158,
6322
51,30,51,130,51,238,52,92,52,206,53,58,53,134,53,212,54,38,54,114,54,230,55,118,55,216,56,58,56,166,57,18,57,116,57,174,58,46,58,154,59,6,59,124,59,232,60,58,60,150,61,34,61,134,61,
6323
236,62,86,62,198,63,42,63,154,64,18,64,106,64,208,65,54,65,162,66,8,66,64,66,122,66,184,66,240,67,98,67,204,68,42,68,138,68,238,69,88,69,182,69,226,70,84,70,180,71,20,71,122,71,218,
6324
72,84,72,198,73,64,0,36,70,21,8,8,77,3,0,7,0,11,0,15,0,19,0,23,0,27,0,31,0,35,0,39,0,43,0,47,0,51,0,55,0,59,0,63,0,67,0,71,0,75,0,79,0,83,0,87,0,91,0,95,0,99,0,103,0,107,0,111,0,115,
6325
0,119,0,123,0,127,0,131,0,135,0,139,0,143,0,0,17,53,51,21,49,150,3,32,5,130,23,32,33,130,3,211,7,151,115,32,128,133,0,37,252,128,128,2,128,128,190,5,133,74,32,4,133,6,206,5,42,0,7,
6326
1,128,0,0,2,0,4,0,0,65,139,13,37,0,1,53,51,21,7,146,3,32,3,130,19,32,1,141,133,32,3,141,14,131,13,38,255,0,128,128,0,6,1,130,84,35,2,128,4,128,140,91,132,89,32,51,65,143,6,139,7,33,
6327
1,0,130,57,32,254,130,3,32,128,132,4,32,4,131,14,138,89,35,0,0,24,0,130,0,33,3,128,144,171,66,55,33,148,115,65,187,19,32,5,130,151,143,155,163,39,32,1,136,182,32,253,134,178,132,7,
6328
132,200,145,17,32,3,65,48,17,165,17,39,0,0,21,0,128,255,128,3,65,175,17,65,3,27,132,253,131,217,139,201,155,233,155,27,131,67,131,31,130,241,33,255,0,131,181,137,232,132,15,132,4,138,
6329
247,34,255,0,128,179,238,32,0,130,0,32,20,65,239,48,33,0,19,67,235,10,32,51,65,203,14,65,215,11,32,7,154,27,135,39,32,33,130,35,33,128,128,130,231,32,253,132,231,32,128,132,232,34,
6330
128,128,254,133,13,136,8,32,253,65,186,5,130,36,130,42,176,234,133,231,34,128,0,0,66,215,44,33,0,1,68,235,6,68,211,19,32,49,68,239,14,139,207,139,47,66,13,7,32,51,130,47,33,1,0,130,
6331
207,35,128,128,1,0,131,222,131,5,130,212,130,6,131,212,32,0,130,10,133,220,130,233,130,226,32,254,133,255,178,233,39,3,1,128,3,0,2,0,4,68,15,7,68,99,12,130,89,130,104,33,128,4,133,
6332
93,130,10,38,0,0,11,1,0,255,0,68,63,16,70,39,9,66,215,8,32,7,68,77,6,68,175,14,32,29,68,195,6,132,7,35,2,0,128,255,131,91,132,4,65,178,5,141,111,67,129,23,165,135,140,107,142,135,33,
6333
21,5,69,71,6,131,7,33,1,0,140,104,132,142,130,4,137,247,140,30,68,255,12,39,11,0,128,0,128,3,0,3,69,171,15,67,251,7,65,15,8,66,249,11,65,229,7,67,211,7,66,13,7,35,1,128,128,254,133,
6334
93,32,254,131,145,132,4,132,18,32,2,151,128,130,23,34,0,0,9,154,131,65,207,8,68,107,15,68,51,7,32,7,70,59,7,135,121,130,82,32,128,151,111,41,0,0,4,0,128,255,0,1,128,1,137,239,33,0,
6335
37,70,145,10,65,77,10,65,212,14,37,0,0,0,5,0,128,66,109,5,70,123,10,33,0,19,72,33,18,133,237,70,209,11,33,0,2,130,113,137,119,136,115,33,1,0,133,43,130,5,34,0,0,10,69,135,6,70,219,
6336
13,66,155,7,65,9,12,66,157,11,66,9,11,32,7,130,141,132,252,66,151,9,137,9,66,15,30,36,0,20,0,128,0,130,218,71,11,42,68,51,8,65,141,7,73,19,15,69,47,23,143,39,66,81,7,32,1,66,55,6,34,
6337
1,128,128,68,25,5,69,32,6,137,6,136,25,32,254,131,42,32,3,66,88,26,148,26,32,0,130,0,32,14,164,231,70,225,12,66,233,7,67,133,19,71,203,15,130,161,32,255,130,155,32,254,139,127,134,
6338
12,164,174,33,0,15,164,159,33,59,0,65,125,20,66,25,7,32,5,68,191,6,66,29,7,144,165,65,105,9,35,128,128,255,0,137,2,133,182,164,169,33,128,128,197,171,130,155,68,235,7,32,21,70,77,19,
6339
66,21,10,68,97,8,66,30,5,66,4,43,34,0,17,0,71,19,41,65,253,20,71,25,23,65,91,15,65,115,7,34,2,128,128,66,9,8,130,169,33,1,0,66,212,13,132,28,72,201,43,35,0,0,0,18,66,27,38,76,231,5,
6340
68,157,20,135,157,32,7,68,185,13,65,129,28,66,20,5,32,253,66,210,11,65,128,49,133,61,32,0,65,135,6,74,111,37,72,149,12,66,203,19,65,147,19,68,93,7,68,85,8,76,4,5,33,255,0,133,129,34,
6341
254,0,128,68,69,8,181,197,34,0,0,12,65,135,32,65,123,20,69,183,27,133,156,66,50,5,72,87,10,67,137,32,33,0,19,160,139,78,251,13,68,55,20,67,119,19,65,91,36,69,177,15,32,254,143,16,65,
6342
98,53,32,128,130,0,32,0,66,43,54,70,141,23,66,23,15,131,39,69,47,11,131,15,70,129,19,74,161,9,36,128,255,0,128,254,130,153,65,148,32,67,41,9,34,0,0,4,79,15,5,73,99,10,71,203,8,32,3,
6343
72,123,6,72,43,8,32,2,133,56,131,99,130,9,34,0,0,6,72,175,5,73,159,14,144,63,135,197,132,189,133,66,33,255,0,73,6,7,70,137,12,35,0,0,0,10,130,3,73,243,25,67,113,12,65,73,7,69,161,7,
6344
138,7,37,21,2,0,128,128,254,134,3,73,116,27,33,128,128,130,111,39,12,0,128,1,0,3,128,2,72,219,21,35,43,0,47,0,67,47,20,130,111,33,21,1,68,167,13,81,147,8,133,230,32,128,77,73,6,32,
6345
128,131,142,134,18,130,6,32,255,75,18,12,131,243,37,128,0,128,3,128,3,74,231,21,135,123,32,29,134,107,135,7,32,21,74,117,7,135,7,134,96,135,246,74,103,23,132,242,33,0,10,67,151,28,
6346
67,133,20,66,141,11,131,11,32,3,77,71,6,32,128,130,113,32,1,81,4,6,134,218,66,130,24,131,31,34,0,26,0,130,0,77,255,44,83,15,11,148,155,68,13,7,32,49,78,231,18,79,7,11,73,243,11,32,
6347
33,65,187,10,130,63,65,87,8,73,239,19,35,0,128,1,0,131,226,32,252,65,100,6,32,128,139,8,33,1,0,130,21,32,253,72,155,44,73,255,20,32,128,71,67,8,81,243,39,67,15,20,74,191,23,68,121,
6348
27,32,1,66,150,6,32,254,79,19,11,131,214,32,128,130,215,37,2,0,128,253,0,128,136,5,65,220,24,147,212,130,210,33,0,24,72,219,42,84,255,13,67,119,16,69,245,19,72,225,19,65,3,15,69,93,
6349
19,131,55,132,178,71,115,14,81,228,6,142,245,33,253,0,132,43,172,252,65,16,11,75,219,8,65,219,31,66,223,24,75,223,10,33,29,1,80,243,10,66,175,8,131,110,134,203,133,172,130,16,70,30,
6350
7,164,183,130,163,32,20,65,171,48,65,163,36,65,143,23,65,151,19,65,147,13,65,134,17,133,17,130,216,67,114,5,164,217,65,137,12,72,147,48,79,71,19,74,169,22,80,251,8,65,173,7,66,157,
6351
15,74,173,15,32,254,65,170,8,71,186,45,72,131,6,77,143,40,187,195,152,179,65,123,38,68,215,57,68,179,15,65,85,7,69,187,14,32,21,66,95,15,67,19,25,32,1,83,223,6,32,2,76,240,7,77,166,
6352
43,65,8,5,130,206,32,0,67,39,54,143,167,66,255,19,82,193,11,151,47,85,171,5,67,27,17,132,160,69,172,11,69,184,56,66,95,6,33,12,1,130,237,32,2,68,179,27,68,175,16,80,135,15,72,55,7,
6353
71,87,12,73,3,12,132,12,66,75,32,76,215,5,169,139,147,135,148,139,81,12,12,81,185,36,75,251,7,65,23,27,76,215,9,87,165,12,65,209,15,72,157,7,65,245,31,32,128,71,128,6,32,1,82,125,5,
6354
34,0,128,254,131,169,32,254,131,187,71,180,9,132,27,32,2,88,129,44,32,0,78,47,40,65,79,23,79,171,14,32,21,71,87,8,72,15,14,65,224,33,130,139,74,27,62,93,23,7,68,31,7,75,27,7,139,15,
6355
74,3,7,74,23,27,65,165,11,65,177,15,67,123,5,32,1,130,221,32,252,71,96,5,74,12,12,133,244,130,25,34,1,0,128,130,2,139,8,93,26,8,65,9,32,65,57,14,140,14,32,0,73,79,67,68,119,11,135,
6356
11,32,51,90,75,14,139,247,65,43,7,131,19,139,11,69,159,11,65,247,6,36,1,128,128,253,0,90,71,9,33,1,0,132,14,32,128,89,93,14,69,133,6,130,44,131,30,131,6,65,20,56,33,0,16,72,179,40,
6357
75,47,12,65,215,19,74,95,19,65,43,11,131,168,67,110,5,75,23,17,69,106,6,75,65,5,71,204,43,32,0,80,75,47,71,203,15,159,181,68,91,11,67,197,7,73,101,13,68,85,6,33,128,128,130,214,130,
6358
25,32,254,74,236,48,130,194,37,0,18,0,128,255,128,77,215,40,65,139,64,32,51,80,159,10,65,147,39,130,219,84,212,43,130,46,75,19,97,74,33,11,65,201,23,65,173,31,33,1,0,79,133,6,66,150,
6359
5,67,75,48,85,187,6,70,207,37,32,71,87,221,13,73,163,14,80,167,15,132,15,83,193,19,82,209,8,78,99,9,72,190,11,77,110,49,89,63,5,80,91,35,99,63,32,70,235,23,81,99,10,69,148,10,65,110,
6360
36,32,0,65,99,47,95,219,11,68,171,51,66,87,7,72,57,7,74,45,17,143,17,65,114,50,33,14,0,65,111,40,159,195,98,135,15,35,7,53,51,21,100,78,9,95,146,16,32,254,82,114,6,32,128,67,208,37,
6361
130,166,99,79,58,32,17,96,99,14,72,31,19,72,87,31,82,155,7,67,47,14,32,21,131,75,134,231,72,51,17,72,78,8,133,8,80,133,6,33,253,128,88,37,9,66,124,36,72,65,12,134,12,71,55,43,66,139,
6362
27,85,135,10,91,33,12,65,35,11,66,131,11,71,32,8,90,127,6,130,244,71,76,11,168,207,33,0,12,66,123,32,32,0,65,183,15,68,135,11,66,111,7,67,235,11,66,111,15,32,254,97,66,12,160,154,67,
6363
227,52,80,33,15,87,249,15,93,45,31,75,111,12,93,45,11,77,99,9,160,184,81,31,12,32,15,98,135,30,104,175,7,77,249,36,69,73,15,78,5,12,32,254,66,151,19,34,128,128,4,87,32,12,149,35,133,
6364
21,96,151,31,32,19,72,35,5,98,173,15,143,15,32,21,143,99,158,129,33,0,0,65,35,52,65,11,15,147,15,98,75,11,33,1,0,143,151,132,15,32,254,99,200,37,132,43,130,4,39,0,10,0,128,1,128,3,
6365
0,104,151,14,97,187,20,69,131,15,67,195,11,87,227,7,33,128,128,132,128,33,254,0,68,131,9,65,46,26,42,0,0,0,7,0,0,255,128,3,128,0,88,223,15,33,0,21,89,61,22,66,209,12,65,2,12,37,0,2,
6366
1,0,3,128,101,83,8,36,0,1,53,51,29,130,3,34,21,1,0,66,53,8,32,0,68,215,6,100,55,25,107,111,9,66,193,11,72,167,8,73,143,31,139,31,33,1,0,131,158,32,254,132,5,33,253,128,65,16,9,133,
6367
17,89,130,25,141,212,33,0,0,93,39,8,90,131,25,93,39,14,66,217,6,106,179,8,159,181,71,125,15,139,47,138,141,87,11,14,76,23,14,65,231,26,140,209,66,122,8,81,179,5,101,195,26,32,47,74,
6368
75,13,69,159,11,83,235,11,67,21,16,136,167,131,106,130,165,130,15,32,128,101,90,24,134,142,32,0,65,103,51,108,23,11,101,231,15,75,173,23,74,237,23,66,15,6,66,46,17,66,58,17,65,105,
6369
49,66,247,55,71,179,12,70,139,15,86,229,7,84,167,15,32,1,95,72,12,89,49,6,33,128,128,65,136,38,66,30,9,32,0,100,239,7,66,247,29,70,105,20,65,141,19,69,81,15,130,144,32,128,83,41,5,
6370
32,255,131,177,68,185,5,133,126,65,97,37,32,0,130,0,33,21,0,130,55,66,195,28,67,155,13,34,79,0,83,66,213,13,73,241,19,66,59,19,65,125,11,135,201,66,249,16,32,128,66,44,11,66,56,17,
6371
68,143,8,68,124,38,67,183,12,96,211,9,65,143,29,112,171,5,32,0,68,131,63,34,33,53,51,71,121,11,32,254,98,251,16,32,253,74,231,10,65,175,37,133,206,37,0,0,8,1,0,0,107,123,11,113,115,
6372
9,33,0,1,130,117,131,3,73,103,7,66,51,18,66,44,5,133,75,70,88,5,32,254,65,39,12,68,80,9,34,12,0,128,107,179,28,68,223,6,155,111,86,147,15,32,2,131,82,141,110,33,254,0,130,15,32,4,103,
6373
184,15,141,35,87,176,5,83,11,5,71,235,23,114,107,11,65,189,16,70,33,15,86,153,31,135,126,86,145,30,65,183,41,32,0,130,0,32,10,65,183,24,34,35,0,39,67,85,9,65,179,15,143,15,33,1,0,65,
6374
28,17,157,136,130,123,32,20,130,3,32,0,97,135,24,115,167,19,80,71,12,32,51,110,163,14,78,35,19,131,19,155,23,77,229,8,78,9,17,151,17,67,231,46,94,135,8,73,31,31,93,215,56,82,171,25,
6375
72,77,8,162,179,169,167,99,131,11,69,85,19,66,215,15,76,129,13,68,115,22,72,79,35,67,113,5,34,0,0,19,70,31,46,65,89,52,73,223,15,85,199,33,95,33,8,132,203,73,29,32,67,48,16,177,215,
6376
101,13,15,65,141,43,69,141,15,75,89,5,70,0,11,70,235,21,178,215,36,10,0,128,0,0,71,207,24,33,0,19,100,67,6,80,215,11,66,67,7,80,43,12,71,106,7,80,192,5,65,63,5,66,217,26,33,0,13,156,
6377
119,68,95,5,72,233,12,134,129,85,81,11,76,165,20,65,43,8,73,136,8,75,10,31,38,128,128,0,0,0,13,1,130,4,32,3,106,235,29,114,179,12,66,131,23,32,7,77,133,6,67,89,12,131,139,116,60,9,
6378
89,15,37,32,0,74,15,7,103,11,22,65,35,5,33,55,0,93,81,28,67,239,23,78,85,5,107,93,14,66,84,17,65,193,26,74,183,10,66,67,34,143,135,79,91,15,32,7,117,111,8,75,56,9,84,212,9,154,134,
6379
32,0,130,0,32,18,130,3,70,171,41,83,7,16,70,131,19,84,191,15,84,175,19,84,167,30,84,158,12,154,193,68,107,15,33,0,0,65,79,42,65,71,7,73,55,7,118,191,16,83,180,9,32,255,76,166,9,154,
6380
141,32,0,130,0,69,195,52,65,225,15,151,15,75,215,31,80,56,10,68,240,17,100,32,9,70,147,39,65,93,12,71,71,41,92,85,15,84,135,23,78,35,15,110,27,10,84,125,8,107,115,29,136,160,38,0,0,
6381
14,0,128,255,0,82,155,24,67,239,8,119,255,11,69,131,11,77,29,6,112,31,8,134,27,105,203,8,32,2,75,51,11,75,195,12,74,13,29,136,161,37,128,0,0,0,11,1,130,163,82,115,8,125,191,17,69,35,
6382
12,74,137,15,143,15,32,1,65,157,12,136,12,161,142,65,43,40,65,199,6,65,19,24,102,185,11,76,123,11,99,6,12,135,12,32,254,130,8,161,155,101,23,9,39,8,0,0,1,128,3,128,2,78,63,17,72,245,
6383
12,67,41,11,90,167,9,32,128,97,49,9,32,128,109,51,14,132,97,81,191,8,130,97,125,99,12,121,35,9,127,75,15,71,79,12,81,151,23,87,97,7,70,223,15,80,245,16,105,97,15,32,254,113,17,6,32,
6384
128,130,8,105,105,8,76,122,18,65,243,21,74,63,7,38,4,1,0,255,0,2,0,119,247,28,133,65,32,255,141,91,35,0,0,0,16,67,63,36,34,59,0,63,77,59,9,119,147,11,143,241,66,173,15,66,31,11,67,
6385
75,8,81,74,16,32,128,131,255,87,181,42,127,43,5,34,255,128,2,120,235,11,37,19,0,23,0,0,37,109,191,14,118,219,7,127,43,14,65,79,14,35,0,0,0,3,73,91,5,130,5,38,3,0,7,0,11,0,0,70,205,
6386
11,88,221,12,32,0,73,135,7,87,15,22,73,135,10,79,153,15,97,71,19,65,49,11,32,1,131,104,121,235,11,80,65,11,142,179,144,14,81,123,46,32,1,88,217,5,112,5,8,65,201,15,83,29,15,122,147,
6387
11,135,179,142,175,143,185,67,247,39,66,199,7,35,5,0,128,3,69,203,15,123,163,12,67,127,7,130,119,71,153,10,141,102,70,175,8,32,128,121,235,30,136,89,100,191,11,116,195,11,111,235,15,
6388
72,39,7,32,2,97,43,5,132,5,94,67,8,131,8,125,253,10,32,3,65,158,16,146,16,130,170,40,0,21,0,128,0,0,3,128,5,88,219,15,24,64,159,32,135,141,65,167,15,68,163,10,97,73,49,32,255,82,58,
6389
7,93,80,8,97,81,16,24,67,87,52,34,0,0,5,130,231,33,128,2,80,51,13,65,129,8,113,61,6,132,175,65,219,5,130,136,77,152,17,32,0,95,131,61,70,215,6,33,21,51,90,53,10,78,97,23,105,77,31,
6390
65,117,7,139,75,24,68,195,9,24,64,22,9,33,0,128,130,11,33,128,128,66,25,5,121,38,5,134,5,134,45,66,40,36,66,59,18,34,128,0,0,66,59,81,135,245,123,103,19,120,159,19,77,175,12,33,255,
6391
0,87,29,10,94,70,21,66,59,54,39,3,1,128,3,0,2,128,4,24,65,7,15,66,47,7,72,98,12,37,0,0,0,3,1,0,24,65,55,21,131,195,32,1,67,178,6,33,4,0,77,141,8,32,6,131,47,74,67,16,24,69,3,20,24,
6392
65,251,7,133,234,130,229,94,108,17,35,0,0,6,0,141,175,86,59,5,162,79,85,166,8,70,112,13,32,13,24,64,67,26,24,71,255,7,123,211,12,80,121,11,69,215,15,66,217,11,69,71,10,131,113,132,
6393
126,119,90,9,66,117,19,132,19,32,0,130,0,24,64,47,59,33,7,0,73,227,5,68,243,15,85,13,12,76,37,22,74,254,15,130,138,33,0,4,65,111,6,137,79,65,107,16,32,1,77,200,6,34,128,128,3,75,154,
6394
12,37,0,16,0,0,2,0,104,115,36,140,157,68,67,19,68,51,15,106,243,15,134,120,70,37,10,68,27,10,140,152,65,121,24,32,128,94,155,7,67,11,8,24,74,11,25,65,3,12,83,89,18,82,21,37,67,200,
6395
5,130,144,24,64,172,12,33,4,0,134,162,74,80,14,145,184,32,0,130,0,69,251,20,32,19,81,243,5,82,143,8,33,5,53,89,203,5,133,112,79,109,15,33,0,21,130,71,80,175,41,36,75,0,79,0,83,121,
6396
117,9,87,89,27,66,103,11,70,13,15,75,191,11,135,67,87,97,20,109,203,5,69,246,8,108,171,5,78,195,38,65,51,13,107,203,11,77,3,17,24,75,239,17,65,229,28,79,129,39,130,175,32,128,123,253,
6397
7,132,142,24,65,51,15,65,239,41,36,128,128,0,0,13,65,171,5,66,163,28,136,183,118,137,11,80,255,15,67,65,7,74,111,8,32,0,130,157,32,253,24,76,35,10,103,212,5,81,175,9,69,141,7,66,150,
6398
29,131,158,24,75,199,28,124,185,7,76,205,15,68,124,14,32,3,123,139,16,130,16,33,128,128,108,199,6,33,0,3,65,191,35,107,11,6,73,197,11,24,70,121,15,83,247,15,24,70,173,23,69,205,14,
6399
32,253,131,140,32,254,136,4,94,198,9,32,3,78,4,13,66,127,13,143,13,32,0,130,0,33,16,0,24,69,59,39,109,147,12,76,253,19,24,69,207,15,69,229,15,130,195,71,90,10,139,10,130,152,73,43,
6400
40,91,139,10,65,131,37,35,75,0,79,0,84,227,12,143,151,68,25,15,80,9,23,95,169,11,34,128,2,128,112,186,5,130,6,83,161,19,76,50,6,130,37,65,145,44,110,83,5,32,16,67,99,6,71,67,15,76,
6401
55,17,140,215,67,97,23,76,69,15,77,237,11,104,211,23,77,238,11,65,154,43,33,0,10,83,15,28,83,13,20,67,145,19,67,141,14,97,149,21,68,9,15,86,251,5,66,207,5,66,27,37,82,1,23,127,71,12,
6402
94,235,10,110,175,24,98,243,15,132,154,132,4,24,66,69,10,32,4,67,156,43,130,198,35,2,1,0,4,75,27,9,69,85,9,95,240,7,32,128,130,35,32,28,66,43,40,24,82,63,23,83,123,12,72,231,15,127,
6403
59,23,116,23,19,117,71,7,24,77,99,15,67,111,15,71,101,8,36,2,128,128,252,128,127,60,11,32,1,132,16,130,18,141,24,67,107,9,32,3,68,194,15,175,15,38,0,11,0,128,1,128,2,80,63,25,32,0,
6404
24,65,73,11,69,185,15,83,243,16,32,0,24,81,165,8,130,86,77,35,6,155,163,88,203,5,24,66,195,30,70,19,19,24,80,133,15,32,1,75,211,8,32,254,108,133,8,79,87,20,65,32,9,41,0,0,7,0,128,0,
6405
0,2,128,2,68,87,15,66,1,16,92,201,16,24,76,24,17,133,17,34,128,0,30,66,127,64,34,115,0,119,73,205,9,66,43,11,109,143,15,24,79,203,11,90,143,15,131,15,155,31,65,185,15,86,87,11,35,128,
6406
128,253,0,69,7,6,130,213,33,1,0,119,178,15,142,17,66,141,74,83,28,6,36,7,0,0,4,128,82,39,18,76,149,12,67,69,21,32,128,79,118,15,32,0,130,0,32,8,131,206,32,2,79,83,9,100,223,14,102,
6407
113,23,115,115,7,24,65,231,12,130,162,32,4,68,182,19,130,102,93,143,8,69,107,29,24,77,255,12,143,197,72,51,7,76,195,15,132,139,85,49,15,130,152,131,18,71,81,23,70,14,11,36,0,10,0,128,
6408
2,69,59,9,89,151,15,66,241,11,76,165,12,71,43,15,75,49,13,65,12,23,132,37,32,0,179,115,130,231,95,181,16,132,77,32,254,67,224,8,65,126,20,79,171,8,32,2,89,81,5,75,143,6,80,41,8,34,
6409
2,0,128,24,81,72,9,32,0,130,0,35,17,0,0,255,77,99,39,95,65,36,67,109,15,24,69,93,11,77,239,5,95,77,23,35,128,1,0,128,24,86,7,8,132,167,32,2,69,198,41,130,202,33,0,26,120,75,44,24,89,
6410
51,15,71,243,12,70,239,11,24,84,3,11,66,7,11,71,255,10,32,21,69,155,35,88,151,12,32,128,74,38,10,65,210,8,74,251,5,65,226,5,75,201,13,32,3,65,9,41,146,41,40,0,0,0,9,1,0,1,0,2,91,99,
6411
19,32,35,106,119,13,70,219,15,83,239,12,137,154,32,2,67,252,19,36,128,0,0,4,1,130,196,32,2,130,8,91,107,8,32,0,135,81,24,73,211,8,132,161,73,164,13,36,0,8,0,128,2,105,123,26,139,67,
6412
76,99,15,34,1,0,128,135,76,83,156,20,92,104,8,67,251,30,24,86,47,27,123,207,12,24,86,7,15,71,227,8,32,4,65,20,20,131,127,32,0,130,123,32,0,71,223,26,32,19,90,195,22,71,223,15,84,200,
6413
6,32,128,133,241,24,84,149,9,67,41,25,36,0,0,0,22,0,88,111,49,32,87,66,21,5,77,3,27,123,75,7,71,143,19,135,183,71,183,19,130,171,74,252,5,131,5,89,87,17,32,1,132,18,130,232,68,11,10,
6414
33,1,128,70,208,16,66,230,18,147,18,130,254,223,255,75,27,23,65,59,15,135,39,155,255,34,128,128,254,104,92,8,33,0,128,65,32,11,65,1,58,33,26,0,130,0,72,71,18,78,55,17,76,11,19,86,101,
6415
12,75,223,11,89,15,11,24,76,87,15,75,235,15,131,15,72,95,7,85,71,11,72,115,11,73,64,6,34,1,128,128,66,215,9,34,128,254,128,134,14,33,128,255,67,102,5,32,0,130,16,70,38,11,66,26,57,
6416
88,11,8,24,76,215,34,78,139,7,95,245,7,32,7,24,73,75,23,32,128,131,167,130,170,101,158,9,82,49,22,118,139,6,32,18,67,155,44,116,187,9,108,55,14,80,155,23,66,131,15,93,77,10,131,168,
6417
32,128,73,211,12,24,75,187,22,32,4,96,71,20,67,108,19,132,19,120,207,8,32,5,76,79,15,66,111,21,66,95,8,32,3,190,211,111,3,8,211,212,32,20,65,167,44,34,75,0,79,97,59,13,32,33,112,63,
6418
10,65,147,19,69,39,19,143,39,24,66,71,9,130,224,65,185,43,94,176,12,65,183,24,71,38,8,24,72,167,7,65,191,38,136,235,24,96,167,12,65,203,62,115,131,13,65,208,42,175,235,67,127,6,32,
6419
4,76,171,29,114,187,5,32,71,65,211,5,65,203,68,72,51,8,164,219,32,0,172,214,71,239,58,78,3,27,66,143,15,77,19,15,147,31,35,33,53,51,21,66,183,10,173,245,66,170,30,150,30,34,0,0,23,
6420
80,123,54,76,1,16,73,125,15,82,245,11,167,253,24,76,85,12,70,184,5,32,254,131,185,37,254,0,128,1,0,128,133,16,117,158,18,92,27,38,65,3,17,130,251,35,17,0,128,254,24,69,83,39,140,243,
6421
121,73,19,109,167,7,81,41,15,24,95,175,12,102,227,15,121,96,11,24,95,189,7,32,3,145,171,154,17,24,77,47,9,33,0,5,70,71,37,68,135,7,32,29,117,171,11,69,87,15,24,79,97,19,24,79,149,23,
6422
131,59,32,1,75,235,5,72,115,11,72,143,7,132,188,71,27,46,131,51,32,0,69,95,6,175,215,32,21,131,167,81,15,19,151,191,151,23,131,215,71,43,5,32,254,24,79,164,24,74,109,8,77,166,13,65,
6423
176,26,88,162,5,98,159,6,171,219,120,247,6,79,29,8,99,169,10,103,59,19,65,209,35,131,35,91,25,19,112,94,15,83,36,8,173,229,33,20,0,88,75,43,71,31,12,65,191,71,33,1,0,130,203,32,254,
6424
131,4,68,66,7,67,130,6,104,61,13,173,215,38,13,1,0,0,0,2,128,67,111,28,74,129,16,104,35,19,79,161,16,87,14,7,138,143,132,10,67,62,36,114,115,5,162,151,67,33,16,108,181,15,143,151,67,
6425
5,5,24,100,242,15,170,153,34,0,0,14,65,51,34,32,55,79,75,9,32,51,74,7,10,65,57,38,132,142,32,254,72,0,14,139,163,32,128,80,254,8,67,158,21,65,63,7,32,4,72,227,27,95,155,12,67,119,19,
6426
124,91,24,149,154,72,177,34,97,223,8,155,151,24,108,227,15,88,147,16,72,117,19,68,35,11,92,253,15,70,199,15,24,87,209,17,32,2,87,233,7,32,1,24,88,195,10,119,24,8,32,3,81,227,24,65,
6427
125,21,35,128,128,0,25,76,59,48,24,90,187,9,97,235,12,66,61,11,91,105,19,24,79,141,11,24,79,117,15,24,79,129,27,90,53,13,130,13,32,253,131,228,24,79,133,40,69,70,8,66,137,31,65,33,
6428
19,96,107,8,68,119,29,66,7,5,68,125,16,65,253,19,65,241,27,24,90,179,13,24,79,143,18,33,128,128,130,246,32,254,130,168,68,154,36,77,51,9,97,47,5,167,195,32,21,131,183,78,239,27,155,
6429
195,78,231,14,201,196,77,11,6,32,5,73,111,37,97,247,12,77,19,31,155,207,78,215,19,162,212,69,17,14,66,91,19,80,143,57,78,203,39,159,215,32,128,93,134,8,24,80,109,24,66,113,15,169,215,
6430
66,115,6,32,4,69,63,33,32,0,101,113,7,86,227,35,143,211,36,49,53,51,21,1,77,185,14,65,159,28,69,251,34,67,56,8,33,9,0,24,107,175,25,90,111,12,110,251,11,119,189,24,119,187,34,87,15,
6431
9,32,4,66,231,37,90,39,7,66,239,8,84,219,15,69,105,23,24,85,27,27,87,31,11,33,1,128,76,94,6,32,1,85,241,7,33,128,128,106,48,10,33,128,128,69,136,11,133,13,24,79,116,49,84,236,8,24,
6432
91,87,9,32,5,165,255,69,115,12,66,27,15,159,15,24,72,247,12,74,178,5,24,80,64,15,33,0,128,143,17,77,89,51,130,214,24,81,43,7,170,215,74,49,8,159,199,143,31,139,215,69,143,5,32,254,
6433
24,81,50,35,181,217,84,123,70,143,195,159,15,65,187,16,66,123,7,65,175,15,65,193,29,68,207,39,79,27,5,70,131,6,32,4,68,211,33,33,67,0,83,143,14,159,207,143,31,140,223,33,0,128,24,80,
6434
82,14,24,93,16,23,32,253,65,195,5,68,227,40,133,214,107,31,7,32,5,67,115,27,87,9,8,107,31,43,66,125,6,32,0,103,177,23,131,127,72,203,36,32,0,110,103,8,155,163,73,135,6,32,19,24,112,
6435
99,10,65,71,11,73,143,19,143,31,126,195,5,24,85,21,9,24,76,47,14,32,254,24,93,77,36,68,207,11,39,25,0,0,255,128,3,128,4,66,51,37,95,247,13,82,255,24,76,39,19,147,221,66,85,27,24,118,
6436
7,8,24,74,249,12,76,74,8,91,234,8,67,80,17,131,222,33,253,0,121,30,44,73,0,16,69,15,6,32,0,65,23,38,69,231,12,65,179,6,98,131,16,86,31,27,24,108,157,14,80,160,8,24,65,46,17,33,4,0,
6437
96,2,18,144,191,65,226,8,68,19,5,171,199,80,9,15,180,199,67,89,5,32,255,24,79,173,28,174,201,24,79,179,50,32,1,24,122,5,10,82,61,10,180,209,83,19,8,32,128,24,80,129,27,111,248,43,131,
6438
71,24,115,103,8,67,127,41,78,213,24,100,247,19,66,115,39,75,107,5,32,254,165,219,78,170,40,24,112,163,49,32,1,97,203,6,65,173,64,32,0,83,54,7,133,217,88,37,12,32,254,131,28,33,128,
6439
3,67,71,44,84,183,6,32,5,69,223,33,96,7,7,123,137,16,192,211,24,112,14,9,32,255,67,88,29,68,14,10,84,197,38,33,0,22,116,47,50,32,87,106,99,9,116,49,15,89,225,15,97,231,23,70,41,19,
6440
82,85,8,93,167,6,32,253,132,236,108,190,7,89,251,5,116,49,58,33,128,128,131,234,32,15,24,74,67,38,70,227,24,24,83,45,23,89,219,12,70,187,12,89,216,19,32,2,69,185,24,141,24,70,143,66,
6441
24,82,119,56,78,24,10,32,253,133,149,132,6,24,106,233,7,69,198,48,178,203,81,243,12,68,211,15,106,255,23,66,91,15,69,193,7,100,39,10,24,83,72,16,176,204,33,19,0,88,207,45,68,21,12,
6442
68,17,10,65,157,53,68,17,6,32,254,92,67,10,65,161,25,69,182,43,24,118,91,47,69,183,18,181,209,111,253,12,89,159,8,66,112,12,69,184,45,35,0,0,0,9,24,80,227,26,73,185,16,118,195,15,131,
6443
15,33,1,0,65,59,15,66,39,27,160,111,66,205,12,148,111,143,110,33,128,128,156,112,24,81,199,8,75,199,23,66,117,20,155,121,32,254,68,126,12,72,213,29,134,239,149,123,89,27,16,148,117,
6444
65,245,8,24,71,159,14,141,134,134,28,73,51,55,109,77,15,105,131,11,68,67,11,76,169,27,107,209,12,102,174,8,32,128,72,100,18,116,163,56,79,203,11,75,183,44,85,119,19,71,119,23,151,227,
6445
32,1,93,27,8,65,122,5,77,102,8,110,120,20,66,23,8,66,175,17,66,63,12,133,12,79,35,8,74,235,33,67,149,16,69,243,15,78,57,15,69,235,16,67,177,7,151,192,130,23,67,84,29,141,192,174,187,
6446
77,67,15,69,11,12,159,187,77,59,10,199,189,24,70,235,50,96,83,19,66,53,23,105,65,19,77,47,12,163,199,66,67,37,78,207,50,67,23,23,174,205,67,228,6,71,107,13,67,22,14,66,85,11,83,187,
6447
38,124,47,49,95,7,19,66,83,23,67,23,19,24,96,78,17,80,101,16,71,98,40,33,0,7,88,131,22,24,89,245,12,84,45,12,102,213,5,123,12,9,32,2,126,21,14,43,255,0,128,128,0,0,20,0,128,255,128,
6448
3,126,19,39,32,75,106,51,7,113,129,15,24,110,135,19,126,47,15,115,117,11,69,47,11,32,2,109,76,9,102,109,9,32,128,75,2,10,130,21,32,254,69,47,6,32,3,94,217,47,32,0,65,247,10,69,15,46,
6449
65,235,31,65,243,15,101,139,10,66,174,14,65,247,16,72,102,28,69,17,14,84,243,9,165,191,88,47,48,66,53,12,32,128,71,108,6,203,193,32,17,75,187,42,73,65,16,65,133,52,114,123,9,167,199,
6450
69,21,37,86,127,44,75,171,11,180,197,78,213,12,148,200,81,97,46,24,95,243,9,32,4,66,75,33,113,103,9,87,243,36,143,225,24,84,27,31,90,145,8,148,216,67,49,5,24,84,34,14,75,155,27,67,
6451
52,13,140,13,36,0,20,0,128,255,24,135,99,46,88,59,43,155,249,80,165,7,136,144,71,161,23,32,253,132,33,32,254,88,87,44,136,84,35,128,0,0,21,81,103,5,94,47,44,76,51,12,143,197,151,15,
6452
65,215,31,24,64,77,13,65,220,20,65,214,14,71,4,40,65,213,13,32,0,130,0,35,21,1,2,0,135,0,34,36,0,72,134,10,36,1,0,26,0,130,134,11,36,2,0,14,0,108,134,11,32,3,138,23,32,4,138,11,34,
6453
5,0,20,134,33,34,0,0,6,132,23,32,1,134,15,32,18,130,25,133,11,37,1,0,13,0,49,0,133,11,36,2,0,7,0,38,134,11,36,3,0,17,0,45,134,11,32,4,138,35,36,5,0,10,0,62,134,23,32,6,132,23,36,3,
6454
0,1,4,9,130,87,131,167,133,11,133,167,133,11,133,167,133,11,37,3,0,34,0,122,0,133,11,133,167,133,11,133,167,133,11,133,167,34,50,0,48,130,1,34,52,0,47,134,5,8,49,49,0,53,98,121,32,
6455
84,114,105,115,116,97,110,32,71,114,105,109,109,101,114,82,101,103,117,108,97,114,84,84,88,32,80,114,111,103,103,121,67,108,101,97,110,84,84,50,48,48,52,47,130,2,53,49,53,0,98,0,121,
6456
0,32,0,84,0,114,0,105,0,115,0,116,0,97,0,110,130,15,32,71,132,15,36,109,0,109,0,101,130,9,32,82,130,5,36,103,0,117,0,108,130,29,32,114,130,43,34,84,0,88,130,35,32,80,130,25,34,111,
6457
0,103,130,1,34,121,0,67,130,27,32,101,132,59,32,84,130,31,33,0,0,65,155,9,34,20,0,0,65,11,6,130,8,135,2,33,1,1,130,9,8,120,1,1,2,1,3,1,4,1,5,1,6,1,7,1,8,1,9,1,10,1,11,1,12,1,13,1,14,
6458
1,15,1,16,1,17,1,18,1,19,1,20,1,21,1,22,1,23,1,24,1,25,1,26,1,27,1,28,1,29,1,30,1,31,1,32,0,3,0,4,0,5,0,6,0,7,0,8,0,9,0,10,0,11,0,12,0,13,0,14,0,15,0,16,0,17,0,18,0,19,0,20,0,21,0,
6459
22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,31,130,187,8,66,33,0,34,0,35,0,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,0,45,0,46,0,47,0,48,0,49,0,50,0,51,0,52,0,53,0,54,0,55,0,56,0,
6460
57,0,58,0,59,0,60,0,61,0,62,0,63,0,64,0,65,0,66,130,243,9,75,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,76,0,77,0,78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,0,90,0,91,0,
6461
92,0,93,0,94,0,95,0,96,0,97,1,33,1,34,1,35,1,36,1,37,1,38,1,39,1,40,1,41,1,42,1,43,1,44,1,45,1,46,1,47,1,48,1,49,1,50,1,51,1,52,1,53,1,54,1,55,1,56,1,57,1,58,1,59,1,60,1,61,1,62,1,
6462
63,1,64,1,65,0,172,0,163,0,132,0,133,0,189,0,150,0,232,0,134,0,142,0,139,0,157,0,169,0,164,0,239,0,138,0,218,0,131,0,147,0,242,0,243,0,141,0,151,0,136,0,195,0,222,0,241,0,158,0,170,
6463
0,245,0,244,0,246,0,162,0,173,0,201,0,199,0,174,0,98,0,99,0,144,0,100,0,203,0,101,0,200,0,202,0,207,0,204,0,205,0,206,0,233,0,102,0,211,0,208,0,209,0,175,0,103,0,240,0,145,0,214,0,
6464
212,0,213,0,104,0,235,0,237,0,137,0,106,0,105,0,107,0,109,0,108,0,110,0,160,0,111,0,113,0,112,0,114,0,115,0,117,0,116,0,118,0,119,0,234,0,120,0,122,0,121,0,123,0,125,0,124,0,184,0,
6465
161,0,127,0,126,0,128,0,129,0,236,0,238,0,186,14,117,110,105,99,111,100,101,35,48,120,48,48,48,49,141,14,32,50,141,14,32,51,141,14,32,52,141,14,32,53,141,14,32,54,141,14,32,55,141,
6466
14,32,56,141,14,32,57,141,14,32,97,141,14,32,98,141,14,32,99,141,14,32,100,141,14,32,101,141,14,32,102,140,14,33,49,48,141,14,141,239,32,49,141,239,32,49,141,239,32,49,141,239,32,49,
6467
141,239,32,49,141,239,32,49,141,239,32,49,141,239,32,49,141,239,32,49,141,239,32,49,141,239,32,49,141,239,32,49,141,239,32,49,141,239,45,49,102,6,100,101,108,101,116,101,4,69,117,114,
6468
111,140,236,32,56,141,236,32,56,141,236,32,56,141,236,32,56,141,236,32,56,141,236,32,56,141,236,32,56,141,236,32,56,141,236,32,56,141,236,32,56,141,236,32,56,141,236,32,56,141,236,
6469
32,56,141,236,32,56,141,236,32,56,65,220,13,32,57,65,220,13,32,57,141,239,32,57,141,239,32,57,141,239,32,57,141,239,32,57,141,239,32,57,141,239,32,57,141,239,32,57,141,239,32,57,141,
6470
239,32,57,141,239,32,57,141,239,32,57,141,239,32,57,141,239,32,57,141,239,35,57,102,0,0,5,250,72,249,98,247,
6471
};
6472
6473
static const char* GetDefaultCompressedFontDataProggyClean(int* out_size)
6474
{
6475
*out_size = proggy_clean_ttf_compressed_size;
6476
return (const char*)proggy_clean_ttf_compressed_data;
6477
}
6478
6479
//-----------------------------------------------------------------------------
6480
// [SECTION] Default font data (ProggyVector-minimal.ttf)
6481
//-----------------------------------------------------------------------------
6482
// Based on ProggyVector.ttf, Copyright (c) 2019,2023 Tristan Grimmer / Copyright (c) 2018 Source Foundry Authors / Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved.
6483
// MIT license + public domain, see licenses at https://github.com/bluescan/proggyfonts/tree/master/ProggyVector
6484
//-----------------------------------------------------------------------------
6485
// See misc/fonts/ProggyVector-ExtractScript.txt for FontForge script to create this from ProggyVector.ttf
6486
//-----------------------------------------------------------------------------
6487
6488
// File: 'ProggyVector-minimal.ttf' (23952 bytes)
6489
// Exported using binary_to_compressed_c.exe -u8 "ProggyVector-minimal.ttf" proggy_vector_minimal_ttf
6490
static const unsigned int proggy_vector_minimal_ttf_compressed_size = 18519;
6491
static const unsigned char proggy_vector_minimal_ttf_compressed_data[18519] =
6492
{
6493
87,188,0,0,0,0,0,0,0,0,93,144,0,4,0,0,55,0,1,0,0,0,14,0,128,0,3,0,96,70,70,84,77,165,245,48,76,0,0,93,116,130,21,38,28,71,68,69,70,0,37,130,9,34,0,93,92,130,5,44,24,79,83,47,50,135,
6494
98,111,82,0,0,1,104,130,15,44,96,99,109,97,112,10,236,8,177,0,0,3,88,130,19,44,82,99,118,116,32,0,34,2,136,0,0,4,172,130,31,38,4,103,97,115,112,255,255,130,89,34,0,93,84,130,15,56,
6495
8,103,108,121,102,169,208,238,39,0,0,6,56,0,0,84,32,104,101,97,100,39,214,168,186,130,27,32,236,130,3,33,54,104,130,16,35,6,225,0,231,130,75,32,36,130,15,40,36,104,109,116,120,37,72,
6496
32,85,130,15,32,200,130,3,40,142,108,111,99,97,26,185,47,212,130,95,32,176,130,15,40,136,109,97,120,112,0,201,0,151,130,11,32,72,130,47,43,32,110,97,109,101,10,160,159,163,0,0,90,131,
6497
143,44,68,112,111,115,116,153,185,200,234,0,0,91,156,130,35,32,184,132,235,45,1,0,0,96,193,239,192,95,15,60,245,0,11,4,130,54,37,0,0,225,81,71,241,131,8,43,228,205,29,41,255,247,255,
6498
2,2,162,3,161,130,15,34,8,0,2,130,5,131,2,32,1,130,225,38,182,254,184,0,143,2,102,130,31,34,196,2,162,132,73,131,25,135,3,32,4,132,17,37,195,0,104,0,5,0,134,49,131,6,132,3,32,46,132,
6499
5,36,2,2,102,1,144,131,29,39,2,138,2,188,0,47,0,140,131,7,40,255,92,1,224,0,49,1,2,0,131,0,32,9,132,57,143,61,43,0,66,105,114,100,0,64,0,32,32,172,3,132,131,47,3,182,1,72,32,63,0,255,
6500
223,253,0,0,2,14,3,182,130,48,38,32,0,1,2,102,0,34,130,9,32,0,130,7,132,3,35,0,237,0,169,130,147,46,91,0,19,0,29,1,10,0,168,0,205,0,46,0,41,130,5,32,83,130,25,44,65,0,67,0,132,0,76,
6501
0,75,0,40,0,72,130,11,40,70,0,66,0,63,0,239,0,209,130,33,52,45,0,44,0,81,255,251,0,18,0,79,0,70,0,69,0,94,0,117,0,51,130,7,34,100,0,61,130,5,34,108,0,38,130,21,36,58,0,86,0,58,130,
6502
57,42,70,0,24,0,60,0,29,0,2,0,9,130,47,50,55,0,148,0,62,0,154,0,61,255,247,0,167,0,68,0,96,0,82,130,51,34,62,0,66,130,105,40,97,0,166,0,118,0,113,0,141,130,97,32,97,130,71,32,95,130,
6503
3,40,129,0,106,0,128,0,84,0,50,130,183,32,38,130,85,38,101,0,92,1,6,0,102,130,147,36,0,0,232,0,105,130,17,34,102,0,18,130,187,34,99,0,160,130,33,38,135,0,40,0,44,0,178,130,9,34,159,
6504
0,150,130,9,52,161,0,163,0,238,0,83,0,53,0,227,0,198,0,172,0,122,0,116,0,13,132,1,32,96,130,139,32,18,136,3,32,0,130,71,33,98,0,133,1,33,100,0,133,1,32,4,132,195,32,58,130,195,131,
6505
3,36,75,0,4,0,74,134,1,32,18,130,33,32,94,130,187,32,68,136,3,32,20,130,197,32,62,130,215,131,3,34,109,0,134,132,1,33,69,0,131,195,32,69,130,195,131,3,34,44,0,24,130,15,32,97,132,3,
6506
36,52,0,95,0,52,130,123,130,166,33,0,3,130,4,131,3,34,28,0,1,130,9,36,0,0,76,0,3,132,9,32,28,130,111,32,48,130,17,46,8,0,8,0,2,0,0,0,126,0,255,32,172,255,255,130,9,34,32,0,160,131,
6507
9,37,255,227,255,194,224,22,132,43,130,20,131,2,34,1,6,0,136,14,35,1,2,0,0,132,55,130,6,136,2,8,152,1,0,0,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,
6508
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,
6509
90,91,92,93,94,95,96,97,0,134,135,137,139,147,152,158,163,162,164,166,165,167,169,171,170,172,173,175,174,176,177,179,181,180,182,184,183,188,187,189,190,0,114,100,101,105,0,120,161,
6510
112,107,0,118,106,0,136,154,0,115,0,0,103,119,132,161,39,108,124,0,168,186,129,99,110,131,12,38,109,125,0,98,130,133,151,131,10,131,3,37,185,0,193,0,0,194,131,9,33,0,121,130,5,47,132,
6511
140,131,141,138,143,144,145,142,149,150,0,148,156,157,155,130,18,32,113,130,3,32,122,130,3,130,2,34,34,2,136,130,5,33,42,0,133,1,8,186,80,0,100,0,170,1,22,1,132,2,2,2,16,2,36,2,56,
6512
2,104,2,124,2,166,2,182,2,208,2,226,3,26,3,52,3,132,3,214,3,246,4,46,4,126,4,150,4,238,5,66,5,120,5,194,5,224,5,244,6,14,6,84,6,224,7,12,7,80,7,122,7,162,7,184,7,208,8,0,8,24,8,46,
6513
8,76,8,116,8,132,8,170,8,202,8,254,9,42,9,98,9,160,9,248,10,10,10,66,10,98,10,152,10,208,10,246,11,20,11,38,11,68,11,86,11,116,11,128,11,152,11,234,12,52,12,100,12,180,12,238,13,16,
6514
13,108,13,148,13,194,13,236,14,18,14,38,14,96,14,128,14,176,14,222,15,18,15,60,15,122,15,152,15,190,15,224,16,18,16,76,16,146,16,178,16,240,16,254,17,68,17,122,130,1,8,225,158,17,228,
6515
18,12,18,88,18,142,18,162,19,32,19,66,19,176,19,246,20,40,20,56,20,68,20,192,20,206,21,8,21,34,21,80,21,160,21,184,21,232,22,4,22,32,22,62,22,88,22,146,22,198,23,4,23,80,23,196,24,
6516
40,24,96,24,146,24,208,25,46,25,116,25,188,25,228,26,48,26,84,26,114,26,156,26,212,26,244,27,16,27,52,27,100,27,154,27,244,28,46,28,98,28,162,29,10,29,82,29,144,30,0,30,68,30,134,30,
6517
210,31,38,31,84,31,122,31,212,32,68,32,176,33,36,33,182,34,50,34,188,35,44,35,128,35,206,36,24,36,104,36,192,36,238,37,20,37,64,37,118,37,216,38,38,38,104,38,160,38,222,39,60,39,134,
6518
39,174,39,250,40,50,40,100,40,158,40,226,41,42,41,92,41,178,42,16,0,2,0,34,0,0,1,50,2,170,0,3,0,7,0,46,177,1,0,47,60,178,7,4,0,237,50,177,6,5,220,60,178,3,2,130,10,34,0,177,3,131,22,
6519
32,5,131,22,39,178,7,6,1,252,60,178,1,131,23,53,51,17,33,17,39,51,17,35,34,1,16,238,204,204,2,170,253,86,34,2,102,0,130,83,8,71,237,255,255,1,126,2,228,0,14,0,20,0,0,37,50,23,22,20,
6520
14,1,35,34,39,38,53,52,55,54,19,3,35,3,53,51,1,53,50,17,6,33,25,15,32,19,21,21,19,85,15,80,18,113,140,42,13,47,30,9,19,19,24,41,19,19,1,221,254,160,1,96,123,0,131,75,38,169,1,185,1,
6521
191,2,189,132,159,34,0,1,17,131,115,39,51,17,1,104,87,254,234,87,130,25,35,4,254,252,1,130,3,61,0,2,0,1,0,5,2,102,2,183,0,5,0,46,0,0,19,51,54,55,35,6,15,1,35,62,1,55,35,53,130,12,130,
6522
14,38,53,51,55,51,14,1,7,134,5,33,21,35,131,11,34,21,35,7,131,34,51,229,123,31,11,123,11,50,52,80,10,32,10,129,149,7,13,14,7,133,152,132,12,32,123,132,5,40,121,140,8,26,8,125,144,53,
6523
79,130,30,51,1,10,112,46,46,178,195,37,121,37,71,30,49,49,29,73,194,37,120,37,131,3,36,73,29,98,30,71,131,22,32,0,130,169,8,40,91,255,237,2,41,2,210,0,8,0,18,0,72,0,0,1,21,54,55,54,
6524
53,52,39,38,39,53,6,7,6,29,1,6,23,22,19,46,1,39,38,35,38,131,18,39,22,23,30,1,23,22,23,53,130,12,8,166,52,55,54,55,53,51,21,20,30,4,23,21,39,38,47,2,34,39,21,22,23,22,21,20,7,6,7,21,
6525
1,102,56,26,31,31,32,132,62,25,8,2,26,30,44,1,1,1,3,7,12,25,79,59,21,30,13,23,16,36,46,82,53,50,53,61,71,82,56,19,21,20,20,11,22,35,25,33,16,8,8,98,43,54,58,63,74,1,54,205,10,20,37,
6526
49,39,29,21,91,194,5,62,20,6,10,25,34,24,254,84,10,37,11,1,1,5,13,23,85,12,15,5,9,6,13,2,217,11,45,42,144,45,50,6,57,57,3,10,3,5,4,6,3,81,10,14,7,8,2,1,202,16,43,46,71,72,50,49,4,58,
6527
0,5,0,19,0,17,2,84,2,172,130,9,38,22,0,38,0,55,0,71,130,219,37,0,7,35,18,19,3,130,166,33,51,50,133,228,38,35,34,7,6,20,23,6,65,239,7,33,51,50,131,193,33,1,22,131,30,32,52,130,239,40,
6528
38,34,14,2,21,20,55,20,7,140,33,8,124,2,40,254,177,58,96,234,160,60,13,34,7,11,24,20,20,20,19,21,52,17,5,165,43,54,52,46,38,39,36,61,55,41,40,254,24,13,34,27,20,20,5,10,27,12,27,23,
6529
20,10,204,68,33,25,67,41,39,67,30,26,68,42,40,2,172,253,200,98,1,140,1,14,253,205,28,10,1,18,20,19,32,18,19,38,11,27,77,38,37,38,53,57,36,36,37,40,51,54,1,162,18,18,20,38,11,23,11,
6530
4,8,18,22,14,27,28,75,37,17,37,35,56,73,40,16,38,36,0,130,0,63,3,0,29,255,243,2,98,2,209,0,11,0,37,0,85,0,0,19,62,1,53,52,35,34,6,7,6,23,22,3,20,23,132,223,45,63,1,54,55,62,2,55,38,
6531
39,38,47,1,38,39,130,26,43,55,38,53,54,55,54,51,50,30,1,29,1,130,208,41,7,30,3,23,54,61,1,54,38,59,132,13,34,22,23,34,131,227,37,6,43,1,34,39,38,130,22,8,147,237,30,57,71,34,40,3,14,
6532
38,19,102,53,29,57,18,15,53,41,12,5,6,7,4,3,2,26,20,34,19,67,17,27,47,26,22,50,86,2,75,42,52,35,78,35,34,24,59,33,53,40,46,26,38,1,2,1,81,20,19,36,36,49,43,47,5,10,40,81,104,8,100,
6533
73,70,13,1,221,18,49,44,61,35,14,53,35,17,254,239,71,49,27,13,4,23,6,3,3,4,5,1,1,34,26,41,26,86,21,36,36,33,38,163,66,66,99,37,23,23,60,24,38,41,45,31,41,42,69,53,57,33,46,91,26,6,
6534
24,108,52,51,38,45,63,1,52,64,63,64,85,20,127,130,250,52,0,1,1,10,1,186,1,102,2,191,0,3,0,0,1,17,51,17,1,10,92,130,16,34,5,254,251,130,14,41,0,168,255,174,1,141,3,7,0,7,130,12,55,6,
6535
16,23,35,38,16,55,1,141,132,132,80,149,149,3,7,217,254,88,216,224,1,157,220,130,26,39,0,205,255,179,1,178,3,12,132,39,8,48,22,16,7,35,54,16,39,1,29,149,149,80,132,132,3,12,220,254,
6536
96,221,216,1,175,210,0,0,1,0,46,0,90,2,57,2,100,0,27,0,0,19,39,54,55,22,23,53,51,21,55,131,7,8,64,7,23,22,23,7,46,1,39,21,35,53,7,39,54,219,173,19,25,129,43,87,88,55,33,14,30,176,88,
6537
54,33,44,33,109,33,87,174,42,99,1,100,96,28,40,70,24,186,186,48,30,17,20,49,96,48,30,19,68,18,59,18,196,196,92,67,56,132,203,48,0,41,0,100,2,61,2,85,0,11,0,0,37,53,35,53,51,130,94,
6538
49,51,21,35,21,1,8,223,223,84,225,225,100,208,80,209,209,80,208,130,135,44,205,255,85,1,125,0,141,0,25,0,0,23,38,130,136,45,54,55,34,38,39,38,53,52,55,54,51,50,23,22,65,207,5,8,44,
6539
6,241,6,30,59,17,7,7,20,29,5,4,43,13,15,32,19,22,3,13,91,17,171,8,42,51,37,15,18,29,13,13,15,49,18,4,19,20,31,6,15,17,92,86,16,130,83,40,83,1,52,2,23,1,133,0,5,130,219,46,53,33,21,
6540
22,21,83,1,195,1,1,52,81,40,25,16,130,156,38,1,0,237,255,255,1,126,130,115,35,13,0,0,4,139,109,8,34,20,1,85,47,25,11,21,44,13,16,30,20,22,1,9,10,19,33,48,18,5,20,20,63,0,0,1,0,65,255,
6541
208,2,41,2,230,131,83,8,37,23,0,55,51,0,7,65,1,38,99,95,254,217,98,48,2,81,197,253,176,198,0,0,3,0,67,255,243,2,38,2,203,0,7,0,18,0,32,130,247,51,50,17,52,39,6,7,22,19,38,35,34,7,6,
6542
21,20,23,54,55,5,16,67,111,6,32,16,131,221,8,57,1,56,148,8,104,149,35,185,33,78,93,35,21,8,63,63,1,1,137,45,60,120,60,61,241,121,60,61,72,1,34,48,46,130,182,72,1,232,72,111,77,102,
6543
49,46,79,78,54,254,240,68,23,92,91,180,1,109,92,88,130,198,130,147,39,132,0,0,1,254,2,189,0,130,199,8,34,51,53,51,17,6,7,38,53,54,55,51,17,51,21,132,144,32,111,1,107,35,94,142,82,2,
6544
0,25,89,82,33,80,26,253,149,82,133,51,44,76,0,0,2,30,2,202,0,54,0,0,1,34,130,48,33,62,1,131,137,36,21,20,14,1,7,130,2,49,6,15,1,14,5,7,33,21,33,53,52,62,4,63,1,62,3,55,69,50,5,8,102,
6545
46,1,35,1,27,70,132,1,96,93,23,100,67,65,30,12,8,20,49,10,30,34,18,9,14,20,19,20,28,17,1,100,254,46,27,33,39,42,40,12,22,17,14,9,18,11,47,9,5,37,16,53,15,2,123,73,58,29,51,14,55,52,
6546
89,49,62,15,12,30,49,11,33,34,16,7,18,16,18,22,27,17,82,63,17,26,34,38,43,40,13,22,19,12,12,20,13,61,40,19,24,52,33,15,19,130,211,44,75,255,243,2,34,2,203,0,56,0,0,19,54,131,154,69,
6547
120,6,69,128,6,37,43,1,38,39,46,1,69,175,5,33,22,51,68,234,6,34,43,1,53,68,245,11,8,161,7,97,120,73,74,64,58,26,16,6,31,97,93,37,22,69,67,127,25,12,14,54,35,14,23,31,65,23,62,45,131,
6548
34,10,44,44,67,86,77,107,30,10,36,33,72,51,88,25,26,2,172,31,29,26,56,34,29,46,17,78,24,23,68,36,51,101,55,55,1,1,4,10,3,5,11,95,30,5,15,77,25,32,65,34,36,78,63,20,27,54,28,29,21,7,
6549
10,0,2,0,40,0,0,2,64,2,189,0,6,0,17,0,0,55,51,17,14,3,39,1,51,17,51,21,35,21,35,53,33,136,242,61,108,39,24,106,1,26,135,119,119,90,254,185,245,1,114,87,170,61,38,6,1,180,254,56,78,
6550
167,167,0,0,0,1,0,72,130,227,32,23,130,63,32,36,135,227,36,21,20,7,14,1,132,218,34,2,39,53,136,214,8,69,39,38,34,7,17,33,21,33,196,47,35,120,69,68,109,50,80,22,36,12,14,69,41,20,10,
6551
88,96,129,37,11,9,15,17,53,170,66,1,135,254,214,1,194,14,65,64,109,141,62,25,11,1,1,5,12,7,3,97,46,90,30,29,48,22,36,15,47,35,1,96,79,130,175,38,67,255,246,2,38,2,191,130,173,32,54,
6552
130,175,136,95,66,149,6,38,22,39,54,51,50,23,22,70,9,6,67,123,7,39,54,59,1,30,2,23,21,38,130,149,8,91,35,6,7,6,214,34,68,101,25,9,53,30,51,69,34,37,21,8,46,51,117,105,57,60,61,56,117,
6553
130,58,49,9,3,89,89,104,9,19,7,25,32,30,17,8,60,44,19,9,9,73,69,51,108,43,92,30,39,99,42,22,43,46,75,59,36,12,249,97,63,62,226,63,60,85,71,113,38,43,192,83,87,1,4,9,4,3,88,32,1,2,71,
6554
71,0,130,0,8,62,1,0,70,0,0,2,28,2,189,0,9,0,0,9,1,35,18,55,54,55,33,53,33,2,28,254,244,105,120,101,22,17,254,155,1,214,2,150,253,106,1,39,232,54,41,79,0,0,3,0,66,255,243,2,39,2,203,
6555
0,14,0,28,0,58,130,209,33,20,23,132,211,34,52,39,38,131,210,34,55,50,53,134,9,32,21,130,24,34,37,20,7,66,58,6,36,35,34,38,53,52,130,91,33,38,39,68,96,6,130,244,8,95,167,82,26,33,65,
6556
40,37,37,37,68,69,35,37,141,125,32,30,63,93,24,8,72,23,1,0,121,78,29,31,16,58,170,113,128,39,24,75,43,23,32,9,14,60,61,208,61,61,198,100,28,10,36,37,128,37,35,35,35,145,115,60,28,30,
6557
67,22,28,85,24,7,126,135,26,17,46,46,75,49,38,115,104,97,73,49,47,16,11,26,32,25,38,35,76,50,49,49,51,130,222,39,0,2,0,63,255,249,2,35,130,175,38,13,0,53,0,0,19,20,66,171,11,40,18,
6558
38,39,53,22,23,30,1,54,130,152,36,6,7,14,1,34,133,156,130,14,66,251,10,8,97,6,7,38,163,134,68,34,37,79,29,23,78,30,34,59,32,72,36,31,19,36,61,35,100,18,18,19,39,63,81,40,86,30,15,23,
6559
11,61,139,130,59,34,12,15,23,42,93,47,63,36,1,219,164,43,43,78,118,36,11,41,42,253,206,1,17,78,15,6,1,2,1,18,50,198,36,15,30,16,15,33,90,44,42,71,67,19,97,89,49,65,73,62,114,65,133,
6560
46,22,4,2,133,167,45,239,0,111,1,129,2,66,0,15,0,32,0,0,1,72,26,14,34,3,22,21,130,17,132,159,32,52,130,172,40,54,50,1,129,22,20,23,39,20,130,0,57,23,55,21,5,45,44,22,19,48,13,26,11,
6561
6,5,10,29,13,31,1,251,33,18,20,20,16,35,130,5,49,42,13,254,236,17,56,24,20,19,5,9,28,13,31,13,25,12,5,130,108,36,2,0,209,255,197,132,107,38,31,0,47,0,0,23,54,130,81,35,34,38,39,38,
6562
132,89,69,248,10,37,7,6,7,46,3,19,142,137,60,209,42,14,18,15,19,29,5,4,5,9,29,13,15,31,20,22,3,3,4,21,29,51,29,6,9,8,8,171,139,147,62,9,36,19,24,42,29,13,13,31,12,26,12,5,20,20,31,
6563
6,12,18,29,12,54,34,58,18,7,13,11,12,2,11,138,162,130,146,8,57,0,1,0,41,0,116,2,57,2,75,0,14,0,0,45,1,53,36,55,21,14,2,7,30,2,31,1,2,57,253,240,1,140,132,91,126,156,52,28,74,115,78,
6564
130,116,196,78,148,49,86,33,44,55,19,9,26,41,27,45,132,207,38,45,0,205,2,61,1,245,75,31,5,36,55,53,33,21,37,130,3,44,45,2,16,253,240,2,16,205,81,81,216,80,80,133,99,58,44,0,114,2,60,
6565
2,73,0,11,0,0,1,37,53,4,23,21,5,53,62,1,55,54,1,213,254,87,130,98,60,253,240,28,73,58,195,1,93,151,85,148,49,78,196,86,9,26,21,68,0,2,0,81,255,255,2,33,2,223,130,151,130,107,75,199,
6566
14,61,3,39,62,1,51,50,22,29,1,6,15,1,14,1,29,1,35,53,54,55,62,2,53,54,39,38,43,1,34,6,75,223,12,56,124,72,33,130,78,106,117,2,85,32,29,44,96,2,87,17,48,45,1,25,38,73,9,37,94,75,243,
6567
12,56,156,46,52,85,86,73,4,77,60,22,21,44,30,55,54,72,61,13,34,45,25,41,20,29,57,131,191,44,2,255,251,255,225,2,162,2,224,0,16,0,95,130,193,36,35,38,7,6,7,74,116,10,46,19,22,23,14,
6568
1,7,6,35,34,39,38,39,46,1,53,65,206,8,33,21,20,130,39,42,6,35,17,38,35,53,6,7,6,46,1,68,101,6,8,203,54,30,1,31,1,22,23,51,22,55,54,61,1,54,39,46,2,34,6,7,14,2,29,1,20,23,22,23,62,1,
6569
1,111,10,10,17,53,6,6,22,32,37,38,29,29,62,17,236,3,50,12,49,40,78,96,83,79,104,75,45,18,27,56,132,64,54,196,88,31,8,14,39,14,19,56,18,20,38,30,69,46,33,53,83,43,60,26,43,17,7,14,9,
6570
12,34,12,11,5,2,38,18,71,53,42,37,32,84,77,27,82,82,122,81,117,1,229,1,8,27,94,64,32,32,35,33,60,91,29,8,254,167,3,59,10,43,19,37,25,32,109,63,104,50,98,64,142,54,26,98,37,60,18,26,
6571
47,15,7,254,242,1,45,34,16,14,6,27,29,62,86,119,66,37,2,22,10,4,14,9,13,2,23,10,6,7,25,36,16,33,7,2,11,31,113,93,47,12,115,100,87,3,1,41,0,0,2,0,18,130,4,45,86,2,189,0,10,0,23,0,0,
6572
19,51,46,3,39,130,202,8,61,1,15,1,35,54,19,51,22,18,30,1,23,35,39,202,213,13,39,30,18,7,13,19,37,30,32,54,105,41,188,123,28,83,63,39,15,104,56,1,3,44,132,98,62,23,43,67,125,100,100,
6573
183,124,2,65,85,254,254,192,120,46,183,0,130,0,38,3,0,79,255,255,2,58,132,87,45,21,0,44,0,0,55,51,50,55,54,52,38,39,38,70,243,10,42,43,1,3,17,51,50,23,22,23,20,7,71,197,5,68,240,7,
6574
8,88,175,149,124,26,10,20,20,40,80,149,127,104,23,8,33,32,82,115,96,207,112,64,60,2,6,13,21,6,12,30,17,84,26,41,66,69,129,78,67,24,67,51,16,32,78,60,21,28,57,21,24,253,144,2,189,46,
6575
46,86,39,15,30,26,7,13,10,7,22,38,47,76,94,50,49,0,1,0,70,255,243,2,25,2,203,0,25,0,0,37,6,76,84,10,39,21,38,35,34,7,6,21,16,131,151,8,41,55,2,25,76,90,147,76,78,139,71,91,88,78,79,
6576
87,98,49,49,197,58,68,20,19,25,38,95,96,171,232,90,44,39,97,58,71,74,142,254,225,34,10,15,130,218,39,0,2,0,69,0,0,2,44,130,219,34,12,0,23,134,217,34,53,52,39,132,219,133,208,8,32,21,
6577
16,7,6,35,170,86,153,32,13,50,25,23,41,62,83,101,189,172,63,63,172,55,71,78,142,54,78,157,56,30,11,18,131,173,39,85,87,179,254,250,66,22,0,130,163,32,94,130,79,32,35,130,79,38,11,0,
6578
0,51,17,33,21,135,1,49,94,1,196,254,161,1,53,254,203,1,96,2,189,79,208,80,254,80,130,43,32,117,130,43,36,41,2,190,0,12,131,43,34,50,54,51,131,44,53,51,21,35,17,117,28,75,60,1,17,254,
6579
174,246,246,2,189,1,76,222,76,254,184,131,171,34,1,0,51,130,255,32,40,130,255,32,31,135,255,74,164,8,32,21,130,177,65,3,8,8,53,53,35,53,51,2,40,86,116,71,56,61,36,75,80,81,139,96,79,
6580
25,38,43,58,109,47,49,194,60,45,134,230,57,70,24,29,45,94,170,175,94,97,50,98,25,19,26,71,71,146,254,226,30,189,78,0,130,143,32,69,130,143,32,36,135,187,79,93,5,55,35,17,33,17,69,101,
6581
1,20,102,102,254,236,2,189,254,225,1,31,253,67,1,78,254,178,130,144,34,1,0,100,130,47,32,3,134,47,37,53,51,17,35,53,33,130,188,47,51,21,100,157,157,1,159,157,157,80,2,30,79,79,253,
6582
226,68,115,6,36,61,255,247,1,222,130,43,32,17,131,187,33,7,6,66,58,7,131,52,61,17,20,1,169,38,51,29,63,183,185,80,23,28,191,1,36,41,38,7,5,77,30,36,95,1,137,79,254,40,132,134,151,32,
6583
100,130,59,53,24,0,0,51,17,51,17,62,3,55,51,6,7,30,2,23,35,46,3,39,6,7,130,159,51,38,116,86,55,20,119,194,97,126,102,52,19,122,29,90,66,42,16,58,19,130,173,52,200,38,115,85,54,20,191,
6584
95,173,143,72,27,43,129,96,60,23,57,20,254,238,130,79,32,108,130,183,32,57,130,79,32,5,133,79,41,33,21,108,101,1,104,2,189,253,147,134,171,32,38,130,31,32,68,130,31,50,20,0,0,1,3,35,
6585
39,46,2,39,17,35,17,51,22,23,62,2,55,130,229,8,40,1,236,145,77,21,13,39,54,17,88,135,90,45,18,86,24,8,136,88,2,102,254,142,56,32,101,137,44,253,154,2,189,229,115,45,218,59,22,253,67,
6586
0,72,87,8,32,35,133,247,37,51,17,51,30,3,23,130,192,8,38,35,46,1,39,38,39,17,70,128,31,92,69,43,17,97,128,31,93,34,72,22,2,189,69,210,156,98,38,2,59,253,67,70,210,78,164,49,253,197,
6587
130,63,48,2,0,58,255,247,2,46,2,198,0,13,0,29,0,0,18,16,72,101,5,46,16,39,38,35,34,7,19,34,17,16,55,54,50,22,23,130,1,8,58,21,16,7,6,164,34,33,77,78,33,34,34,35,76,75,35,110,250,141,
6588
47,93,54,24,48,32,61,141,50,1,242,254,216,68,65,65,64,1,48,64,67,67,253,193,1,103,1,15,66,23,11,11,22,46,94,176,254,239,65,21,130,102,39,0,2,0,86,0,0,2,46,130,167,41,12,0,26,0,0,19,
6589
51,50,55,54,79,194,5,67,216,8,8,51,22,20,7,6,43,1,17,187,117,56,33,11,10,39,39,40,78,109,101,218,125,65,35,10,19,16,49,189,117,1,104,21,7,7,37,61,60,37,34,253,144,2,189,53,30,28,49,
6590
101,39,119,254,230,130,87,36,58,255,159,2,104,130,191,42,23,0,32,0,0,37,30,1,23,21,35,130,251,35,6,34,39,38,137,188,54,16,1,6,16,22,50,54,16,38,34,1,248,26,56,30,64,62,23,24,53,145,
6591
47,140,135,193,52,254,152,34,68,153,68,69,151,92,29,66,35,59,70,27,27,35,22,66,1,14,136,195,43,254,171,1,125,68,254,217,134,130,1,47,131,130,111,32,72,130,199,32,50,130,199,34,9,0,
6592
40,134,199,34,52,39,38,135,196,44,21,20,6,7,6,7,30,4,31,1,35,46,2,130,134,32,35,130,25,8,43,17,173,111,82,33,36,38,36,79,109,101,219,123,54,66,23,24,34,56,16,19,6,13,35,28,48,107,54,
6593
45,16,6,16,13,59,12,24,37,1,119,31,30,124,32,32,131,220,55,52,60,88,45,60,26,32,28,29,34,13,24,66,54,90,105,91,31,11,31,26,1,254,216,68,159,6,36,37,2,203,0,58,74,225,11,130,102,73,
6594
237,8,43,51,50,23,30,2,23,21,38,47,1,38,34,130,136,36,6,21,20,23,22,130,1,33,30,1,76,96,5,8,108,34,39,46,1,39,79,110,102,118,33,11,29,27,75,14,7,62,40,58,24,47,103,63,79,37,54,16,45,
6595
26,13,39,21,32,43,87,28,58,21,11,6,8,14,32,69,13,13,39,189,146,48,90,27,57,75,27,130,67,72,23,28,52,27,27,17,3,1,9,16,25,24,43,77,118,57,33,9,4,11,9,4,96,23,7,12,13,7,17,45,21,20,32,
6596
12,19,13,28,13,3,3,8,38,165,153,40,13,3,5,24,10,0,130,175,43,24,0,0,2,81,2,189,0,7,0,0,33,67,189,6,44,1,2,234,2,57,234,2,110,79,79,253,146,0,131,35,36,60,255,243,2,43,130,35,37,34,
6597
0,0,5,35,34,132,204,130,164,37,38,53,17,51,17,20,71,116,6,33,55,54,132,13,131,208,60,1,82,29,49,59,10,9,42,12,30,18,4,16,103,21,11,38,75,54,24,56,10,2,101,11,17,34,61,13,130,119,60,
6598
19,11,25,41,12,48,105,1,176,253,250,43,34,11,32,11,27,52,20,205,1,67,254,80,105,35,58,30,48,132,111,32,29,130,147,32,76,130,111,32,15,130,124,36,2,3,35,38,2,130,114,8,44,51,30,3,23,
6599
19,2,76,111,107,123,27,80,30,48,33,98,12,31,49,67,22,181,2,189,254,162,254,161,85,1,2,96,155,107,40,106,168,226,75,2,103,0,1,0,2,130,63,32,102,130,63,32,30,130,63,40,3,35,47,1,38,47,
6600
1,14,2,130,154,34,35,2,3,132,70,8,72,51,18,23,22,23,18,55,2,102,109,99,40,25,10,8,15,4,10,16,12,41,15,98,44,66,86,10,28,21,14,5,86,112,39,14,26,8,58,19,2,189,253,67,244,157,59,51,85,
6601
22,59,99,75,254,87,1,9,1,180,68,206,153,96,37,2,48,254,255,88,173,43,1,165,140,130,107,32,9,130,107,32,95,130,107,32,31,132,107,36,19,54,55,46,1,132,173,8,83,1,23,19,51,6,7,14,1,7,
6602
22,23,30,1,23,35,38,39,46,1,1,59,197,109,174,46,30,17,40,31,64,83,108,39,100,44,167,109,28,41,45,95,14,47,113,22,42,15,108,12,16,32,101,1,46,254,210,1,2,68,46,23,56,43,88,119,57,143,
6603
64,1,8,40,61,68,138,22,75,173,36,64,24,20,26,52,167,130,98,71,223,8,32,19,130,12,33,19,51,130,95,36,6,7,17,35,17,131,94,8,45,39,51,22,23,22,1,52,181,109,29,88,33,51,39,101,29,44,78,
6604
72,16,108,44,47,64,1,136,1,53,46,143,52,82,63,254,197,1,59,47,71,126,117,25,76,79,107,0,130,62,33,0,55,130,187,32,49,130,187,8,47,16,0,0,51,53,54,18,54,55,33,53,33,21,14,3,7,33,21,
6605
55,109,180,65,25,254,144,1,229,26,67,106,144,47,1,144,73,156,1,6,95,36,79,71,36,95,150,202,67,80,131,59,44,148,255,166,1,205,3,24,0,7,0,0,23,17,69,243,5,43,148,1,57,220,220,90,3,114,
6606
74,253,35,75,132,95,8,52,62,255,210,2,40,2,233,0,13,0,0,19,22,23,18,31,1,35,39,46,1,47,1,38,39,158,31,43,212,41,67,96,60,34,62,25,50,121,42,2,233,62,85,254,84,82,134,120,68,124,51,
6607
102,244,80,31,6,36,154,255,167,1,210,134,95,70,87,5,44,17,154,220,220,1,56,89,75,2,220,74,252,143,132,95,36,61,1,177,2,43,130,191,32,14,130,144,39,7,35,19,51,30,1,23,22,65,106,6,59,
6608
52,136,111,203,88,25,74,28,58,18,111,8,12,24,75,2,112,191,1,12,32,99,36,77,24,13,16,32,130,252,45,1,255,247,255,167,2,114,255,243,0,3,0,0,7,130,245,49,9,2,123,89,76,76,0,1,0,167,2,
6609
51,1,169,3,2,0,10,130,83,33,35,38,65,202,6,8,33,22,1,169,112,33,39,64,10,111,9,26,20,48,2,51,46,56,92,13,13,36,29,67,0,0,2,0,68,255,243,2,19,2,27,130,227,32,57,78,1,9,38,61,1,35,34,
6610
7,6,5,72,159,8,49,55,54,59,1,53,52,39,38,43,1,34,7,53,51,50,62,1,50,130,168,32,22,82,86,5,8,94,35,34,39,54,52,38,160,70,21,27,78,44,38,116,96,42,24,1,31,48,144,84,50,53,35,38,54,59,
6611
77,107,36,37,61,88,34,40,40,19,32,40,50,24,59,27,76,14,8,1,31,10,42,2,2,158,73,20,7,57,50,81,18,39,22,133,83,44,45,81,67,39,40,13,17,13,68,25,27,2,73,1,1,3,9,15,40,66,36,76,250,24,
6612
21,1,30,14,15,131,163,32,96,130,163,52,44,2,246,0,25,0,47,0,0,19,20,23,22,50,55,54,55,62,2,55,54,130,147,36,46,1,34,6,7,132,1,79,126,5,68,133,5,32,7,131,186,8,86,6,7,35,17,51,193,70,
6613
28,69,19,32,18,28,16,4,2,1,43,26,51,46,37,14,30,10,20,4,6,5,48,107,86,52,57,15,3,47,23,43,40,61,106,48,5,4,83,92,1,7,134,50,20,5,8,21,31,54,35,17,17,16,114,47,29,13,10,10,21,22,41,
6614
25,46,168,80,52,54,121,24,24,110,78,38,27,24,80,44,23,130,136,35,0,1,0,82,130,147,36,3,2,27,0,30,73,199,14,36,22,23,21,38,39,69,25,9,8,57,51,50,55,2,3,72,91,128,73,69,123,62,87,54,
6615
24,50,33,41,24,45,76,27,47,35,41,76,40,67,91,62,27,40,76,72,128,167,74,35,7,16,17,91,32,9,17,7,12,40,53,91,123,53,28,58,0,2,0,61,130,95,43,9,2,245,0,28,0,51,0,0,55,30,1,130,72,130,
6616
243,36,1,55,54,52,39,130,95,35,39,38,35,34,130,245,36,14,2,21,20,5,130,234,132,17,32,52,78,236,7,8,37,17,51,17,35,38,200,24,48,22,42,20,37,11,16,6,2,1,1,2,2,3,12,35,80,45,26,29,9,17,
6617
6,3,1,14,50,101,62,63,17,130,252,8,60,30,29,57,102,75,48,16,11,92,83,2,101,29,13,15,26,29,35,49,17,17,32,17,17,17,30,26,80,20,22,22,37,52,34,16,114,82,80,37,16,54,122,25,88,100,37,
6618
73,45,15,20,1,42,253,11,19,0,0,0,2,0,62,130,159,32,44,130,255,38,10,0,36,0,0,19,33,132,149,131,147,32,1,87,7,12,35,29,1,33,21,80,85,6,8,67,55,162,1,47,14,21,60,20,26,69,46,40,1,110,
6619
96,100,129,74,74,116,60,83,170,50,15,254,114,46,46,90,72,76,23,24,1,54,37,42,54,18,5,46,38,254,157,40,72,74,126,164,79,37,148,46,46,56,3,83,48,50,33,10,11,0,0,1,0,66,130,120,44,40,
6620
2,224,0,22,0,0,51,17,35,53,51,53,131,242,34,59,1,21,131,119,8,35,29,1,51,21,35,17,231,165,165,22,21,43,99,136,140,50,19,19,169,169,1,143,78,71,43,84,21,40,73,19,17,62,88,78,254,113,
6621
130,62,37,0,76,255,3,2,23,130,183,37,18,0,63,0,0,19,134,155,32,53,131,190,33,46,1,80,245,5,49,23,52,38,53,51,6,29,1,6,20,14,3,35,7,53,51,54,55,131,1,34,53,6,7,132,217,34,39,46,3,77,
6622
142,5,8,106,168,83,26,33,98,27,8,9,15,13,28,47,27,60,38,38,125,105,55,1,83,1,1,1,17,62,60,45,222,102,53,36,66,34,33,1,32,29,48,40,70,42,20,17,29,32,10,6,48,24,43,42,1,13,147,41,12,
6623
113,37,33,77,27,50,16,31,13,50,50,173,67,13,29,10,34,45,95,93,193,113,99,66,37,2,78,1,1,2,46,46,60,77,38,9,15,24,13,15,28,72,48,48,24,110,74,37,26,24,131,251,32,97,130,188,35,13,2,
6624
245,0,130,12,42,19,54,59,1,50,23,22,21,17,35,17,81,160,6,33,7,6,131,12,8,38,51,189,50,106,10,68,38,64,92,57,20,26,73,38,19,7,4,92,92,1,207,80,32,57,127,254,185,1,71,105,23,9,52,26,
6625
47,20,21,254,214,130,68,35,0,2,0,166,130,84,51,129,2,219,0,21,0,33,0,0,33,35,53,54,61,1,35,53,51,21,20,130,248,34,22,29,1,130,2,41,20,6,17,20,43,1,34,61,1,52,130,109,38,21,1,128,92,
6626
1,127,218,130,222,63,1,15,71,16,16,71,15,114,28,120,187,77,64,16,35,37,126,11,23,40,16,18,66,16,37,2,103,14,14,81,14,14,130,166,37,0,118,255,4,1,187,130,91,43,15,0,27,0,0,23,53,51,
6627
50,54,53,17,130,92,41,17,20,6,7,6,35,19,50,29,1,134,88,63,51,118,143,46,44,144,236,22,23,45,80,149,14,14,73,14,14,252,80,80,58,1,227,77,253,208,46,96,25,51,3,215,131,79,32,81,130,81,
6628
130,170,33,0,113,130,88,34,84,2,218,130,175,8,61,0,1,7,21,35,17,51,17,62,1,55,54,55,51,6,7,30,3,23,35,38,1,20,68,95,95,29,89,33,40,51,111,158,62,31,94,69,44,17,113,186,1,15,60,211,
6629
2,218,254,90,27,80,30,37,44,141,57,40,121,89,56,22,245,131,75,32,141,130,4,36,119,2,190,0,8,130,7,55,7,17,35,17,52,39,35,53,1,119,2,92,1,139,2,190,192,254,2,2,9,40,63,78,130,26,41,
6630
0,41,0,0,2,69,2,27,0,38,130,12,33,54,51,65,114,13,32,21,130,55,76,176,7,130,10,8,72,51,20,6,21,54,55,50,1,71,46,85,66,29,28,84,15,12,39,38,25,16,84,3,9,17,30,55,14,15,84,77,1,33,89,
6631
60,1,217,66,47,50,137,254,207,1,45,114,26,26,29,26,111,254,211,1,96,69,16,30,28,26,112,254,211,2,14,8,29,9,57,2,0,1,0,65,231,5,40,27,0,18,0,0,1,52,35,34,65,217,6,33,22,23,130,127,130,
6632
114,61,1,177,107,100,28,9,92,83,7,2,51,114,171,92,1,71,137,95,31,40,254,214,2,14,49,30,92,212,254,185,130,174,37,0,69,255,243,2,36,130,179,34,15,0,28,66,223,13,131,75,35,19,34,39,38,
6633
88,17,6,8,51,16,6,166,81,27,34,67,39,37,82,26,35,69,36,37,143,179,46,15,15,46,178,117,61,62,122,1,7,146,44,14,54,53,97,149,41,13,52,51,254,136,157,51,134,51,159,71,70,254,243,142,0,
6634
131,95,36,95,255,3,2,42,130,95,32,10,131,95,34,37,50,16,132,162,36,20,23,22,23,34,76,96,6,65,40,5,46,20,7,6,1,82,132,132,101,28,9,79,25,34,105,46,131,177,8,32,48,103,99,60,57,127,39,
6635
59,1,151,117,37,49,147,43,14,72,80,254,192,3,11,41,26,80,74,73,129,196,62,18,0,2,130,187,40,4,2,15,2,26,0,14,0,32,85,95,15,39,20,1,54,55,51,17,35,17,68,93,10,8,33,190,34,65,66,34,35,
6636
78,25,32,65,34,35,1,24,7,2,83,92,47,105,136,53,25,127,40,50,101,111,54,54,51,99,151,39,130,191,47,199,1,40,38,28,252,248,1,62,81,130,61,74,206,63,19,130,195,34,1,0,129,130,200,32,25,
6637
130,195,44,25,0,0,1,38,43,1,34,6,7,6,29,1,130,195,8,53,21,35,17,51,22,20,6,21,54,59,1,22,23,2,25,56,84,39,10,63,21,45,1,1,92,90,1,2,56,127,5,82,49,1,155,48,24,21,45,43,42,30,48,146,
6638
60,2,14,6,18,24,23,84,2,38,130,82,35,0,1,0,106,70,15,6,39,39,0,0,1,34,21,20,23,75,15,9,86,136,10,33,46,1,84,150,5,8,72,55,54,50,23,21,38,1,67,121,25,28,109,12,139,59,59,183,108,108,
6639
80,57,36,35,29,27,67,10,9,29,66,40,36,55,54,185,83,80,1,211,78,37,17,17,19,2,26,116,78,45,45,32,90,51,24,21,40,36,19,19,13,2,2,6,12,36,34,60,76,41,40,31,84,43,133,123,41,128,255,254,
6640
1,230,2,174,0,17,0,74,223,5,36,53,17,51,21,51,130,204,130,210,59,59,1,1,230,169,103,43,43,92,221,221,24,22,60,160,2,39,41,94,2,2,160,79,254,237,59,18,18,130,60,51,1,0,84,255,242,2,
6641
20,2,13,0,24,0,0,37,6,43,1,38,35,34,130,61,8,61,17,20,51,54,55,54,53,54,53,51,20,22,29,1,35,1,190,37,123,9,4,5,184,91,124,73,30,34,3,92,1,86,57,71,1,213,1,69,254,187,139,8,36,40,57,
6642
240,83,63,194,72,196,0,0,1,0,50,0,0,2,54,2,14,131,135,40,1,3,35,46,3,39,51,23,22,130,1,8,40,62,1,63,1,2,54,198,119,25,72,55,34,13,95,50,30,22,46,15,26,57,30,50,2,14,253,242,64,194,
6643
143,91,34,135,81,60,125,40,68,157,81,135,131,67,130,148,33,2,104,130,67,32,27,130,12,43,3,35,2,38,39,51,30,2,23,19,51,23,130,5,131,71,32,51,130,87,8,58,1,39,1,52,89,88,89,33,9,91,22,
6644
49,16,6,72,102,25,16,22,14,5,11,31,12,31,91,131,88,11,32,12,1,33,254,223,1,100,136,34,93,220,70,27,1,4,80,48,71,44,17,50,151,56,153,253,242,35,107,39,130,93,130,167,32,38,130,167,32,
6645
67,130,99,39,35,0,0,51,54,55,46,2,130,99,46,3,23,62,1,55,51,14,3,7,30,1,23,35,39,38,130,1,33,7,6,130,1,57,38,140,80,61,92,34,14,103,18,55,40,26,9,109,29,10,103,24,74,55,34,14,25,169,
6646
27,107,130,198,33,45,17,132,4,58,171,103,79,113,44,16,23,70,52,33,12,139,39,12,31,92,69,43,17,30,211,33,65,38,29,58,21,132,4,133,115,8,40,70,255,2,2,25,2,15,0,50,0,0,23,51,54,59,1,
6647
50,55,54,53,54,52,39,35,34,38,61,1,52,55,53,50,54,51,17,20,23,22,59,1,17,130,241,34,54,51,21,69,131,5,130,5,8,80,20,6,35,33,38,54,119,59,45,37,102,39,17,25,1,1,189,84,100,1,17,57,18,
6648
24,25,68,163,1,1,35,11,47,1,1,1,88,66,254,248,1,1,174,1,29,45,64,10,18,8,100,63,252,32,28,50,1,254,202,77,31,27,1,82,54,52,1,83,41,37,76,40,66,115,51,32,32,81,127,21,39,0,130,255,32,
6649
101,130,255,32,8,130,139,32,17,130,255,33,53,54,88,38,5,32,21,131,238,8,34,6,7,33,21,101,39,60,114,109,254,203,1,150,39,59,115,60,27,21,1,65,80,46,70,134,129,68,78,46,70,136,69,33,
6650
24,71,131,63,40,92,255,151,2,3,3,38,0,44,66,111,6,130,193,83,72,8,130,11,32,55,130,222,71,147,6,32,20,84,214,5,33,29,1,132,219,8,76,2,3,33,122,44,43,26,27,56,72,59,71,25,26,43,43,123,
6651
33,36,68,22,21,23,26,48,46,28,23,21,24,46,56,105,34,35,109,113,70,28,23,88,21,28,72,111,109,35,35,84,14,19,71,110,74,33,40,11,10,41,33,76,115,63,19,15,0,1,1,6,255,181,1,92,3,9,0,3,
6652
130,123,43,17,51,17,1,6,86,75,3,84,252,172,0,131,151,32,102,130,151,32,16,130,151,40,50,0,0,23,53,51,50,55,54,132,140,34,55,38,39,130,1,137,163,33,23,22,132,142,35,23,22,51,22,72,59,
6653
8,130,167,8,99,35,102,34,72,20,22,22,31,43,28,16,37,9,6,22,20,72,34,31,124,43,42,10,6,7,33,65,16,21,28,32,96,35,23,42,42,125,105,83,16,20,70,108,74,34,42,9,6,15,31,40,26,59,97,63,20,
6654
14,84,35,34,110,113,36,24,11,10,37,1,88,39,33,61,100,109,36,34,0,1,0,40,0,241,2,61,1,215,0,33,0,0,19,39,54,55,54,51,50,23,30,1,130,115,130,149,33,55,23,87,136,6,131,151,8,89,35,34,
6655
7,14,1,118,78,12,21,41,76,37,19,28,41,11,57,36,56,13,5,3,77,33,36,83,39,22,33,28,51,16,19,19,38,17,7,12,1,20,18,71,36,70,11,15,41,14,76,73,22,27,17,51,59,68,12,19,37,65,10,13,33,27,
6656
44,0,2,0,232,255,227,1,138,2,193,0,6,0,20,0,0,55,54,55,51,19,21,35,2,52,131,115,33,22,21,133,106,8,34,246,9,29,60,34,132,14,23,21,37,35,46,49,15,17,37,21,181,79,187,254,246,210,2,102,
6657
76,21,23,46,27,66,18,5,21,0,130,71,48,105,255,109,2,18,2,161,0,8,0,43,0,0,37,17,6,7,79,220,5,34,53,38,39,89,241,5,36,54,55,53,51,21,130,197,32,21,130,16,32,39,71,127,5,32,21,130,36,
6658
37,35,21,1,93,66,40,130,0,8,70,66,117,60,67,13,22,24,70,115,51,62,49,19,46,23,34,27,8,16,8,48,50,11,9,55,55,59,1,151,6,56,54,87,88,54,56,212,135,9,75,75,115,58,37,60,28,82,12,134,134,
6659
8,17,8,81,26,5,8,3,254,102,1,3,1,10,28,81,4,4,23,135,0,82,115,8,43,44,2,203,0,27,0,0,19,52,51,50,23,131,115,73,231,8,8,47,21,33,21,33,53,51,53,35,53,51,187,227,62,70,9,8,50,60,103,
6660
20,8,185,185,1,12,254,26,117,99,99,1,221,238,28,86,5,5,31,96,33,61,86,68,218,80,80,218,68,130,219,42,102,0,92,2,38,2,0,0,13,0,47,70,91,11,8,32,34,7,6,20,23,7,38,39,54,55,46,1,53,52,
6661
55,38,39,55,23,54,50,23,55,23,22,23,7,22,20,7,22,23,6,130,27,8,86,6,34,250,32,45,46,30,31,31,30,92,30,32,11,82,10,36,80,3,22,7,30,72,12,48,82,50,90,50,83,22,14,9,83,30,31,23,61,38,
6662
9,80,3,50,90,229,28,28,31,42,43,29,28,28,28,86,92,76,10,32,75,3,36,43,11,44,43,69,10,44,79,29,28,78,22,13,8,79,49,88,39,21,57,33,11,75,3,29,133,231,86,239,7,43,35,0,0,1,6,7,21,51,21,
6663
35,21,35,131,216,33,53,39,130,221,79,22,8,8,80,23,19,51,7,14,1,7,51,21,1,145,5,38,201,201,101,200,200,45,155,122,19,30,68,33,11,108,44,47,64,27,181,109,50,51,53,11,126,1,130,9,62,17,
6664
51,247,247,51,17,71,52,32,48,111,55,17,76,79,107,47,1,53,80,80,86,17,52,0,0,2,1,10,255,188,1,96,3,2,0,3,0,7,67,61,5,8,45,3,17,51,17,1,10,86,86,86,68,1,101,254,155,1,226,1,100,254,156,
6665
0,2,0,99,255,164,2,6,2,203,0,17,0,85,0,0,19,20,23,22,23,54,53,52,39,38,130,1,33,6,7,130,1,32,5,92,10,8,37,43,1,39,46,3,39,70,224,11,35,2,53,52,55,66,44,6,35,51,31,1,22,130,58,86,216,
6666
5,66,74,6,33,30,1,130,17,8,129,22,181,42,40,112,61,8,12,17,39,117,28,18,4,3,9,1,81,92,50,5,4,51,50,86,20,20,27,18,20,43,11,88,60,73,26,7,61,38,46,87,46,16,92,59,50,35,61,18,18,39,20,
6667
9,13,20,53,82,60,42,13,33,7,7,18,26,59,5,5,20,92,36,33,1,98,35,37,36,53,38,48,20,13,20,15,35,58,18,25,4,5,19,77,84,48,44,32,14,25,58,39,40,2,3,4,3,12,3,77,36,43,13,15,44,36,25,25,47,
6668
50,41,25,87,46,39,67,61,38,27,7,3,2,130,0,8,40,3,17,77,37,7,20,15,16,11,22,18,26,33,3,2,10,46,41,37,0,0,0,2,0,160,2,123,1,201,2,217,0,11,0,23,0,0,1,52,59,1,74,174,6,33,53,39,138,11,
6669
36,1,99,16,70,16,130,2,43,195,14,72,15,15,72,14,2,204,13,13,68,135,2,33,0,3,130,71,51,58,2,104,2,126,0,27,0,51,0,75,0,0,37,50,55,21,6,34,39,91,150,5,46,51,50,23,21,46,2,43,1,34,7,6,
6670
21,20,22,7,82,126,9,75,202,9,34,20,23,22,79,122,7,68,56,9,89,249,5,8,126,1,85,45,46,52,106,36,73,28,12,13,42,139,57,56,35,43,14,6,13,64,31,33,70,150,55,90,24,26,74,68,64,33,18,76,70,
6671
111,56,32,137,27,5,32,9,1,105,53,92,160,96,52,35,17,91,165,99,72,45,34,8,50,35,35,42,26,219,25,49,22,11,24,68,31,82,32,103,20,51,17,6,2,34,33,64,60,68,26,63,19,5,42,37,72,42,37,116,
6672
68,70,14,56,123,23,24,54,64,15,124,35,130,73,87,61,76,24,129,48,31,41,12,70,87,83,52,60,28,20,0,130,219,38,135,0,220,1,224,2,203,130,9,41,17,0,46,0,0,55,53,33,21,3,130,203,130,179,
6673
33,50,55,130,173,34,61,1,21,73,162,8,80,51,5,8,122,34,7,53,54,63,1,50,23,22,29,1,35,38,146,1,78,138,104,22,8,22,22,62,22,43,18,9,53,80,96,33,9,103,33,56,79,49,27,93,71,40,60,35,132,
6674
33,11,64,4,220,59,59,1,43,37,13,49,18,18,8,18,46,22,19,22,130,61,70,22,28,89,28,8,1,55,20,11,31,59,16,9,2,92,31,44,211,18,0,0,0,2,0,40,0,67,1,245,1,242,0,12,0,29,0,0,1,23,21,39,53,
6675
62,3,55,21,14,1,7,22,23,21,38,39,46,1,130,15,32,1,130,148,8,49,21,6,1,94,151,235,29,86,64,40,16,29,93,255,78,72,15,20,53,118,28,28,87,32,61,26,78,1,26,126,89,196,38,24,72,54,34,13,
6676
90,24,79,23,67,59,89,12,17,45,98,24,130,17,53,27,52,22,90,67,0,1,0,44,0,174,2,60,1,150,0,5,0,0,37,53,33,130,237,41,1,232,254,68,2,16,174,151,81,232,130,131,42,1,0,178,0,225,1,182,1,
6677
46,0,3,65,11,5,39,178,1,4,225,77,77,0,4,66,3,8,39,10,0,37,0,61,0,85,0,86,143,5,32,53,85,200,8,41,21,20,7,6,7,30,1,23,30,5,81,241,5,35,43,1,21,39,66,12,46,8,32,246,51,45,14,23,19,18,
6678
42,54,65,119,145,48,16,20,5,11,8,3,8,11,8,18,32,11,72,65,10,18,26,16,23,133,66,20,39,8,32,1,113,9,15,30,33,9,12,254,225,1,71,93,50,24,7,3,1,10,7,4,11,12,11,27,50,17,102,12,19,7,140,
6679
3,66,31,40,8,40,1,0,159,2,135,1,202,2,205,0,3,0,0,1,21,33,53,1,202,254,213,2,205,70,70,0,0,0,2,0,150,1,160,1,211,2,203,0,13,0,35,130,29,80,201,5,46,35,34,7,6,20,22,50,55,22,23,30,1,
6680
20,14,1,103,70,13,8,61,1,132,15,6,13,38,14,22,45,24,28,54,92,11,30,31,13,23,23,34,18,32,54,84,46,26,45,46,66,8,7,35,2,4,17,50,16,30,17,7,24,26,76,52,228,13,29,13,55,60,54,30,12,21,
6681
63,39,38,72,43,44,1,5,132,115,32,44,130,120,34,60,2,38,130,143,38,15,0,0,51,53,33,21,101,69,11,47,44,2,16,254,206,222,222,84,222,222,80,80,160,155,80,155,130,2,130,152,47,0,161,2,14,
6682
1,190,3,159,0,27,0,0,19,54,51,50,130,153,38,21,20,7,14,2,7,51,130,208,33,54,55,130,1,8,52,52,39,38,34,7,164,66,46,100,43,18,6,15,40,67,59,20,204,254,227,21,36,114,15,21,7,23,106,68,
6683
3,132,27,48,20,32,10,35,19,51,60,54,18,54,53,20,33,100,27,29,38,12,38,34,130,142,50,0,1,0,163,2,9,1,206,3,161,0,55,0,0,1,20,7,22,23,88,146,5,36,34,47,1,38,39,131,1,32,53,94,4,10,92,
6684
154,10,38,35,34,14,3,7,53,54,130,139,8,92,22,1,196,86,47,24,25,12,36,133,17,7,7,14,8,7,17,10,20,11,39,24,23,26,95,14,2,28,23,59,32,37,71,18,6,52,17,17,23,39,15,14,14,8,77,38,112,37,
6685
11,3,59,65,22,8,26,25,67,22,71,1,2,1,1,4,2,4,5,56,15,3,7,56,7,13,29,18,18,51,33,10,13,42,12,4,8,2,5,6,2,57,17,60,19,130,159,40,238,2,81,1,221,3,2,0,9,130,159,34,6,7,35,132,238,53,55,
6686
1,221,143,20,76,17,25,26,20,38,14,3,2,156,21,21,33,33,24,48,18,133,207,44,83,255,55,2,65,2,14,0,30,0,0,37,6,78,3,5,39,17,20,23,22,51,50,53,17,74,209,6,33,50,55,68,18,5,8,47,1,175,42,
6687
181,42,83,91,18,33,66,127,93,17,6,5,8,7,23,40,23,39,14,24,60,73,72,254,252,2,215,254,186,54,30,55,158,1,51,254,106,42,8,3,10,70,20,14,24,133,95,36,53,255,164,2,3,85,35,5,43,5,17,38,
6688
39,38,53,52,54,59,1,17,35,130,1,56,1,23,136,56,34,132,106,224,71,95,92,1,141,10,78,43,67,90,108,252,231,2,224,253,32,130,56,48,1,0,227,1,14,1,133,1,174,0,15,0,0,1,22,21,20,107,176,
6689
9,8,35,51,50,1,110,23,35,29,17,34,23,24,50,14,17,32,1,152,23,43,26,34,12,23,22,35,54,20,6,0,1,0,198,255,71,1,148,130,65,41,17,0,0,5,50,53,52,38,39,51,130,61,8,33,7,6,43,1,34,39,53,
6690
22,1,17,62,33,11,59,54,46,33,25,37,28,37,36,128,43,21,49,15,54,49,53,18,11,11,61,131,102,8,57,0,172,2,14,1,202,3,151,0,13,0,0,19,54,55,51,17,51,21,33,53,51,17,14,1,7,172,42,73,68,103,
6691
254,235,103,21,70,21,3,132,6,13,254,172,53,53,1,30,4,11,4,0,3,0,122,0,220,1,239,69,79,6,32,37,68,67,5,34,39,22,51,101,144,6,106,122,9,32,39,103,204,10,8,71,21,20,138,1,82,213,20,25,
6692
53,27,29,44,21,70,20,62,244,49,87,46,25,43,16,45,8,3,76,43,67,87,49,51,220,59,59,172,9,37,33,68,79,38,21,9,27,203,39,53,11,19,17,46,57,20,34,98,54,31,53,53,88,89,0,2,0,116,0,67,2,65,
6693
1,242,91,143,5,34,1,23,21,130,161,41,6,7,53,62,1,55,38,39,7,38,130,230,33,23,22,130,19,8,61,3,7,53,54,1,86,235,29,86,32,59,29,28,94,29,54,97,76,72,78,59,60,78,37,15,40,64,87,28,72,
6694
1,242,197,38,24,72,27,50,23,89,23,79,24,42,84,126,59,67,90,50,50,65,32,38,13,33,54,72,24,89,59,0,130,0,59,4,0,13,255,129,2,45,3,11,0,5,0,20,0,24,0,36,0,0,37,51,53,6,7,6,23,53,35,131,
6695
108,44,54,55,51,21,51,21,35,21,19,5,39,37,1,65,45,8,8,65,6,7,1,27,137,9,12,68,89,194,22,67,25,34,34,80,59,59,69,253,237,13,2,19,254,11,115,68,103,254,235,103,63,49,12,195,13,16,94,
6696
211,87,57,31,91,33,47,46,253,52,87,1,231,123,51,123,1,95,17,254,172,52,52,1,31,12,7,130,122,33,0,3,136,123,36,30,0,34,0,46,130,121,80,150,8,37,7,6,7,51,21,33,133,128,92,31,6,34,34,
6697
7,37,143,131,59,8,63,48,82,44,43,15,29,39,83,36,205,254,226,22,72,19,54,9,6,6,19,25,23,96,60,1,37,142,143,58,247,26,30,34,47,29,22,40,36,75,34,53,52,20,66,17,50,12,9,6,32,18,33,17,
6698
17,34,172,144,152,65,19,7,32,19,65,19,6,32,79,65,19,25,47,45,1,50,52,35,34,15,1,14,1,7,53,55,62,1,55,137,192,32,22,75,212,5,41,47,1,34,39,46,2,39,53,30,1,101,182,8,34,43,1,53,65,61,
6699
22,8,45,135,95,90,37,17,25,7,15,8,18,21,19,11,16,35,71,42,42,49,16,21,96,47,48,85,9,8,29,8,7,13,23,14,8,18,24,7,38,27,93,14,2,6,21,82,33,65,98,20,8,56,212,113,5,7,2,5,2,56,4,5,2,2,
6700
3,27,28,46,51,23,7,5,20,79,58,31,32,1,2,2,4,4,4,2,58,6,8,2,10,56,8,25,12,40,51,0,2,0,96,255,244,1,239,2,219,0,50,0,67,130,227,33,54,55,66,100,5,72,27,7,35,62,1,63,1,131,211,36,55,54,
6701
61,1,52,130,3,32,51,131,210,36,7,14,2,15,1,81,137,5,33,51,19,69,25,5,33,35,34,66,247,6,8,119,50,1,82,68,89,31,31,11,33,25,35,38,87,52,56,17,22,53,6,27,8,12,5,15,4,8,1,96,12,18,43,12,
6702
11,27,5,13,31,19,28,71,40,30,10,4,16,25,23,39,31,6,5,57,7,24,65,7,57,89,17,11,4,14,3,3,44,46,75,40,27,35,49,5,25,7,13,6,17,8,16,32,2,3,5,5,65,72,45,25,40,39,11,10,26,5,13,36,25,10,
6703
31,22,38,2,149,9,27,13,51,14,23,29,13,13,16,56,14,1,0,0,0,3,90,175,5,39,3,101,0,10,0,23,0,31,98,145,23,39,3,46,1,39,51,30,1,23,98,153,23,39,145,22,70,22,92,19,61,19,98,161,22,36,2,
6704
49,23,79,23,130,2,137,111,32,104,132,111,32,27,151,111,35,17,7,35,55,151,107,34,114,77,98,151,102,34,177,123,123,138,211,32,102,132,99,32,35,151,99,42,3,38,39,14,1,7,35,54,55,51,22,
6705
152,215,43,47,48,35,15,52,16,69,85,20,94,44,62,151,116,41,50,51,33,15,53,16,102,23,51,74,138,123,32,81,132,123,32,62,153,123,40,34,7,6,29,1,35,52,55,54,94,110,5,32,22,79,205,5,43,51,
6706
6,7,6,35,34,46,1,47,1,46,3,151,255,8,33,172,14,18,6,22,63,27,26,42,6,9,30,34,7,10,26,11,19,8,13,62,3,53,17,15,32,18,9,6,14,7,7,18,5,151,169,63,92,7,4,11,30,4,49,27,28,1,6,17,4,5,13,
6707
9,15,19,3,73,23,8,8,3,3,7,4,4,9,4,0,4,66,11,12,34,35,0,47,151,189,32,19,86,222,6,36,59,1,50,21,7,138,11,151,177,32,19,76,76,5,38,196,15,72,14,14,72,15,151,157,35,93,14,14,67,135,2,
6708
66,151,8,38,126,0,8,0,22,0,44,132,137,53,1,39,14,3,18,6,20,30,1,51,50,55,54,52,39,38,35,34,3,7,35,19,110,2,8,8,89,21,20,7,22,18,22,23,35,39,202,213,48,46,13,13,39,29,18,35,12,34,26,
6709
16,33,21,22,5,20,52,29,101,54,105,214,61,14,46,77,56,42,39,61,46,120,34,14,104,56,1,3,158,156,43,43,132,97,62,2,11,26,44,31,11,21,20,45,13,44,253,115,183,2,145,35,72,38,22,70,38,39,
6710
53,66,41,138,254,141,105,43,183,0,130,0,32,2,132,4,38,78,2,189,0,7,0,23,131,141,46,17,35,14,1,7,6,15,1,35,19,33,21,35,21,51,132,3,63,33,53,164,154,53,12,38,13,30,30,50,92,205,1,120,
6711
169,153,153,178,254,240,1,3,1,107,45,133,50,106,108,180,2,100,83,5,32,180,131,74,45,1,0,70,255,71,2,25,2,203,0,51,0,0,1,130,202,78,63,5,131,217,43,55,21,6,7,34,6,7,22,23,22,21,20,71,
6712
149,5,37,51,50,53,52,46,3,71,33,7,8,88,55,54,50,23,2,25,79,87,98,49,49,75,45,76,59,68,20,19,47,43,6,22,8,26,3,15,120,22,25,40,36,39,62,14,3,7,7,4,129,73,78,14,45,116,55,159,78,2,67,
6713
58,71,74,142,175,70,42,34,10,15,97,23,9,3,1,34,7,32,19,82,11,61,15,43,14,26,8,9,9,6,8,87,96,171,89,50,152,50,25,39,132,226,43,0,98,0,0,2,39,3,104,0,11,0,19,101,29,13,68,3,7,50,98,1,
6714
188,254,170,1,70,254,186,1,95,240,21,71,21,92,18,62,18,134,217,36,2,237,23,77,23,130,2,130,72,32,2,138,71,32,15,142,71,34,7,35,55,138,67,35,113,114,77,98,134,63,35,3,104,123,123,138,
6715
59,32,102,130,131,32,24,142,59,67,179,9,33,31,1,138,68,32,151,67,167,7,35,95,20,33,52,134,77,33,2,233,67,152,6,36,23,39,63,0,3,134,143,32,101,130,83,33,25,0,130,234,101,247,11,32,3,
6716
66,195,6,33,55,54,66,209,11,133,13,138,100,44,85,15,71,15,3,4,28,51,15,196,15,72,14,132,8,134,105,41,3,20,14,14,67,7,4,3,14,67,134,7,36,0,0,2,0,100,130,4,34,3,3,104,130,111,32,18,130,
6717
195,95,33,5,43,21,35,17,51,21,3,46,1,39,51,22,23,101,128,6,38,216,21,70,22,92,47,52,101,135,7,38,2,237,23,77,23,60,63,140,63,32,15,142,63,34,7,35,55,134,60,35,77,114,77,98,135,57,65,
6718
60,5,135,119,32,102,130,119,32,21,144,55,33,54,55,130,120,33,35,38,134,61,41,208,82,70,85,20,95,44,62,71,48,136,67,41,61,84,102,23,51,74,51,0,0,3,134,191,32,101,130,71,34,23,0,35,142,
6719
73,67,255,22,134,87,32,58,67,238,12,136,91,32,20,67,223,11,42,2,0,4,0,0,2,39,2,189,0,19,131,93,38,55,51,50,55,62,1,55,81,133,6,47,43,1,21,51,21,35,3,17,35,53,51,17,51,50,22,21,106,
6720
19,5,8,54,170,48,66,45,43,36,10,28,9,21,50,54,94,48,132,132,103,63,63,151,171,162,81,45,59,64,99,78,15,17,43,21,57,120,85,36,87,32,33,221,70,254,179,1,77,70,1,42,170,181,179,85,45,
6721
21,20,130,102,33,0,70,130,4,38,35,3,102,0,16,0,60,130,201,32,17,96,135,5,41,17,51,17,35,38,39,38,39,17,19,69,134,5,33,30,1,84,192,8,48,61,1,51,6,7,6,34,39,46,4,47,1,46,1,39,46,1,80,
6722
206,5,8,121,70,128,16,44,34,93,65,97,128,74,59,93,26,39,63,27,25,43,28,31,20,3,10,24,4,11,7,15,9,11,62,3,53,17,28,8,18,11,9,12,15,3,18,4,5,3,7,6,3,7,26,9,2,2,189,37,100,78,215,147,
6723
2,65,253,67,167,137,215,59,253,190,3,0,44,31,27,13,11,1,3,13,1,4,13,11,19,3,72,23,7,1,2,4,3,6,7,2,10,1,4,1,3,3,27,8,6,0,0,3,0,58,255,243,2,46,3,104,0,13,0,26,0,34,83,209,11,43,35,34,
6724
6,16,39,16,51,50,23,22,21,16,131,164,33,38,19,130,162,131,210,8,53,198,35,75,76,35,34,34,34,77,76,68,106,250,126,63,61,192,27,94,47,140,246,21,70,22,92,18,63,18,130,67,67,64,156,157,
6725
64,66,132,254,205,152,1,109,90,94,181,254,190,36,5,22,66,2,162,67,178,8,142,115,32,30,156,115,35,1,7,35,55,148,111,36,1,129,114,77,98,150,108,34,3,29,123,71,159,5,133,219,32,102,132,
6726
219,32,39,157,103,67,240,11,149,112,32,86,67,251,11,150,121,33,2,158,68,11,12,139,127,32,70,156,127,66,27,40,148,155,32,148,66,35,38,151,181,32,181,66,41,34,34,0,0,4,66,43,6,40,101,
6727
0,13,0,26,0,38,0,50,156,209,32,1,67,188,22,148,192,33,1,143,67,203,12,151,167,32,201,67,218,11,8,34,0,1,0,75,0,82,2,30,2,9,0,36,0,0,37,7,39,54,63,1,54,55,46,3,39,55,30,2,23,54,55,23,
6728
14,3,7,109,205,5,58,7,38,39,46,1,1,52,174,59,21,32,64,40,18,22,64,48,30,11,58,55,79,30,11,47,128,59,132,12,63,11,30,24,56,32,21,59,11,15,57,69,247,165,55,20,30,60,37,17,20,61,45,28,
6729
11,55,50,76,28,11,43,122,55,132,12,43,11,28,22,53,30,20,55,11,14,53,67,0,130,0,52,3,0,4,255,223,2,88,2,221,0,18,0,33,0,72,0,0,9,1,30,2,78,109,5,51,38,53,39,38,53,38,39,52,5,54,55,38,
6730
35,34,7,6,7,6,29,1,68,91,5,34,46,1,39,89,67,5,32,53,73,143,5,41,55,22,23,7,22,23,30,1,23,22,68,121,5,8,134,34,38,39,38,1,186,254,255,15,50,37,21,78,33,34,1,2,1,1,1,254,234,168,84,23,
6731
91,42,19,36,13,33,2,39,44,28,10,31,10,89,24,5,1,1,4,98,63,88,116,57,70,35,15,84,14,4,13,6,2,3,16,30,92,46,68,49,42,17,41,1,231,254,167,35,33,11,67,73,148,13,23,10,37,8,7,7,6,10,251,
6732
225,113,78,13,27,30,62,182,47,14,10,18,172,56,39,6,21,6,119,56,69,16,16,39,41,221,88,50,77,95,23,12,112,28,15,49,51,18,27,140,68,133,48,22,14,7,16,130,222,50,0,2,0,74,255,243,2,31,
6733
3,102,0,34,0,41,0,0,5,34,39,81,86,5,33,38,39,80,141,5,37,51,50,55,62,1,53,131,11,130,223,130,227,37,14,1,3,38,39,51,130,202,8,77,1,46,67,42,39,13,34,9,19,2,2,1,101,11,33,89,85,35,11,
6734
2,102,22,12,17,30,10,10,48,71,21,49,65,93,18,61,19,13,21,17,12,31,25,41,42,18,23,1,228,254,37,80,20,63,57,19,61,191,1,54,254,80,102,73,19,27,20,5,5,27,4,2,247,57,67,23,77,24,0,136,
6735
135,32,104,130,135,32,40,164,135,37,19,6,7,35,54,55,156,134,37,106,56,59,76,65,33,161,133,37,3,117,61,62,83,40,65,11,12,32,46,165,131,68,77,9,32,23,156,137,32,68,75,247,10,161,143,
6736
33,2,246,76,2,11,33,0,3,65,163,6,38,101,0,34,0,46,0,58,165,153,67,149,22,156,165,32,134,67,156,12,161,167,33,3,33,67,167,12,32,2,75,239,6,36,102,0,19,0,24,104,173,21,36,19,7,35,54,
6737
55,104,178,18,36,148,115,76,44,54,104,183,20,37,1,175,124,58,66,0,72,191,6,42,71,2,189,0,8,0,23,0,0,37,50,86,24,5,8,48,21,7,17,51,21,51,50,23,22,21,20,7,6,43,1,21,1,62,158,60,36,75,
6738
103,102,102,127,192,46,16,63,65,126,127,250,124,75,30,18,247,250,2,189,127,112,38,38,117,47,50,92,247,5,40,94,255,243,2,62,2,219,0,60,68,217,9,66,246,6,34,53,52,55,67,206,6,35,21,17,
6739
35,17,130,12,130,91,39,23,6,7,6,21,20,31,2,109,115,5,67,194,9,8,110,39,229,75,60,84,26,7,22,8,26,70,84,6,1,90,30,39,4,114,91,20,7,93,119,39,105,39,116,3,116,35,11,24,10,38,22,32,45,
6740
19,31,30,10,16,55,97,50,41,9,14,23,86,29,52,12,20,32,32,7,25,35,53,55,10,12,89,42,15,8,103,70,23,34,253,236,2,23,151,33,12,13,36,156,9,60,19,18,38,19,10,25,11,22,27,26,45,54,56,35,
6741
14,10,41,10,2,3,7,0,0,0,3,0,68,130,179,40,48,3,18,0,13,0,66,0,77,130,183,40,20,23,22,50,54,55,54,61,1,98,167,5,33,7,53,102,237,5,32,51,104,105,8,93,181,6,41,30,1,23,35,38,53,38,39,
6742
6,7,83,210,9,88,104,5,32,39,95,200,6,8,130,160,88,13,52,60,21,44,116,123,29,10,138,97,92,10,12,20,43,18,37,43,92,55,58,16,3,3,12,1,10,3,4,6,4,1,92,18,2,2,15,44,39,61,37,82,49,51,63,
6743
62,122,123,76,27,32,50,73,28,11,99,9,24,39,52,17,159,84,15,2,26,25,48,89,18,58,20,1,24,50,87,4,3,5,13,4,7,30,31,44,8,8,30,80,115,14,13,22,35,40,26,10,17,14,2,42,19,9,10,30,28,23,12,
6744
45,39,83,86,47,46,13,92,20,8,143,55,80,31,11,11,30,49,65,22,142,223,32,72,196,223,68,33,5,180,221,37,143,12,150,77,65,76,184,216,38,1,64,12,165,84,93,0,65,183,16,32,78,196,215,43,3,
6745
7,35,55,51,30,1,23,35,38,39,38,180,221,43,26,90,69,123,73,23,77,23,69,17,28,29,185,227,40,3,116,177,33,111,33,22,36,36,138,231,39,2,250,0,13,0,66,0,103,196,231,36,55,50,53,51,20,88,
6746
223,5,33,47,1,130,235,32,35,71,102,5,75,93,5,36,23,30,4,23,22,180,253,8,33,40,37,62,56,18,16,26,12,20,19,10,12,7,14,4,5,10,29,6,2,1,62,26,25,46,18,18,23,18,7,20,10,4,6,65,19,56,41,
6747
223,73,94,30,8,5,8,15,10,9,130,88,49,39,14,19,61,36,35,6,13,16,6,18,7,2,5,0,0,0,4,67,195,5,41,2,217,0,13,0,66,0,78,0,90,65,37,69,69,233,22,65,27,52,35,123,15,71,15,130,2,32,196,93,
6748
166,5,65,7,56,32,182,93,222,11,135,247,33,3,77,132,247,34,82,0,96,196,247,48,2,14,1,20,30,1,51,50,54,55,54,53,52,46,1,34,23,85,42,6,37,54,51,50,23,22,20,180,253,55,68,22,11,33,26,16,
6749
32,33,6,5,32,28,32,115,40,59,56,40,41,82,55,58,41,39,65,7,56,8,47,1,55,20,26,45,30,11,31,12,12,15,31,31,10,162,38,38,37,54,55,74,37,35,113,0,0,3,0,20,255,243,2,88,2,27,0,14,0,26,0,
6750
80,0,0,55,6,7,6,20,86,151,5,41,61,1,35,34,55,51,53,52,38,39,130,214,38,7,6,21,19,50,55,21,130,29,36,35,34,39,38,39,134,7,34,53,52,55,110,97,6,37,35,34,7,6,7,53,131,244,132,248,35,29,
6751
1,35,21,86,17,5,8,132,176,51,15,8,23,22,32,67,15,10,24,42,149,164,15,4,18,33,33,16,45,108,75,52,51,42,17,23,80,40,14,8,31,58,21,32,90,39,23,112,36,46,60,24,23,49,49,60,8,8,72,63,91,
6752
34,34,94,89,34,36,246,1,60,23,236,9,36,18,70,21,24,50,33,46,55,67,24,57,38,7,25,7,8,23,107,254,241,48,80,32,5,2,43,13,18,55,15,4,63,37,56,122,34,10,41,56,30,31,30,4,5,79,32,60,60,56,
6753
54,145,42,17,1,6,10,123,18,9,0,1,0,82,255,71,2,3,130,223,34,56,0,0,90,23,5,103,203,9,32,55,132,170,36,23,21,38,39,38,130,189,32,21,95,10,7,82,168,7,71,203,5,8,94,34,39,53,22,1,53,63,
6754
14,2,4,11,4,116,66,73,14,25,36,74,125,67,52,19,21,56,57,20,66,34,103,104,34,56,11,70,46,7,8,40,46,5,20,7,44,46,33,26,36,26,40,36,128,43,16,24,4,8,14,6,6,66,73,131,71,36,61,35,73,22,
6755
8,10,91,47,8,3,14,40,149,150,40,14,1,10,34,6,7,90,25,9,3,1,48,44,51,20,90,130,5,54,0,3,0,62,255,243,2,44,3,18,0,12,0,39,0,50,0,0,19,51,54,59,1,130,152,132,154,65,121,6,34,43,1,34,119,
6756
116,8,33,22,29,109,161,5,32,3,71,60,6,8,34,162,64,25,22,192,2,8,12,17,35,136,42,43,170,87,108,74,75,12,12,23,129,75,73,111,66,86,110,61,60,254,114,140,19,8,71,41,6,8,45,38,52,17,1,
6757
53,1,44,20,34,19,39,42,41,254,188,54,86,32,6,2,73,73,129,161,74,42,67,68,119,42,3,150,28,3,2,38,55,80,31,11,11,31,48,65,22,0,130,0,141,155,32,47,169,155,37,19,7,35,62,3,55,161,153,
6758
39,167,162,77,17,51,39,24,9,159,150,38,215,177,22,65,48,31,11,145,147,32,51,169,147,70,180,11,161,153,32,2,70,161,8,33,29,28,159,157,32,154,70,135,11,32,4,65,207,5,41,2,217,0,12,0,
6759
39,0,51,0,63,169,161,86,133,23,161,173,38,147,15,71,16,16,71,15,69,53,6,159,175,32,77,69,28,11,50,2,0,109,255,252,2,34,3,6,0,14,0,27,0,0,5,35,34,38,109,250,6,37,23,22,59,1,1,38,73,
6760
163,7,8,54,2,34,117,81,92,122,214,52,16,22,108,254,237,20,29,30,45,28,10,99,9,24,38,52,17,4,100,91,1,16,67,254,173,86,24,7,2,15,21,33,33,48,31,11,11,31,48,66,21,0,0,0,2,0,134,136,91,
6761
130,15,142,91,37,3,7,35,62,2,55,138,87,38,50,162,78,27,81,24,9,139,80,35,192,177,34,101,65,247,5,139,75,32,25,145,167,84,8,6,34,39,6,7,138,80,43,254,100,92,31,74,92,31,70,68,22,68,
6762
22,139,85,40,16,132,44,132,44,86,29,86,29,130,163,32,3,133,163,33,2,217,130,255,34,26,0,38,144,89,85,74,7,85,72,11,131,11,138,102,35,100,15,71,15,130,2,38,195,15,72,14,14,72,15,139,
6763
104,32,66,70,134,12,34,0,2,0,109,235,5,46,219,0,46,0,65,0,0,1,22,23,14,1,7,22,21,72,98,6,69,82,5,43,22,59,2,50,23,46,2,39,38,39,46,1,130,205,34,39,54,55,85,93,5,32,3,112,248,11,8,123,
6764
38,43,1,34,7,6,1,211,10,6,23,78,24,190,98,56,86,112,65,62,61,62,123,17,5,2,2,1,2,4,1,8,11,5,7,8,16,11,5,15,124,15,79,40,17,58,16,109,36,28,157,37,37,68,67,39,37,55,7,9,25,13,23,113,
6765
30,10,2,196,30,16,7,24,7,190,186,151,72,38,69,72,123,127,67,70,1,1,2,9,13,7,10,9,17,12,5,5,38,46,25,12,18,58,18,39,28,254,99,92,49,51,51,51,89,113,68,4,2,6,109,36,0,0,0,2,110,239,6,
6766
39,225,0,18,0,53,0,0,19,110,229,5,32,17,110,248,10,73,53,10,32,39,131,200,32,35,130,170,32,7,73,51,6,80,132,5,8,88,189,51,115,170,92,110,97,28,9,92,83,7,186,38,62,26,25,45,43,38,4,
6767
9,11,8,4,3,7,8,17,10,7,2,63,27,25,45,34,36,7,3,19,16,3,5,1,191,92,212,254,185,1,71,137,95,30,41,254,214,2,14,49,188,72,65,33,35,38,3,9,10,5,3,2,3,18,11,44,63,35,35,28,7,4,18,9,3,3,
6768
0,3,65,95,5,43,3,18,0,13,0,27,0,40,0,0,1,34,114,203,7,36,53,52,39,38,3,69,68,10,37,16,6,3,46,1,39,130,2,8,69,51,30,3,23,1,52,142,80,27,35,106,27,10,81,26,36,175,49,15,136,45,58,117,
6769
61,62,122,124,20,60,28,16,28,11,100,9,24,38,52,17,1,210,203,150,41,13,116,38,50,151,39,13,254,33,158,51,67,202,56,18,71,72,254,243,140,2,110,22,65,32,16,69,52,9,141,131,32,33,157,131,
6770
76,32,5,149,126,37,51,23,140,76,82,58,152,119,38,3,31,23,154,106,71,0,142,243,32,38,157,111,69,3,8,33,46,1,149,116,42,118,90,70,123,74,23,77,23,70,17,56,152,121,33,2,226,68,239,5,32,
6771
72,135,123,39,2,225,0,13,0,27,0,62,158,123,75,76,9,66,22,22,149,146,32,53,66,32,31,65,153,24,32,166,66,41,25,34,0,0,4,66,43,5,33,2,217,132,187,34,39,0,51,157,189,69,155,23,149,179,
6772
32,31,80,199,12,65,73,25,32,149,68,31,13,49,3,0,44,0,71,2,60,2,22,0,11,0,15,0,27,0,0,37,75,90,10,36,37,53,33,21,39,138,15,44,1,114,16,92,15,15,92,16,254,186,2,16,202,133,10,41,85,14,
6773
14,87,13,13,90,80,80,170,130,8,49,15,15,0,3,0,24,255,211,2,75,2,57,0,10,0,20,0,47,130,225,36,6,7,22,23,22,98,170,6,114,7,6,37,54,3,6,7,38,39,106,2,5,38,51,50,23,54,55,22,23,68,147,
6774
5,8,102,43,1,38,1,182,40,191,21,35,25,55,27,81,42,36,65,103,31,10,14,187,215,50,30,44,2,85,40,136,44,58,101,59,29,45,21,25,82,43,137,45,59,26,87,1,111,46,218,25,12,7,13,41,148,67,94,
6775
44,111,34,31,74,56,212,254,182,55,32,34,2,94,67,111,202,56,18,52,33,49,18,17,93,63,115,204,55,17,7,0,0,0,2,0,97,255,243,2,13,3,5,0,24,0,34,130,229,74,83,7,83,241,8,33,54,53,130,10,
6776
38,35,38,3,46,2,39,51,130,176,8,60,23,1,177,35,78,24,36,119,33,11,92,27,29,54,97,28,9,92,83,2,138,28,96,28,11,100,13,29,70,28,79,67,19,6,119,40,54,1,69,254,187,74,31,34,96,31,40,1,
6777
41,253,243,23,2,61,29,106,31,11,17,36,90,130,96,139,111,32,30,154,111,67,142,6,145,108,37,37,20,143,76,41,99,150,104,36,238,21,156,55,122,140,211,32,35,154,99,32,1,79,57,7,33,6,7,146,
6778
213,33,254,220,67,126,5,35,67,23,67,23,150,110,36,61,177,33,111,33,70,188,5,32,3,65,71,5,39,2,217,0,24,0,36,0,48,154,117,66,190,24,145,235,32,17,66,187,12,150,132,32,113,66,184,12,
6779
44,2,0,52,255,55,2,65,3,5,0,38,0,44,130,133,44,19,51,14,3,7,14,2,15,1,14,2,7,6,131,1,48,43,1,53,51,50,55,54,55,46,1,39,38,39,51,23,30,1,65,105,6,8,89,59,164,98,55,58,25,21,8,13,14,
6780
5,2,28,10,17,13,6,18,15,26,12,38,41,60,54,61,27,12,22,35,77,28,73,3,98,50,62,42,173,44,119,76,31,109,115,1,155,132,140,62,49,20,33,32,14,6,72,25,32,26,11,30,10,18,3,12,73,59,23,54,
6781
85,187,65,174,7,125,152,107,2,119,47,129,42,134,0,0,0,2,0,95,130,143,40,42,2,224,0,10,0,30,0,0,107,185,5,37,23,22,51,50,16,5,99,147,8,34,35,34,39,130,141,8,58,17,35,17,51,1,68,101,
6782
27,9,77,26,34,134,254,241,48,103,99,60,57,58,60,99,40,20,41,38,11,92,92,1,210,115,38,50,148,43,13,1,151,7,80,74,73,130,131,72,72,8,16,36,20,254,244,3,169,0,0,3,133,243,33,2,204,130,
6783
243,34,50,0,62,133,245,35,1,7,14,9,130,248,33,7,6,145,240,32,21,67,186,9,32,7,138,11,56,1,59,164,98,55,58,12,16,25,7,5,3,4,2,4,4,7,7,22,47,13,6,40,65,83,65,2,13,32,153,65,148,12,53,
6784
115,1,155,132,140,31,37,60,17,13,8,7,6,8,12,18,19,61,92,16,7,43,65,10,12,38,47,62,18,14,66,15,15,132,5,43,0,1,0,18,255,243,2,18,2,203,0,65,130,167,32,6,130,247,46,38,39,35,55,54,55,
6785
51,53,38,61,1,38,52,55,53,130,2,37,35,55,51,54,55,54,111,182,10,48,7,51,6,7,35,21,20,6,29,1,22,21,51,14,1,7,35,104,231,5,48,62,1,55,2,18,65,146,91,32,63,28,87,13,7,5,58,1,130,0,8,86,
6786
83,25,62,42,130,45,38,104,66,8,8,58,78,108,43,14,6,240,15,9,221,1,1,180,5,15,5,150,10,45,44,73,53,65,8,17,8,25,38,1,33,33,62,139,26,16,10,10,2,5,13,9,11,10,15,1,2,10,50,205,48,17,39,
6787
97,6,7,47,110,36,48,34,16,9,2,6,4,62,2,3,10,32,10,92,52,50,36,6,102,24,5,35,0,14,0,174,130,193,32,0,132,0,34,1,0,4,134,11,32,1,130,7,32,10,134,11,32,2,130,7,32,16,134,11,36,3,0,29,
6788
0,78,134,11,131,43,32,112,134,11,36,5,0,9,0,134,134,11,32,6,130,7,44,148,0,3,0,1,4,9,0,0,0,2,0,0,134,11,32,1,130,11,32,6,134,11,32,2,130,11,32,12,134,11,36,3,0,58,0,18,134,11,32,4,
6789
130,23,32,108,134,11,32,5,130,21,32,114,134,11,32,6,130,23,35,144,0,46,0,143,2,39,70,0,111,0,110,0,116,0,131,7,40,114,0,103,0,101,0,32,0,50,130,36,32,48,130,7,32,58,130,3,32,46,134,
6790
7,38,50,0,49,0,45,0,56,130,3,34,50,0,48,130,33,51,53,0,0,70,111,110,116,70,111,114,103,101,32,50,46,48,32,58,32,46,130,3,39,50,49,45,56,45,50,48,50,130,30,133,107,32,86,130,81,36,114,
6791
0,115,0,105,132,103,32,32,130,89,40,0,86,101,114,115,105,111,110,32,136,140,33,2,0,132,0,35,255,156,0,35,130,8,32,1,130,3,141,2,32,195,132,21,32,2,130,201,58,4,0,5,0,6,0,7,0,8,0,9,
6792
0,10,0,11,0,12,0,13,0,14,0,15,0,16,0,17,130,235,62,19,0,20,0,21,0,22,0,23,0,24,0,25,0,26,0,27,0,28,0,29,0,30,0,31,0,32,0,33,0,34,130,93,50,36,0,37,0,38,0,39,0,40,0,41,0,42,0,43,0,44,
6793
0,45,130,145,32,47,130,209,32,49,130,211,9,38,51,0,52,0,53,0,54,0,55,0,56,0,57,0,58,0,59,0,60,0,61,0,62,0,63,0,64,0,65,0,66,0,67,0,68,0,69,0,70,0,71,0,72,0,73,0,74,0,75,0,76,0,77,0,
6794
78,0,79,0,80,0,81,0,82,0,83,0,84,0,85,0,86,0,87,0,88,0,89,0,90,0,91,0,92,0,93,0,94,0,95,0,96,0,97,0,172,0,163,0,132,0,133,0,189,0,150,0,232,0,134,0,142,0,139,0,157,0,169,0,164,1,2,
6795
0,138,0,218,0,131,0,147,0,242,0,243,0,141,0,151,0,136,0,195,0,222,0,241,0,158,0,170,0,245,0,244,0,246,0,162,0,173,0,201,0,199,0,174,0,98,0,99,0,144,0,100,0,203,0,101,0,200,0,202,0,
6796
207,0,204,0,205,0,206,0,233,0,102,0,211,0,208,0,209,0,175,0,103,0,240,0,145,0,214,0,212,0,213,0,104,0,235,0,237,0,137,0,106,0,105,0,107,0,109,0,108,0,110,0,160,0,111,0,113,0,112,0,
6797
114,0,115,0,117,0,116,0,118,0,119,0,234,0,120,0,122,0,121,0,123,0,125,0,124,0,184,0,161,0,127,0,126,0,128,0,129,0,236,0,238,0,186,1,3,7,117,110,105,48,48,97,100,131,7,45,50,48,97,99,
6798
0,0,0,1,255,255,0,2,0,1,130,9,32,12,130,3,32,16,130,3,36,2,0,0,0,4,134,7,32,0,132,25,36,0,223,214,203,49,130,17,24,92,127,12,5,250,205,249,72,146,
6799
};
6800
6801
static const char* GetDefaultCompressedFontDataProggyVector(int* out_size)
6802
{
6803
*out_size = proggy_vector_minimal_ttf_compressed_size;
6804
return (const char*)proggy_vector_minimal_ttf_compressed_data;
6805
}
6806
6807
#endif // #ifndef IMGUI_DISABLE_DEFAULT_FONT
6808
6809
#endif // #ifndef IMGUI_DISABLE
6810
6811