You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stanislav Vasilev edited this page Sep 15, 2024
·
1 revision
In order to use this library in different languages we offer a C API for most of the functions in the library.
Note
The C API does not require you to use cimgui or to have a C header file for dear imgui!
Using the C API
The C API is located under the C folder in the CUImGuiTextUtils.h. To set up fonts and initialise it with global data, use the following code:
UImGui_CTextUtilsData* data = UImGui_TextUtilsData_allocate();
... // Create fontsUImGui_TextUtilsData_setFonts(data, bold, italic, boldItalic, monospace, smallFont);
UImGui_TextUtils_initTextUtilsData(data);
... // Render// Free the dataUImGui_TextUtilsData_free(data);
Conventions
All functions and types are prefixed with their namespaces and containing classes separated by _. For example, the UImGui::TextUtils::Bold function becomes UImGui_TextUtils_Bold.
In C++, functions like UImGui::TextUtils::Underline have a variant that adds an underline to an existing component, as well as a variadic list one. The variadic list variants have _fmt added to the function name. Example:
voidUImGui_TextUtils_Underline(UImGui_TextUtils_Colour colour);
// Format variant
UImGui_TextUtils_WidgetState UImGui_TextUtils_Underline_fmt(UImGui_TextUtils_Colour colour, constchar* fmt, ...);
// Format variant with list
UImGui_TextUtils_WidgetState UImGui_TextUtils_Underline_fmtV(UImGui_TextUtils_Colour colour, constchar* fmt, va_list args);
UImGui_TextUtils_WidgetState UImGui_TextUtils_UnderlineWrapped(constchar* text, constchar* end, UImGui_TextUtils_Colour colour);
Note
The colour argument to variadic functions is always the first one, due to limitations of the C language.
Tip
If you want to use the default text colour, pass the UIMGUI_C_TEXT_COLOUR macro.
C types
These are the C alternatives of the following C++ types: