Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
imgui_draw.cpp File Reference
#include "imgui.h"
#include "imgui_internal.h"
#include "imconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include "imstb_rectpack.h"
#include "imstb_truetype.h"
+ Include dependency graph for imgui_draw.cpp:

Go to the source code of this file.

Classes

struct  ImFontBuildSrcData
 
struct  ImFontBuildDstData
 

Macros

#define IMGUI_DEFINE_MATH_OPERATORS
 
#define STBRP_STATIC
 
#define STBRP_ASSERT(x)   do { IM_ASSERT(x); } while (0)
 
#define STBRP_SORT   ImQsort
 
#define STB_RECT_PACK_IMPLEMENTATION
 
#define STBTT_malloc(x, u)   ((void)(u), IM_ALLOC(x))
 
#define STBTT_free(x, u)   ((void)(u), IM_FREE(x))
 
#define STBTT_assert(x)   do { IM_ASSERT(x); } while(0)
 
#define STBTT_fmod(x, y)   ImFmod(x,y)
 
#define STBTT_sqrt(x)   ImSqrt(x)
 
#define STBTT_pow(x, y)   ImPow(x,y)
 
#define STBTT_fabs(x)   ImFabs(x)
 
#define STBTT_ifloor(x)   ((int)ImFloorSigned(x))
 
#define STBTT_iceil(x)   ((int)ImCeil(x))
 
#define STBTT_STATIC
 
#define STB_TRUETYPE_IMPLEMENTATION
 
#define ImDrawCmd_HeaderSize   (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int))
 
#define ImDrawCmd_HeaderCompare(CMD_LHS, CMD_RHS)   (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize))
 
#define ImDrawCmd_HeaderCopy(CMD_DST, CMD_SRC)   (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize))
 
#define IM_NORMALIZE2F_OVER_ZERO(VX, VY)   do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImRsqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)
 
#define IM_FIXNORMAL2F_MAX_INVLEN2   100.0f
 
#define IM_FIXNORMAL2F(VX, VY)   do { 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; } } while (0)
 
#define stb__in2(x)   ((i[x] << 8) + i[(x)+1])
 
#define stb__in3(x)   ((i[x] << 16) + stb__in2((x)+1))
 
#define stb__in4(x)   ((i[x] << 24) + stb__in3((x)+1))
 

Functions

ImVec2 ImBezierCubicCalc (const ImVec2 &p1, const ImVec2 &p2, const ImVec2 &p3, const ImVec2 &p4, float t)
 
ImVec2 ImBezierQuadraticCalc (const ImVec2 &p1, const ImVec2 &p2, const ImVec2 &p3, float t)
 
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)
 
static void PathBezierQuadraticCurveToCasteljau (ImVector< ImVec2 > *path, float x1, float y1, float x2, float y2, float x3, float y3, float tess_tol, int level)
 
 IM_STATIC_ASSERT (ImDrawFlags_RoundCornersTopLeft==(1<< 4))
 
static ImDrawFlags FixRectCornerFlags (ImDrawFlags flags)
 
static unsigned int stb_decompress_length (const unsigned char *input)
 
static unsigned int stb_decompress (unsigned char *output, const unsigned char *input, unsigned int length)
 
static const char * GetDefaultCompressedFontDataTTFBase85 ()
 
static unsigned int Decode85Byte (char c)
 
static void Decode85 (const unsigned char *src, unsigned char *dst)
 
void ImFontAtlasBuildMultiplyCalcLookupTable (unsigned char out_table[256], float in_brighten_factor)
 
void ImFontAtlasBuildMultiplyRectAlpha8 (const unsigned char table[256], unsigned char *pixels, int x, int y, int w, int h, int stride)
 
static void UnpackBitVectorToFlatIndexList (const ImBitVector *in, ImVector< int > *out)
 
static bool ImFontAtlasBuildWithStbTruetype (ImFontAtlas *atlas)
 
const ImFontBuilderIOImFontAtlasGetBuilderForStbTruetype ()
 
void ImFontAtlasBuildSetupFont (ImFontAtlas *atlas, ImFont *font, ImFontConfig *font_config, float ascent, float descent)
 
void ImFontAtlasBuildPackCustomRects (ImFontAtlas *atlas, void *stbrp_context_opaque)
 
void ImFontAtlasBuildRender8bppRectFromString (ImFontAtlas *atlas, int x, int y, int w, int h, const char *in_str, char in_marker_char, unsigned char in_marker_pixel_value)
 
void ImFontAtlasBuildRender32bppRectFromString (ImFontAtlas *atlas, int x, int y, int w, int h, const char *in_str, char in_marker_char, unsigned int in_marker_pixel_value)
 
static void ImFontAtlasBuildRenderDefaultTexData (ImFontAtlas *atlas)
 
static void ImFontAtlasBuildRenderLinesTexData (ImFontAtlas *atlas)
 
void ImFontAtlasBuildInit (ImFontAtlas *atlas)
 
void ImFontAtlasBuildFinish (ImFontAtlas *atlas)
 
static void UnpackAccumulativeOffsetsIntoRanges (int base_codepoint, const short *accumulative_offsets, int accumulative_offsets_count, ImWchar *out_ranges)
 
static float ImAcos01 (float x)
 
static void stb__match (const unsigned char *data, unsigned int length)
 
static void stb__lit (const unsigned char *data, unsigned int length)
 
static const unsigned char * stb_decompress_token (const unsigned char *i)
 
static unsigned int stb_adler32 (unsigned int adler32, unsigned char *buffer, unsigned int buflen)
 

Variables

const int FONT_ATLAS_DEFAULT_TEX_DATA_W = 108
 
const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27
 
static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS [FONT_ATLAS_DEFAULT_TEX_DATA_W *FONT_ATLAS_DEFAULT_TEX_DATA_H+1]
 
static const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA [ImGuiMouseCursor_COUNT][3]
 
static unsigned char * stb__barrier_out_e
 
static unsigned char * stb__barrier_out_b
 
static const unsigned char * stb__barrier_in_b
 
static unsigned char * stb__dout
 
static const char proggy_clean_ttf_compressed_data_base85 [11980+1]
 

Class Documentation

◆ ImFontBuildSrcData

struct ImFontBuildSrcData
+ Collaboration diagram for ImFontBuildSrcData:
Class Members
int DstIndex
stbtt_fontinfo FontInfo
int GlyphsCount
int GlyphsHighest
ImVector< int > GlyphsList
ImBitVector GlyphsSet
stbtt_packedchar * PackedChars
stbtt_pack_range PackRange
stbrp_rect * Rects
const ImWchar * SrcRanges

◆ ImFontBuildDstData

struct ImFontBuildDstData
+ Collaboration diagram for ImFontBuildDstData:
Class Members
int GlyphsCount
int GlyphsHighest
ImBitVector GlyphsSet
int SrcCount

Macro Definition Documentation

◆ IM_FIXNORMAL2F

#define IM_FIXNORMAL2F (   VX,
  VY 
)    do { 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; } } while (0)

◆ IM_FIXNORMAL2F_MAX_INVLEN2

#define IM_FIXNORMAL2F_MAX_INVLEN2   100.0f

◆ IM_NORMALIZE2F_OVER_ZERO

#define IM_NORMALIZE2F_OVER_ZERO (   VX,
  VY 
)    do { float d2 = VX*VX + VY*VY; if (d2 > 0.0f) { float inv_len = ImRsqrt(d2); VX *= inv_len; VY *= inv_len; } } while (0)

◆ ImDrawCmd_HeaderCompare

#define ImDrawCmd_HeaderCompare (   CMD_LHS,
  CMD_RHS 
)    (memcmp(CMD_LHS, CMD_RHS, ImDrawCmd_HeaderSize))

◆ ImDrawCmd_HeaderCopy

#define ImDrawCmd_HeaderCopy (   CMD_DST,
  CMD_SRC 
)    (memcpy(CMD_DST, CMD_SRC, ImDrawCmd_HeaderSize))

◆ ImDrawCmd_HeaderSize

#define ImDrawCmd_HeaderSize   (IM_OFFSETOF(ImDrawCmd, VtxOffset) + sizeof(unsigned int))

◆ IMGUI_DEFINE_MATH_OPERATORS

#define IMGUI_DEFINE_MATH_OPERATORS

◆ stb__in2

#define stb__in2 (   x)    ((i[x] << 8) + i[(x)+1])

◆ stb__in3

#define stb__in3 (   x)    ((i[x] << 16) + stb__in2((x)+1))

◆ stb__in4

#define stb__in4 (   x)    ((i[x] << 24) + stb__in3((x)+1))

◆ STB_RECT_PACK_IMPLEMENTATION

#define STB_RECT_PACK_IMPLEMENTATION

◆ STB_TRUETYPE_IMPLEMENTATION

#define STB_TRUETYPE_IMPLEMENTATION

◆ STBRP_ASSERT

#define STBRP_ASSERT (   x)    do { IM_ASSERT(x); } while (0)

◆ STBRP_SORT

#define STBRP_SORT   ImQsort

◆ STBRP_STATIC

#define STBRP_STATIC

◆ STBTT_assert

#define STBTT_assert (   x)    do { IM_ASSERT(x); } while(0)

◆ STBTT_fabs

#define STBTT_fabs (   x)    ImFabs(x)

◆ STBTT_fmod

#define STBTT_fmod (   x,
 
)    ImFmod(x,y)

◆ STBTT_free

#define STBTT_free (   x,
 
)    ((void)(u), IM_FREE(x))

◆ STBTT_iceil

#define STBTT_iceil (   x)    ((int)ImCeil(x))

◆ STBTT_ifloor

#define STBTT_ifloor (   x)    ((int)ImFloorSigned(x))

◆ STBTT_malloc

#define STBTT_malloc (   x,
 
)    ((void)(u), IM_ALLOC(x))

◆ STBTT_pow

#define STBTT_pow (   x,
 
)    ImPow(x,y)

◆ STBTT_sqrt

#define STBTT_sqrt (   x)    ImSqrt(x)

◆ STBTT_STATIC

#define STBTT_STATIC

Function Documentation

◆ Decode85()

static void Decode85 ( const unsigned char *  src,
unsigned char *  dst 
)
static
2100{
2101 while (*src)
2102 {
2103 unsigned int tmp = Decode85Byte(src[0]) + 85 * (Decode85Byte(src[1]) + 85 * (Decode85Byte(src[2]) + 85 * (Decode85Byte(src[3]) + 85 * Decode85Byte(src[4]))));
2104 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.
2105 src += 5;
2106 dst += 4;
2107 }
2108}
static unsigned int Decode85Byte(char c)
Definition imgui_draw.cpp:2098

References Decode85Byte().

Referenced by ImFontAtlas::AddFontFromMemoryCompressedBase85TTF().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Decode85Byte()

static unsigned int Decode85Byte ( char  c)
static
2098{ return c >= '\\' ? c-36 : c-35; }

Referenced by Decode85().

+ Here is the caller graph for this function:

◆ FixRectCornerFlags()

static ImDrawFlags FixRectCornerFlags ( ImDrawFlags  flags)
inlinestatic
1308{
1309#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
1310 // Legacy Support for hard coded ~0 (used to be a suggested equivalent to ImDrawCornerFlags_All)
1311 // ~0 --> ImDrawFlags_RoundCornersAll or 0
1312 if (flags == ~0)
1314
1315 // Legacy Support for hard coded 0x01 to 0x0F (matching 15 out of 16 old flags combinations)
1316 // 0x01 --> ImDrawFlags_RoundCornersTopLeft (VALUE 0x01 OVERLAPS ImDrawFlags_Closed but ImDrawFlags_Closed is never valid in this path!)
1317 // 0x02 --> ImDrawFlags_RoundCornersTopRight
1318 // 0x03 --> ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersTopRight
1319 // 0x04 --> ImDrawFlags_RoundCornersBotLeft
1320 // 0x05 --> ImDrawFlags_RoundCornersTopLeft | ImDrawFlags_RoundCornersBotLeft
1321 // ...
1322 // 0x0F --> ImDrawFlags_RoundCornersAll or 0
1323 // (See all values in ImDrawCornerFlags_)
1324 if (flags >= 0x01 && flags <= 0x0F)
1325 return (flags << 4);
1326
1327 // We cannot support hard coded 0x00 with 'float rounding > 0.0f' --> replace with ImDrawFlags_RoundCornersNone or use 'float rounding = 0.0f'
1328#endif
1329
1330 // If this triggers, please update your code replacing hardcoded values with new ImDrawFlags_RoundCorners* values.
1331 // Note that ImDrawFlags_Closed (== 0x01) is an invalid flag for AddRect(), AddRectFilled(), PathRect() etc...
1332 IM_ASSERT((flags & 0x0F) == 0 && "Misuse of legacy hardcoded ImDrawCornerFlags values!");
1333
1334 if ((flags & ImDrawFlags_RoundCornersMask_) == 0)
1336
1337 return flags;
1338}
#define IM_ASSERT(_EXPR)
Definition imgui.h:81
@ ImDrawFlags_RoundCornersMask_
Definition imgui.h:2324
@ ImDrawFlags_RoundCornersAll
Definition imgui.h:2322

References IM_ASSERT, ImDrawFlags_RoundCornersAll, and ImDrawFlags_RoundCornersMask_.

Referenced by ImDrawList::AddImageRounded(), and ImDrawList::PathRect().

+ Here is the caller graph for this function:

◆ GetDefaultCompressedFontDataTTFBase85()

static const char * GetDefaultCompressedFontDataTTFBase85 ( )
static
4169{
4171}
static const char proggy_clean_ttf_compressed_data_base85[11980+1]
Definition imgui_draw.cpp:4080

References proggy_clean_ttf_compressed_data_base85.

Referenced by ImFontAtlas::AddFontDefault().

+ Here is the caller graph for this function:

◆ IM_STATIC_ASSERT()

IM_STATIC_ASSERT ( ImDrawFlags_RoundCornersTopLeft  = =(1<< 4))

◆ ImAcos01()

static float ImAcos01 ( float  x)
inlinestatic
3824{
3825 if (x <= 0.0f) return IM_PI * 0.5f;
3826 if (x >= 1.0f) return 0.0f;
3827 return ImAcos(x);
3828 //return (-0.69813170079773212f * x * x - 0.87266462599716477f) * x + 1.5707963267948966f; // Cheap approximation, may be enough for what we do.
3829}
#define ImAcos(X)
Definition imgui_internal.h:386
#define IM_PI
Definition imgui_internal.h:222

References IM_PI, and ImAcos.

Referenced by ImGui::RenderRectFilledRangeH().

+ Here is the caller graph for this function:

◆ ImBezierCubicCalc()

ImVec2 ImBezierCubicCalc ( const ImVec2 p1,
const ImVec2 p2,
const ImVec2 p3,
const ImVec2 p4,
float  t 
)
1214{
1215 float u = 1.0f - t;
1216 float w1 = u * u * u;
1217 float w2 = 3 * u * u * t;
1218 float w3 = 3 * u * t * t;
1219 float w4 = t * t * t;
1220 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);
1221}
Definition imgui.h:245
float y
Definition imgui.h:246
float x
Definition imgui.h:246

References ImVec2::x, and ImVec2::y.

Referenced by ImBezierCubicClosestPoint(), and ImDrawList::PathBezierCubicCurveTo().

+ Here is the caller graph for this function:

◆ ImBezierQuadraticCalc()

ImVec2 ImBezierQuadraticCalc ( const ImVec2 p1,
const ImVec2 p2,
const ImVec2 p3,
float  t 
)
1224{
1225 float u = 1.0f - t;
1226 float w1 = u * u;
1227 float w2 = 2 * u * t;
1228 float w3 = t * t;
1229 return ImVec2(w1 * p1.x + w2 * p2.x + w3 * p3.x, w1 * p1.y + w2 * p2.y + w3 * p3.y);
1230}

References ImVec2::x, and ImVec2::y.

Referenced by ImDrawList::PathBezierQuadraticCurveTo().

+ Here is the caller graph for this function:

◆ ImFontAtlasBuildFinish()

void ImFontAtlasBuildFinish ( ImFontAtlas atlas)
2766{
2767 // Render into our custom data blocks
2768 IM_ASSERT(atlas->TexPixelsAlpha8 != NULL || atlas->TexPixelsRGBA32 != NULL);
2771
2772 // Register custom rectangle glyphs
2773 for (int i = 0; i < atlas->CustomRects.Size; i++)
2774 {
2775 const ImFontAtlasCustomRect* r = &atlas->CustomRects[i];
2776 if (r->Font == NULL || r->GlyphID == 0)
2777 continue;
2778
2779 // Will ignore ImFontConfig settings: GlyphMinAdvanceX, GlyphMinAdvanceY, GlyphExtraSpacing, PixelSnapH
2780 IM_ASSERT(r->Font->ContainerAtlas == atlas);
2781 ImVec2 uv0, uv1;
2782 atlas->CalcCustomRectUV(r, &uv0, &uv1);
2783 r->Font->AddGlyph(NULL, (ImWchar)r->GlyphID, r->GlyphOffset.x, r->GlyphOffset.y, r->GlyphOffset.x + r->Width, r->GlyphOffset.y + r->Height, uv0.x, uv0.y, uv1.x, uv1.y, r->GlyphAdvanceX);
2784 }
2785
2786 // Build all fonts lookup tables
2787 for (int i = 0; i < atlas->Fonts.Size; i++)
2788 if (atlas->Fonts[i]->DirtyLookupTables)
2789 atlas->Fonts[i]->BuildLookupTable();
2790
2791 // Ellipsis character is required for rendering elided text. We prefer using U+2026 (horizontal ellipsis).
2792 // However some old fonts may contain ellipsis at U+0085. Here we auto-detect most suitable ellipsis character.
2793 // FIXME: Also note that 0x2026 is currently seldom included in our font ranges. Because of this we are more likely to use three individual dots.
2794 for (int i = 0; i < atlas->Fonts.size(); i++)
2795 {
2796 ImFont* font = atlas->Fonts[i];
2797 if (font->EllipsisChar != (ImWchar)-1)
2798 continue;
2799 const ImWchar ellipsis_variants[] = { (ImWchar)0x2026, (ImWchar)0x0085 };
2800 for (int j = 0; j < IM_ARRAYSIZE(ellipsis_variants); j++)
2801 if (font->FindGlyphNoFallback(ellipsis_variants[j]) != NULL) // Verify glyph exists
2802 {
2803 font->EllipsisChar = ellipsis_variants[j];
2804 break;
2805 }
2806 }
2807}
ImWchar16 ImWchar
Definition imgui.h:220
#define IM_ARRAYSIZE(_ARR)
Definition imgui.h:83
static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas *atlas)
Definition imgui_draw.cpp:2652
static void ImFontAtlasBuildRenderLinesTexData(ImFontAtlas *atlas)
Definition imgui_draw.cpp:2692
Definition imgui.h:2551
ImVec2 GlyphOffset
Definition imgui.h:2556
float GlyphAdvanceX
Definition imgui.h:2555
unsigned int GlyphID
Definition imgui.h:2554
unsigned short Height
Definition imgui.h:2552
unsigned short Width
Definition imgui.h:2552
ImFont * Font
Definition imgui.h:2557
ImVector< ImFont * > Fonts
Definition imgui.h:2668
unsigned int * TexPixelsRGBA32
Definition imgui.h:2663
unsigned char * TexPixelsAlpha8
Definition imgui.h:2662
IMGUI_API void CalcCustomRectUV(const ImFontAtlasCustomRect *rect, ImVec2 *out_uv_min, ImVec2 *out_uv_max) const
Definition imgui_draw.cpp:2219
ImVector< ImFontAtlasCustomRect > CustomRects
Definition imgui.h:2669
Definition imgui.h:2690
IMGUI_API void AddGlyph(const ImFontConfig *src_cfg, ImWchar c, float x0, float y0, float x1, float y1, float u0, float v0, float u1, float v1, float advance_x)
Definition imgui_draw.cpp:3224
ImWchar EllipsisChar
Definition imgui.h:2706
ImFontAtlas * ContainerAtlas
Definition imgui.h:2702
IMGUI_API const ImFontGlyph * FindGlyphNoFallback(ImWchar c) const
Definition imgui_draw.cpp:3293
int size() const
Definition imgui.h:1671
int Size
Definition imgui.h:1655

References ImFont::AddGlyph(), ImFontAtlas::CalcCustomRectUV(), ImFont::ContainerAtlas, ImFontAtlas::CustomRects, ImFont::EllipsisChar, ImFont::FindGlyphNoFallback(), ImFontAtlasCustomRect::Font, ImFontAtlas::Fonts, ImFontAtlasCustomRect::GlyphAdvanceX, ImFontAtlasCustomRect::GlyphID, ImFontAtlasCustomRect::GlyphOffset, ImFontAtlasCustomRect::Height, IM_ARRAYSIZE, IM_ASSERT, ImFontAtlasBuildRenderDefaultTexData(), ImFontAtlasBuildRenderLinesTexData(), ImVector< T >::Size, ImVector< T >::size(), ImFontAtlas::TexPixelsAlpha8, ImFontAtlas::TexPixelsRGBA32, ImFontAtlasCustomRect::Width, ImVec2::x, and ImVec2::y.

Referenced by ImFontAtlasBuildWithStbTruetype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ImFontAtlasBuildInit()

void ImFontAtlasBuildInit ( ImFontAtlas atlas)
2745{
2746 // Register texture region for mouse cursors or standard white pixels
2747 if (atlas->PackIdMouseCursors < 0)
2748 {
2749 if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
2751 else
2752 atlas->PackIdMouseCursors = atlas->AddCustomRectRegular(2, 2);
2753 }
2754
2755 // Register texture region for thick lines
2756 // 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
2757 if (atlas->PackIdLines < 0)
2758 {
2759 if (!(atlas->Flags & ImFontAtlasFlags_NoBakedLines))
2761 }
2762}
#define IM_DRAWLIST_TEX_LINES_WIDTH_MAX
Definition imgui.h:2210
@ ImFontAtlasFlags_NoBakedLines
Definition imgui.h:2568
@ ImFontAtlasFlags_NoMouseCursors
Definition imgui.h:2567
const int FONT_ATLAS_DEFAULT_TEX_DATA_H
Definition imgui_draw.cpp:1916
const int FONT_ATLAS_DEFAULT_TEX_DATA_W
Definition imgui_draw.cpp:1915
int PackIdLines
Definition imgui.h:2679
ImFontAtlasFlags Flags
Definition imgui.h:2653
IMGUI_API int AddCustomRectRegular(int width, int height)
Definition imgui_draw.cpp:2189
int PackIdMouseCursors
Definition imgui.h:2678

References ImFontAtlas::AddCustomRectRegular(), ImFontAtlas::Flags, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_W, IM_DRAWLIST_TEX_LINES_WIDTH_MAX, ImFontAtlasFlags_NoBakedLines, ImFontAtlasFlags_NoMouseCursors, ImFontAtlas::PackIdLines, and ImFontAtlas::PackIdMouseCursors.

Referenced by ImFontAtlasBuildWithStbTruetype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ImFontAtlasBuildMultiplyCalcLookupTable()

void ImFontAtlasBuildMultiplyCalcLookupTable ( unsigned char  out_table[256],
float  in_brighten_factor 
)
2274{
2275 for (unsigned int i = 0; i < 256; i++)
2276 {
2277 unsigned int value = (unsigned int)(i * in_brighten_factor);
2278 out_table[i] = value > 255 ? 255 : (value & 0xFF);
2279 }
2280}

Referenced by ImFontAtlasBuildWithStbTruetype().

+ Here is the caller graph for this function:

◆ ImFontAtlasBuildMultiplyRectAlpha8()

void ImFontAtlasBuildMultiplyRectAlpha8 ( const unsigned char  table[256],
unsigned char *  pixels,
int  x,
int  y,
int  w,
int  h,
int  stride 
)
2283{
2284 unsigned char* data = pixels + x + y * stride;
2285 for (int j = h; j > 0; j--, data += stride)
2286 for (int i = 0; i < w; i++)
2287 data[i] = table[data[i]];
2288}
const Scalar & y
Definition MathFunctions.h:552
constexpr auto data(C &c) -> decltype(c.data())
Definition span.hpp:195
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297

Referenced by ImFontAtlasBuildWithStbTruetype().

+ Here is the caller graph for this function:

◆ ImFontAtlasBuildPackCustomRects()

void ImFontAtlasBuildPackCustomRects ( ImFontAtlas atlas,
void stbrp_context_opaque 
)
2606{
2607 stbrp_context* pack_context = (stbrp_context*)stbrp_context_opaque;
2608 IM_ASSERT(pack_context != NULL);
2609
2610 ImVector<ImFontAtlasCustomRect>& user_rects = atlas->CustomRects;
2611 IM_ASSERT(user_rects.Size >= 1); // We expect at least the default custom rects to be registered, else something went wrong.
2612
2613 ImVector<stbrp_rect> pack_rects;
2614 pack_rects.resize(user_rects.Size);
2615 memset(pack_rects.Data, 0, (size_t)pack_rects.size_in_bytes());
2616 for (int i = 0; i < user_rects.Size; i++)
2617 {
2618 pack_rects[i].w = user_rects[i].Width;
2619 pack_rects[i].h = user_rects[i].Height;
2620 }
2621 stbrp_pack_rects(pack_context, &pack_rects[0], pack_rects.Size);
2622 for (int i = 0; i < pack_rects.Size; i++)
2623 if (pack_rects[i].was_packed)
2624 {
2625 user_rects[i].X = pack_rects[i].x;
2626 user_rects[i].Y = pack_rects[i].y;
2627 IM_ASSERT(pack_rects[i].w == user_rects[i].Width && pack_rects[i].h == user_rects[i].Height);
2628 atlas->TexHeight = ImMax(atlas->TexHeight, pack_rects[i].y + pack_rects[i].h);
2629 }
2630}
static T ImMax(T lhs, T rhs)
Definition imgui_internal.h:410
STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects)
Definition imstb_rectpack.h:182
int TexHeight
Definition imgui.h:2665
Definition imgui.h:1654
T * Data
Definition imgui.h:1657
void resize(int new_size)
Definition imgui.h:1690
int size_in_bytes() const
Definition imgui.h:1672

References ImFontAtlas::CustomRects, ImVector< T >::Data, IM_ASSERT, ImMax(), ImVector< T >::resize(), ImVector< T >::Size, ImVector< T >::size_in_bytes(), stbrp_pack_rects(), and ImFontAtlas::TexHeight.

Referenced by ImFontAtlasBuildWithStbTruetype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ImFontAtlasBuildRender32bppRectFromString()

void ImFontAtlasBuildRender32bppRectFromString ( ImFontAtlas atlas,
int  x,
int  y,
int  w,
int  h,
const char *  in_str,
char  in_marker_char,
unsigned int  in_marker_pixel_value 
)
2643{
2644 IM_ASSERT(x >= 0 && x + w <= atlas->TexWidth);
2645 IM_ASSERT(y >= 0 && y + h <= atlas->TexHeight);
2646 unsigned int* out_pixel = atlas->TexPixelsRGBA32 + x + (y * atlas->TexWidth);
2647 for (int off_y = 0; off_y < h; off_y++, out_pixel += atlas->TexWidth, in_str += w)
2648 for (int off_x = 0; off_x < w; off_x++)
2649 out_pixel[off_x] = (in_str[off_x] == in_marker_char) ? in_marker_pixel_value : IM_COL32_BLACK_TRANS;
2650}
#define IM_COL32_BLACK_TRANS
Definition imgui.h:2180
int TexWidth
Definition imgui.h:2664

References IM_ASSERT, IM_COL32_BLACK_TRANS, ImFontAtlas::TexPixelsRGBA32, and ImFontAtlas::TexWidth.

Referenced by ImFontAtlasBuildRenderDefaultTexData().

+ Here is the caller graph for this function:

◆ ImFontAtlasBuildRender8bppRectFromString()

void ImFontAtlasBuildRender8bppRectFromString ( ImFontAtlas atlas,
int  x,
int  y,
int  w,
int  h,
const char *  in_str,
char  in_marker_char,
unsigned char  in_marker_pixel_value 
)
2633{
2634 IM_ASSERT(x >= 0 && x + w <= atlas->TexWidth);
2635 IM_ASSERT(y >= 0 && y + h <= atlas->TexHeight);
2636 unsigned char* out_pixel = atlas->TexPixelsAlpha8 + x + (y * atlas->TexWidth);
2637 for (int off_y = 0; off_y < h; off_y++, out_pixel += atlas->TexWidth, in_str += w)
2638 for (int off_x = 0; off_x < w; off_x++)
2639 out_pixel[off_x] = (in_str[off_x] == in_marker_char) ? in_marker_pixel_value : 0x00;
2640}

References IM_ASSERT, ImFontAtlas::TexPixelsAlpha8, and ImFontAtlas::TexWidth.

Referenced by ImFontAtlasBuildRenderDefaultTexData().

+ Here is the caller graph for this function:

◆ ImFontAtlasBuildRenderDefaultTexData()

static void ImFontAtlasBuildRenderDefaultTexData ( ImFontAtlas atlas)
static
2653{
2655 IM_ASSERT(r->IsPacked());
2656
2657 const int w = atlas->TexWidth;
2658 if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
2659 {
2660 // Render/copy pixels
2662 const int x_for_white = r->X;
2663 const int x_for_black = r->X + FONT_ATLAS_DEFAULT_TEX_DATA_W + 1;
2664 if (atlas->TexPixelsAlpha8 != NULL)
2665 {
2668 }
2669 else
2670 {
2673 }
2674 }
2675 else
2676 {
2677 // Render 4 white pixels
2678 IM_ASSERT(r->Width == 2 && r->Height == 2);
2679 const int offset = (int)r->X + (int)r->Y * w;
2680 if (atlas->TexPixelsAlpha8 != NULL)
2681 {
2682 atlas->TexPixelsAlpha8[offset] = atlas->TexPixelsAlpha8[offset + 1] = atlas->TexPixelsAlpha8[offset + w] = atlas->TexPixelsAlpha8[offset + w + 1] = 0xFF;
2683 }
2684 else
2685 {
2686 atlas->TexPixelsRGBA32[offset] = atlas->TexPixelsRGBA32[offset + 1] = atlas->TexPixelsRGBA32[offset + w] = atlas->TexPixelsRGBA32[offset + w + 1] = IM_COL32_WHITE;
2687 }
2688 }
2689 atlas->TexUvWhitePixel = ImVec2((r->X + 0.5f) * atlas->TexUvScale.x, (r->Y + 0.5f) * atlas->TexUvScale.y);
2690}
#define IM_COL32_WHITE
Definition imgui.h:2178
void ImFontAtlasBuildRender32bppRectFromString(ImFontAtlas *atlas, int x, int y, int w, int h, const char *in_str, char in_marker_char, unsigned int in_marker_pixel_value)
Definition imgui_draw.cpp:2642
static const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W *FONT_ATLAS_DEFAULT_TEX_DATA_H+1]
Definition imgui_draw.cpp:1917
void ImFontAtlasBuildRender8bppRectFromString(ImFontAtlas *atlas, int x, int y, int w, int h, const char *in_str, char in_marker_char, unsigned char in_marker_pixel_value)
Definition imgui_draw.cpp:2632
void offset(Slic3r::ExPolygon &sh, coord_t distance, const PolygonTag &)
Definition geometries.hpp:132
unsigned short X
Definition imgui.h:2553
bool IsPacked() const
Definition imgui.h:2559
unsigned short Y
Definition imgui.h:2553
ImFontAtlasCustomRect * GetCustomRectByIndex(int index)
Definition imgui.h:2643
ImVec2 TexUvScale
Definition imgui.h:2666
ImVec2 TexUvWhitePixel
Definition imgui.h:2667

References ImFontAtlas::Flags, FONT_ATLAS_DEFAULT_TEX_DATA_H, FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS, FONT_ATLAS_DEFAULT_TEX_DATA_W, ImFontAtlas::GetCustomRectByIndex(), ImFontAtlasCustomRect::Height, IM_ASSERT, IM_COL32_WHITE, ImFontAtlasBuildRender32bppRectFromString(), ImFontAtlasBuildRender8bppRectFromString(), ImFontAtlasFlags_NoMouseCursors, ImFontAtlasCustomRect::IsPacked(), ImFontAtlas::PackIdMouseCursors, ImFontAtlas::TexPixelsAlpha8, ImFontAtlas::TexPixelsRGBA32, ImFontAtlas::TexUvScale, ImFontAtlas::TexUvWhitePixel, ImFontAtlas::TexWidth, ImFontAtlasCustomRect::Width, ImVec2::x, ImFontAtlasCustomRect::X, ImVec2::y, and ImFontAtlasCustomRect::Y.

Referenced by ImFontAtlasBuildFinish().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ImFontAtlasBuildRenderLinesTexData()

static void ImFontAtlasBuildRenderLinesTexData ( ImFontAtlas atlas)
static
2693{
2695 return;
2696
2697 // This generates a triangular shape in the texture, with the various line widths stacked on top of each other to allow interpolation between them
2699 IM_ASSERT(r->IsPacked());
2700 for (unsigned int n = 0; n < IM_DRAWLIST_TEX_LINES_WIDTH_MAX + 1; n++) // +1 because of the zero-width row
2701 {
2702 // Each line consists of at least two empty pixels at the ends, with a line of solid pixels in the middle
2703 unsigned int y = n;
2704 unsigned int line_width = n;
2705 unsigned int pad_left = (r->Width - line_width) / 2;
2706 unsigned int pad_right = r->Width - (pad_left + line_width);
2707
2708 // Write each slice
2709 IM_ASSERT(pad_left + line_width + pad_right == r->Width && y < r->Height); // Make sure we're inside the texture bounds before we start writing pixels
2710 if (atlas->TexPixelsAlpha8 != NULL)
2711 {
2712 unsigned char* write_ptr = &atlas->TexPixelsAlpha8[r->X + ((r->Y + y) * atlas->TexWidth)];
2713 for (unsigned int i = 0; i < pad_left; i++)
2714 *(write_ptr + i) = 0x00;
2715
2716 for (unsigned int i = 0; i < line_width; i++)
2717 *(write_ptr + pad_left + i) = 0xFF;
2718
2719 for (unsigned int i = 0; i < pad_right; i++)
2720 *(write_ptr + pad_left + line_width + i) = 0x00;
2721 }
2722 else
2723 {
2724 unsigned int* write_ptr = &atlas->TexPixelsRGBA32[r->X + ((r->Y + y) * atlas->TexWidth)];
2725 for (unsigned int i = 0; i < pad_left; i++)
2726 *(write_ptr + i) = IM_COL32_BLACK_TRANS;
2727
2728 for (unsigned int i = 0; i < line_width; i++)
2729 *(write_ptr + pad_left + i) = IM_COL32_WHITE;
2730
2731 for (unsigned int i = 0; i < pad_right; i++)
2732 *(write_ptr + pad_left + line_width + i) = IM_COL32_BLACK_TRANS;
2733 }
2734
2735 // Calculate UVs for this line
2736 ImVec2 uv0 = ImVec2((float)(r->X + pad_left - 1), (float)(r->Y + y)) * atlas->TexUvScale;
2737 ImVec2 uv1 = ImVec2((float)(r->X + pad_left + line_width + 1), (float)(r->Y + y + 1)) * atlas->TexUvScale;
2738 float half_v = (uv0.y + uv1.y) * 0.5f; // Calculate a constant V in the middle of the row to avoid sampling artifacts
2739 atlas->TexUvLines[n] = ImVec4(uv0.x, half_v, uv1.x, half_v);
2740 }
2741}
ImVec4 TexUvLines[IM_DRAWLIST_TEX_LINES_WIDTH_MAX+1]
Definition imgui.h:2671
Definition imgui.h:258

References ImFontAtlas::Flags, ImFontAtlas::GetCustomRectByIndex(), IM_ASSERT, IM_COL32_BLACK_TRANS, IM_COL32_WHITE, IM_DRAWLIST_TEX_LINES_WIDTH_MAX, ImFontAtlasFlags_NoBakedLines, ImFontAtlasCustomRect::IsPacked(), ImFontAtlas::PackIdLines, ImFontAtlas::TexPixelsAlpha8, ImFontAtlas::TexPixelsRGBA32, ImFontAtlas::TexUvLines, ImFontAtlas::TexUvScale, ImFontAtlas::TexWidth, ImFontAtlasCustomRect::Width, ImVec2::x, ImFontAtlasCustomRect::X, ImVec2::y, and ImFontAtlasCustomRect::Y.

Referenced by ImFontAtlasBuildFinish().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ImFontAtlasBuildSetupFont()

void ImFontAtlasBuildSetupFont ( ImFontAtlas atlas,
ImFont font,
ImFontConfig font_config,
float  ascent,
float  descent 
)
2591{
2592 if (!font_config->MergeMode)
2593 {
2594 font->ClearOutputData();
2595 font->FontSize = font_config->SizePixels;
2596 font->ConfigData = font_config;
2597 font->ConfigDataCount = 0;
2598 font->ContainerAtlas = atlas;
2599 font->Ascent = ascent;
2600 font->Descent = descent;
2601 }
2602 font->ConfigDataCount++;
2603}
float SizePixels
Definition imgui.h:2500
bool MergeMode
Definition imgui.h:2509
float FontSize
Definition imgui.h:2694
short ConfigDataCount
Definition imgui.h:2704
float Ascent
Definition imgui.h:2709
float Descent
Definition imgui.h:2709
IMGUI_API void ClearOutputData()
Definition imgui_draw.cpp:3123
const ImFontConfig * ConfigData
Definition imgui.h:2703

References ImFont::Ascent, ImFont::ClearOutputData(), ImFont::ConfigData, ImFont::ConfigDataCount, ImFont::ContainerAtlas, ImFont::Descent, ImFont::FontSize, ImFontConfig::MergeMode, and ImFontConfig::SizePixels.

Referenced by ImFontAtlasBuildWithStbTruetype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ImFontAtlasBuildWithStbTruetype()

static bool ImFontAtlasBuildWithStbTruetype ( ImFontAtlas atlas)
static
2329{
2330 IM_ASSERT(atlas->ConfigData.Size > 0);
2331
2332 ImFontAtlasBuildInit(atlas);
2333
2334 // Clear atlas
2335 atlas->TexID = (ImTextureID)NULL;
2336 atlas->TexWidth = atlas->TexHeight = 0;
2337 atlas->TexUvScale = ImVec2(0.0f, 0.0f);
2338 atlas->TexUvWhitePixel = ImVec2(0.0f, 0.0f);
2339 atlas->ClearTexData();
2340
2341 // Temporary storage for building
2342 ImVector<ImFontBuildSrcData> src_tmp_array;
2343 ImVector<ImFontBuildDstData> dst_tmp_array;
2344 src_tmp_array.resize(atlas->ConfigData.Size);
2345 dst_tmp_array.resize(atlas->Fonts.Size);
2346 memset(src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes());
2347 memset(dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes());
2348
2349 // 1. Initialize font loading structure, check font data validity
2350 for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++)
2351 {
2352 ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
2353 ImFontConfig& cfg = atlas->ConfigData[src_i];
2354 IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == atlas));
2355
2356 // Find index from cfg.DstFont (we allow the user to set cfg.DstFont. Also it makes casual debugging nicer than when storing indices)
2357 src_tmp.DstIndex = -1;
2358 for (int output_i = 0; output_i < atlas->Fonts.Size && src_tmp.DstIndex == -1; output_i++)
2359 if (cfg.DstFont == atlas->Fonts[output_i])
2360 src_tmp.DstIndex = output_i;
2361 if (src_tmp.DstIndex == -1)
2362 {
2363 IM_ASSERT(src_tmp.DstIndex != -1); // cfg.DstFont not pointing within atlas->Fonts[] array?
2364 return false;
2365 }
2366 // Initialize helper structure for font loading and verify that the TTF/OTF data is correct
2367 const int font_offset = stbtt_GetFontOffsetForIndex((unsigned char*)cfg.FontData, cfg.FontNo);
2368 IM_ASSERT(font_offset >= 0 && "FontData is incorrect, or FontNo cannot be found.");
2369 if (!stbtt_InitFont(&src_tmp.FontInfo, (unsigned char*)cfg.FontData, font_offset))
2370 return false;
2371
2372 // Measure highest codepoints
2373 ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex];
2374 src_tmp.SrcRanges = cfg.GlyphRanges ? cfg.GlyphRanges : atlas->GetGlyphRangesDefault();
2375 for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
2376 src_tmp.GlyphsHighest = ImMax(src_tmp.GlyphsHighest, (int)src_range[1]);
2377 dst_tmp.SrcCount++;
2378 dst_tmp.GlyphsHighest = ImMax(dst_tmp.GlyphsHighest, src_tmp.GlyphsHighest);
2379 }
2380
2381 // 2. For every requested codepoint, check for their presence in the font data, and handle redundancy or overlaps between source fonts to avoid unused glyphs.
2382 int total_glyphs_count = 0;
2383 for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
2384 {
2385 ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
2386 ImFontBuildDstData& dst_tmp = dst_tmp_array[src_tmp.DstIndex];
2387 src_tmp.GlyphsSet.Create(src_tmp.GlyphsHighest + 1);
2388 if (dst_tmp.GlyphsSet.Storage.empty())
2389 dst_tmp.GlyphsSet.Create(dst_tmp.GlyphsHighest + 1);
2390
2391 for (const ImWchar* src_range = src_tmp.SrcRanges; src_range[0] && src_range[1]; src_range += 2)
2392 for (unsigned int codepoint = src_range[0]; codepoint <= src_range[1]; codepoint++)
2393 {
2394 if (dst_tmp.GlyphsSet.TestBit(codepoint)) // Don't overwrite existing glyphs. We could make this an option for MergeMode (e.g. MergeOverwrite==true)
2395 continue;
2396 if (!stbtt_FindGlyphIndex(&src_tmp.FontInfo, codepoint)) // It is actually in the font?
2397 continue;
2398
2399 // Add to avail set/counters
2400 src_tmp.GlyphsCount++;
2401 dst_tmp.GlyphsCount++;
2402 src_tmp.GlyphsSet.SetBit(codepoint);
2403 dst_tmp.GlyphsSet.SetBit(codepoint);
2404 total_glyphs_count++;
2405 }
2406 }
2407
2408 // 3. Unpack our bit map into a flat list (we now have all the Unicode points that we know are requested _and_ available _and_ not overlapping another)
2409 for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
2410 {
2411 ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
2412 src_tmp.GlyphsList.reserve(src_tmp.GlyphsCount);
2414 src_tmp.GlyphsSet.Clear();
2415 IM_ASSERT(src_tmp.GlyphsList.Size == src_tmp.GlyphsCount);
2416 }
2417 for (int dst_i = 0; dst_i < dst_tmp_array.Size; dst_i++)
2418 dst_tmp_array[dst_i].GlyphsSet.Clear();
2419 dst_tmp_array.clear();
2420
2421 // Allocate packing character data and flag packed characters buffer as non-packed (x0=y0=x1=y1=0)
2422 // (We technically don't need to zero-clear buf_rects, but let's do it for the sake of sanity)
2423 ImVector<stbrp_rect> buf_rects;
2424 ImVector<stbtt_packedchar> buf_packedchars;
2425 buf_rects.resize(total_glyphs_count);
2426 buf_packedchars.resize(total_glyphs_count);
2427 memset(buf_rects.Data, 0, (size_t)buf_rects.size_in_bytes());
2428 memset(buf_packedchars.Data, 0, (size_t)buf_packedchars.size_in_bytes());
2429
2430 // 4. Gather glyphs sizes so we can pack them in our virtual canvas.
2431 int total_surface = 0;
2432 int buf_rects_out_n = 0;
2433 int buf_packedchars_out_n = 0;
2434 for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
2435 {
2436 ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
2437 if (src_tmp.GlyphsCount == 0)
2438 continue;
2439
2440 src_tmp.Rects = &buf_rects[buf_rects_out_n];
2441 src_tmp.PackedChars = &buf_packedchars[buf_packedchars_out_n];
2442 buf_rects_out_n += src_tmp.GlyphsCount;
2443 buf_packedchars_out_n += src_tmp.GlyphsCount;
2444
2445 // Convert our ranges in the format stb_truetype wants
2446 ImFontConfig& cfg = atlas->ConfigData[src_i];
2447 src_tmp.PackRange.font_size = cfg.SizePixels;
2450 src_tmp.PackRange.num_chars = src_tmp.GlyphsList.Size;
2451 src_tmp.PackRange.chardata_for_range = src_tmp.PackedChars;
2452 src_tmp.PackRange.h_oversample = (unsigned char)cfg.OversampleH;
2453 src_tmp.PackRange.v_oversample = (unsigned char)cfg.OversampleV;
2454
2455 // Gather the sizes of all rectangles we will need to pack (this loop is based on stbtt_PackFontRangesGatherRects)
2456 const float scale = (cfg.SizePixels > 0) ? stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels) : stbtt_ScaleForMappingEmToPixels(&src_tmp.FontInfo, -cfg.SizePixels);
2457 const int padding = atlas->TexGlyphPadding;
2458 for (int glyph_i = 0; glyph_i < src_tmp.GlyphsList.Size; glyph_i++)
2459 {
2460 int x0, y0, x1, y1;
2461 const int glyph_index_in_font = stbtt_FindGlyphIndex(&src_tmp.FontInfo, src_tmp.GlyphsList[glyph_i]);
2462 IM_ASSERT(glyph_index_in_font != 0);
2463 stbtt_GetGlyphBitmapBoxSubpixel(&src_tmp.FontInfo, glyph_index_in_font, scale * cfg.OversampleH, scale * cfg.OversampleV, 0, 0, &x0, &y0, &x1, &y1);
2464 src_tmp.Rects[glyph_i].w = (stbrp_coord)(x1 - x0 + padding + cfg.OversampleH - 1);
2465 src_tmp.Rects[glyph_i].h = (stbrp_coord)(y1 - y0 + padding + cfg.OversampleV - 1);
2466 total_surface += src_tmp.Rects[glyph_i].w * src_tmp.Rects[glyph_i].h;
2467 }
2468 }
2469
2470 // We need a width for the skyline algorithm, any width!
2471 // The exact width doesn't really matter much, but some API/GPU have texture size limitations and increasing width can decrease height.
2472 // User can override TexDesiredWidth and TexGlyphPadding if they wish, otherwise we use a simple heuristic to select the width based on expected surface.
2473 const int surface_sqrt = (int)ImSqrt((float)total_surface) + 1;
2474 atlas->TexHeight = 0;
2475 if (atlas->TexDesiredWidth > 0)
2476 atlas->TexWidth = atlas->TexDesiredWidth;
2477 else
2478 atlas->TexWidth = (surface_sqrt >= 4096 * 0.7f) ? 4096 : (surface_sqrt >= 2048 * 0.7f) ? 2048 : (surface_sqrt >= 1024 * 0.7f) ? 1024 : 512;
2479
2480 // 5. Start packing
2481 // Pack our extra data rectangles first, so it will be on the upper-left corner of our texture (UV will have small values).
2482 const int TEX_HEIGHT_MAX = 1024 * 32;
2483 stbtt_pack_context spc = {};
2484 stbtt_PackBegin(&spc, NULL, atlas->TexWidth, TEX_HEIGHT_MAX, 0, atlas->TexGlyphPadding, NULL);
2486
2487 // 6. Pack each source font. No rendering yet, we are working with rectangles in an infinitely tall texture at this point.
2488 for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
2489 {
2490 ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
2491 if (src_tmp.GlyphsCount == 0)
2492 continue;
2493
2494 stbrp_pack_rects((stbrp_context*)spc.pack_info, src_tmp.Rects, src_tmp.GlyphsCount);
2495
2496 // Extend texture height and mark missing glyphs as non-packed so we won't render them.
2497 // FIXME: We are not handling packing failure here (would happen if we got off TEX_HEIGHT_MAX or if a single if larger than TexWidth?)
2498 for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++)
2499 if (src_tmp.Rects[glyph_i].was_packed)
2500 atlas->TexHeight = ImMax(atlas->TexHeight, src_tmp.Rects[glyph_i].y + src_tmp.Rects[glyph_i].h);
2501 }
2502
2503 // 7. Allocate texture
2504 atlas->TexHeight = (atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) ? (atlas->TexHeight + 1) : ImUpperPowerOfTwo(atlas->TexHeight);
2505 atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight);
2506 atlas->TexPixelsAlpha8 = (unsigned char*)IM_ALLOC(atlas->TexWidth * atlas->TexHeight);
2507 memset(atlas->TexPixelsAlpha8, 0, atlas->TexWidth * atlas->TexHeight);
2508 spc.pixels = atlas->TexPixelsAlpha8;
2509 spc.height = atlas->TexHeight;
2510
2511 // 8. Render/rasterize font characters into the texture
2512 for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
2513 {
2514 ImFontConfig& cfg = atlas->ConfigData[src_i];
2515 ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
2516 if (src_tmp.GlyphsCount == 0)
2517 continue;
2518
2519 stbtt_PackFontRangesRenderIntoRects(&spc, &src_tmp.FontInfo, &src_tmp.PackRange, 1, src_tmp.Rects);
2520
2521 // Apply multiply operator
2522 if (cfg.RasterizerMultiply != 1.0f)
2523 {
2524 unsigned char multiply_table[256];
2526 stbrp_rect* r = &src_tmp.Rects[0];
2527 for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++, r++)
2528 if (r->was_packed)
2529 ImFontAtlasBuildMultiplyRectAlpha8(multiply_table, atlas->TexPixelsAlpha8, r->x, r->y, r->w, r->h, atlas->TexWidth * 1);
2530 }
2531 src_tmp.Rects = NULL;
2532 }
2533
2534 // End packing
2535 stbtt_PackEnd(&spc);
2536 buf_rects.clear();
2537
2538 // 9. Setup ImFont and glyphs for runtime
2539 for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
2540 {
2541 ImFontBuildSrcData& src_tmp = src_tmp_array[src_i];
2542 if (src_tmp.GlyphsCount == 0)
2543 continue;
2544
2545 // When merging fonts with MergeMode=true:
2546 // - We can have multiple input fonts writing into a same destination font.
2547 // - dst_font->ConfigData is != from cfg which is our source configuration.
2548 ImFontConfig& cfg = atlas->ConfigData[src_i];
2549 ImFont* dst_font = cfg.DstFont;
2550
2551 const float font_scale = stbtt_ScaleForPixelHeight(&src_tmp.FontInfo, cfg.SizePixels);
2552 int unscaled_ascent, unscaled_descent, unscaled_line_gap;
2553 stbtt_GetFontVMetrics(&src_tmp.FontInfo, &unscaled_ascent, &unscaled_descent, &unscaled_line_gap);
2554
2555 const float ascent = ImFloor(unscaled_ascent * font_scale + ((unscaled_ascent > 0.0f) ? +1 : -1));
2556 const float descent = ImFloor(unscaled_descent * font_scale + ((unscaled_descent > 0.0f) ? +1 : -1));
2557 ImFontAtlasBuildSetupFont(atlas, dst_font, &cfg, ascent, descent);
2558 const float font_off_x = cfg.GlyphOffset.x;
2559 const float font_off_y = cfg.GlyphOffset.y + IM_ROUND(dst_font->Ascent);
2560
2561 for (int glyph_i = 0; glyph_i < src_tmp.GlyphsCount; glyph_i++)
2562 {
2563 // Register glyph
2564 const int codepoint = src_tmp.GlyphsList[glyph_i];
2565 const stbtt_packedchar& pc = src_tmp.PackedChars[glyph_i];
2567 float unused_x = 0.0f, unused_y = 0.0f;
2568 stbtt_GetPackedQuad(src_tmp.PackedChars, atlas->TexWidth, atlas->TexHeight, glyph_i, &unused_x, &unused_y, &q, 0);
2569 dst_font->AddGlyph(&cfg, (ImWchar)codepoint, q.x0 + font_off_x, q.y0 + font_off_y, q.x1 + font_off_x, q.y1 + font_off_y, q.s0, q.t0, q.s1, q.t1, pc.xadvance);
2570 }
2571 }
2572
2573 // Cleanup temporary (ImVector doesn't honor destructor)
2574 for (int src_i = 0; src_i < src_tmp_array.Size; src_i++)
2575 src_tmp_array[src_i].~ImFontBuildSrcData();
2576
2578 return true;
2579}
int scale(const int val)
Definition WipeTowerDialog.cpp:14
void * ImTextureID
Definition imgui.h:205
#define IM_ALLOC(_SIZE)
Definition imgui.h:1634
@ ImFontAtlasFlags_NoPowerOfTwoHeight
Definition imgui.h:2566
int DstIndex
Definition imgui_draw.cpp:2300
int GlyphsHighest
Definition imgui_draw.cpp:2311
const ImWchar * SrcRanges
Definition imgui_draw.cpp:2299
int GlyphsHighest
Definition imgui_draw.cpp:2301
void ImFontAtlasBuildSetupFont(ImFontAtlas *atlas, ImFont *font, ImFontConfig *font_config, float ascent, float descent)
Definition imgui_draw.cpp:2590
static void UnpackBitVectorToFlatIndexList(const ImBitVector *in, ImVector< int > *out)
Definition imgui_draw.cpp:2316
int GlyphsCount
Definition imgui_draw.cpp:2302
stbtt_packedchar * PackedChars
Definition imgui_draw.cpp:2298
void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_brighten_factor)
Definition imgui_draw.cpp:2273
void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char *pixels, int x, int y, int w, int h, int stride)
Definition imgui_draw.cpp:2282
stbrp_rect * Rects
Definition imgui_draw.cpp:2297
stbtt_pack_range PackRange
Definition imgui_draw.cpp:2296
stbtt_fontinfo FontInfo
Definition imgui_draw.cpp:2295
int SrcCount
Definition imgui_draw.cpp:2310
void ImFontAtlasBuildInit(ImFontAtlas *atlas)
Definition imgui_draw.cpp:2744
ImBitVector GlyphsSet
Definition imgui_draw.cpp:2313
ImBitVector GlyphsSet
Definition imgui_draw.cpp:2303
void ImFontAtlasBuildFinish(ImFontAtlas *atlas)
Definition imgui_draw.cpp:2765
void ImFontAtlasBuildPackCustomRects(ImFontAtlas *atlas, void *stbrp_context_opaque)
Definition imgui_draw.cpp:2605
ImVector< int > GlyphsList
Definition imgui_draw.cpp:2304
int GlyphsCount
Definition imgui_draw.cpp:2312
Definition imgui_draw.cpp:2294
Definition imgui_draw.cpp:2309
static float ImFloor(float f)
Definition imgui_internal.h:427
#define IM_ROUND(_VAL)
Definition imgui_internal.h:233
static int ImUpperPowerOfTwo(int v)
Definition imgui_internal.h:300
#define ImSqrt(X)
Definition imgui_internal.h:382
stbrp_coord w
Definition imstb_rectpack.h:121
stbrp_coord x
Definition imstb_rectpack.h:124
int was_packed
Definition imstb_rectpack.h:125
unsigned short stbrp_coord
Definition imstb_rectpack.h:87
stbrp_coord y
Definition imstb_rectpack.h:124
stbrp_coord h
Definition imstb_rectpack.h:121
Definition imstb_rectpack.h:116
int num_chars
Definition imstb_truetype.h:625
int * array_of_unicode_codepoints
Definition imstb_truetype.h:624
STBTT_DEF int stbtt_FindGlyphIndex(const stbtt_fontinfo *info, int unicode_codepoint)
float s1
Definition imstb_truetype.h:547
STBTT_DEF void stbtt_GetFontVMetrics(const stbtt_fontinfo *info, int *ascent, int *descent, int *lineGap)
float xadvance
Definition imstb_truetype.h:579
float font_size
Definition imstb_truetype.h:622
void * pack_info
Definition imstb_truetype.h:681
int first_unicode_codepoint_in_range
Definition imstb_truetype.h:623
float x1
Definition imstb_truetype.h:547
STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, int glyph, float scale_x, float scale_y, float shift_x, float shift_y, int *ix0, int *iy0, int *ix1, int *iy1)
STBTT_DEF int stbtt_GetFontOffsetForIndex(const unsigned char *data, int index)
float y0
Definition imstb_truetype.h:546
unsigned char v_oversample
Definition imstb_truetype.h:627
unsigned char * pixels
Definition imstb_truetype.h:688
float y1
Definition imstb_truetype.h:547
STBTT_DEF float stbtt_ScaleForMappingEmToPixels(const stbtt_fontinfo *info, float pixels)
unsigned char h_oversample
Definition imstb_truetype.h:627
int height
Definition imstb_truetype.h:683
float t0
Definition imstb_truetype.h:546
stbtt_packedchar * chardata_for_range
Definition imstb_truetype.h:626
STBTT_DEF float stbtt_ScaleForPixelHeight(const stbtt_fontinfo *info, float pixels)
STBTT_DEF void stbtt_PackEnd(stbtt_pack_context *spc)
STBTT_DEF int stbtt_PackFontRangesRenderIntoRects(stbtt_pack_context *spc, const stbtt_fontinfo *info, stbtt_pack_range *ranges, int num_ranges, stbrp_rect *rects)
STBTT_DEF void stbtt_GetPackedQuad(const stbtt_packedchar *chardata, int pw, int ph, int char_index, float *xpos, float *ypos, stbtt_aligned_quad *q, int align_to_integer)
float s0
Definition imstb_truetype.h:546
STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data, int offset)
float x0
Definition imstb_truetype.h:546
STBTT_DEF int stbtt_PackBegin(stbtt_pack_context *spc, unsigned char *pixels, int width, int height, int stride_in_bytes, int padding, void *alloc_context)
float t1
Definition imstb_truetype.h:547
Definition imstb_truetype.h:577
Definition imstb_truetype.h:679
Definition imstb_truetype.h:545
void Create(int sz)
Definition imgui_internal.h:544
ImVector< ImU32 > Storage
Definition imgui_internal.h:543
void Clear()
Definition imgui_internal.h:545
bool TestBit(int n) const
Definition imgui_internal.h:546
void SetBit(int n)
Definition imgui_internal.h:547
ImTextureID TexID
Definition imgui.h:2654
int TexGlyphPadding
Definition imgui.h:2656
IMGUI_API void ClearTexData()
Definition imgui_draw.cpp:1996
int TexDesiredWidth
Definition imgui.h:2655
IMGUI_API const ImWchar * GetGlyphRangesDefault()
Definition imgui_draw.cpp:2810
ImVector< ImFontConfig > ConfigData
Definition imgui.h:2670
Definition imgui.h:2495
void * FontData
Definition imgui.h:2496
ImVec2 GlyphOffset
Definition imgui.h:2505
ImFont * DstFont
Definition imgui.h:2516
int OversampleV
Definition imgui.h:2502
float RasterizerMultiply
Definition imgui.h:2511
const ImWchar * GlyphRanges
Definition imgui.h:2506
int FontNo
Definition imgui.h:2499
int OversampleH
Definition imgui.h:2501
bool IsLoaded() const
Definition imgui.h:2719
void reserve(int new_capacity)
Definition imgui.h:1693
bool empty() const
Definition imgui.h:1670
void clear()
Definition imgui.h:1678

References ImFont::AddGlyph(), stbtt_pack_range::array_of_unicode_codepoints, ImFont::Ascent, stbtt_pack_range::chardata_for_range, ImVector< T >::clear(), ImBitVector::Clear(), ImFontAtlas::ClearTexData(), ImFontAtlas::ConfigData, ImFont::ContainerAtlas, ImBitVector::Create(), ImVector< T >::Data, ImFontConfig::DstFont, ImFontBuildSrcData::DstIndex, ImVector< T >::empty(), stbtt_pack_range::first_unicode_codepoint_in_range, ImFontAtlas::Flags, stbtt_pack_range::font_size, ImFontConfig::FontData, ImFontBuildSrcData::FontInfo, ImFontConfig::FontNo, ImFontAtlas::Fonts, ImFontAtlas::GetGlyphRangesDefault(), ImFontConfig::GlyphOffset, ImFontConfig::GlyphRanges, ImFontBuildSrcData::GlyphsCount, ImFontBuildDstData::GlyphsCount, ImFontBuildSrcData::GlyphsHighest, ImFontBuildDstData::GlyphsHighest, ImFontBuildSrcData::GlyphsList, ImFontBuildSrcData::GlyphsSet, ImFontBuildDstData::GlyphsSet, stbrp_rect::h, stbtt_pack_range::h_oversample, stbtt_pack_context::height, IM_ALLOC, IM_ASSERT, IM_ROUND, ImFloor(), ImFontAtlasBuildFinish(), ImFontAtlasBuildInit(), ImFontAtlasBuildMultiplyCalcLookupTable(), ImFontAtlasBuildMultiplyRectAlpha8(), ImFontAtlasBuildPackCustomRects(), ImFontAtlasBuildSetupFont(), ImFontAtlasFlags_NoPowerOfTwoHeight, ImMax(), ImSqrt, ImUpperPowerOfTwo(), ImFont::IsLoaded(), stbtt_pack_range::num_chars, ImFontConfig::OversampleH, ImFontConfig::OversampleV, stbtt_pack_context::pack_info, ImFontBuildSrcData::PackedChars, ImFontBuildSrcData::PackRange, stbtt_pack_context::pixels, ImFontConfig::RasterizerMultiply, ImFontBuildSrcData::Rects, ImVector< T >::reserve(), ImVector< T >::resize(), stbtt_aligned_quad::s0, stbtt_aligned_quad::s1, scale(), ImBitVector::SetBit(), ImVector< T >::Size, ImVector< T >::size_in_bytes(), ImFontConfig::SizePixels, ImFontBuildDstData::SrcCount, ImFontBuildSrcData::SrcRanges, stbrp_pack_rects(), stbtt_FindGlyphIndex(), stbtt_GetFontOffsetForIndex(), stbtt_GetFontVMetrics(), stbtt_GetGlyphBitmapBoxSubpixel(), stbtt_GetPackedQuad(), stbtt_InitFont(), stbtt_PackBegin(), stbtt_PackEnd(), stbtt_PackFontRangesRenderIntoRects(), stbtt_ScaleForMappingEmToPixels(), stbtt_ScaleForPixelHeight(), ImBitVector::Storage, stbtt_aligned_quad::t0, stbtt_aligned_quad::t1, ImBitVector::TestBit(), ImFontAtlas::TexDesiredWidth, ImFontAtlas::TexGlyphPadding, ImFontAtlas::TexHeight, ImFontAtlas::TexID, ImFontAtlas::TexPixelsAlpha8, ImFontAtlas::TexUvScale, ImFontAtlas::TexUvWhitePixel, ImFontAtlas::TexWidth, UnpackBitVectorToFlatIndexList(), stbtt_pack_range::v_oversample, stbrp_rect::w, stbrp_rect::was_packed, ImVec2::x, stbrp_rect::x, stbtt_aligned_quad::x0, stbtt_aligned_quad::x1, stbtt_packedchar::xadvance, ImVec2::y, stbrp_rect::y, stbtt_aligned_quad::y0, and stbtt_aligned_quad::y1.

Referenced by ImFontAtlasGetBuilderForStbTruetype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ImFontAtlasGetBuilderForStbTruetype()

const ImFontBuilderIO * ImFontAtlasGetBuilderForStbTruetype ( )
2582{
2583 static ImFontBuilderIO io;
2585 return &io;
2586}
static bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas *atlas)
Definition imgui_draw.cpp:2328
Definition imgui_internal.h:2638
bool(* FontBuilder_Build)(ImFontAtlas *atlas)
Definition imgui_internal.h:2639

References ImFontBuilderIO::FontBuilder_Build, and ImFontAtlasBuildWithStbTruetype().

Referenced by ImFontAtlas::Build().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PathBezierCubicCurveToCasteljau()

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 
)
static
1234{
1235 float dx = x4 - x1;
1236 float dy = y4 - y1;
1237 float d2 = (x2 - x4) * dy - (y2 - y4) * dx;
1238 float d3 = (x3 - x4) * dy - (y3 - y4) * dx;
1239 d2 = (d2 >= 0) ? d2 : -d2;
1240 d3 = (d3 >= 0) ? d3 : -d3;
1241 if ((d2 + d3) * (d2 + d3) < tess_tol * (dx * dx + dy * dy))
1242 {
1243 path->push_back(ImVec2(x4, y4));
1244 }
1245 else if (level < 10)
1246 {
1247 float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f;
1248 float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f;
1249 float x34 = (x3 + x4) * 0.5f, y34 = (y3 + y4) * 0.5f;
1250 float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f;
1251 float x234 = (x23 + x34) * 0.5f, y234 = (y23 + y34) * 0.5f;
1252 float x1234 = (x123 + x234) * 0.5f, y1234 = (y123 + y234) * 0.5f;
1253 PathBezierCubicCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, x1234, y1234, tess_tol, level + 1);
1254 PathBezierCubicCurveToCasteljau(path, x1234, y1234, x234, y234, x34, y34, x4, y4, tess_tol, level + 1);
1255 }
1256}
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)
Definition imgui_draw.cpp:1233
void push_back(const T &v)
Definition imgui.h:1696

References PathBezierCubicCurveToCasteljau(), and ImVector< T >::push_back().

Referenced by ImDrawList::PathBezierCubicCurveTo(), and PathBezierCubicCurveToCasteljau().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ PathBezierQuadraticCurveToCasteljau()

static void PathBezierQuadraticCurveToCasteljau ( ImVector< ImVec2 > *  path,
float  x1,
float  y1,
float  x2,
float  y2,
float  x3,
float  y3,
float  tess_tol,
int  level 
)
static
1259{
1260 float dx = x3 - x1, dy = y3 - y1;
1261 float det = (x2 - x3) * dy - (y2 - y3) * dx;
1262 if (det * det * 4.0f < tess_tol * (dx * dx + dy * dy))
1263 {
1264 path->push_back(ImVec2(x3, y3));
1265 }
1266 else if (level < 10)
1267 {
1268 float x12 = (x1 + x2) * 0.5f, y12 = (y1 + y2) * 0.5f;
1269 float x23 = (x2 + x3) * 0.5f, y23 = (y2 + y3) * 0.5f;
1270 float x123 = (x12 + x23) * 0.5f, y123 = (y12 + y23) * 0.5f;
1271 PathBezierQuadraticCurveToCasteljau(path, x1, y1, x12, y12, x123, y123, tess_tol, level + 1);
1272 PathBezierQuadraticCurveToCasteljau(path, x123, y123, x23, y23, x3, y3, tess_tol, level + 1);
1273 }
1274}
static void PathBezierQuadraticCurveToCasteljau(ImVector< ImVec2 > *path, float x1, float y1, float x2, float y2, float x3, float y3, float tess_tol, int level)
Definition imgui_draw.cpp:1258

References PathBezierQuadraticCurveToCasteljau(), and ImVector< T >::push_back().

Referenced by ImDrawList::PathBezierQuadraticCurveTo(), and PathBezierQuadraticCurveToCasteljau().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stb__lit()

static void stb__lit ( const unsigned char *  data,
unsigned int  length 
)
static
3976{
3978 if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; }
3979 if (data < stb__barrier_in_b) { stb__dout = stb__barrier_out_e+1; return; }
3980 memcpy(stb__dout, data, length);
3981 stb__dout += length;
3982}
static unsigned char * stb__dout
Definition imgui_draw.cpp:3965
static unsigned char * stb__barrier_out_e
Definition imgui_draw.cpp:3963
static const unsigned char * stb__barrier_in_b
Definition imgui_draw.cpp:3964
double length(std::vector< SurfacePoint > &path)
Definition exact_geodesic.cpp:1682

References IM_ASSERT, stb__barrier_in_b, stb__barrier_out_e, and stb__dout.

Referenced by stb_decompress_token().

+ Here is the caller graph for this function:

◆ stb__match()

static void stb__match ( const unsigned char *  data,
unsigned int  length 
)
static
3967{
3968 // INVERSE of memmove... write each byte before copying the next...
3970 if (stb__dout + length > stb__barrier_out_e) { stb__dout += length; return; }
3971 if (data < stb__barrier_out_b) { stb__dout = stb__barrier_out_e+1; return; }
3972 while (length--) *stb__dout++ = *data++;
3973}
static unsigned char * stb__barrier_out_b
Definition imgui_draw.cpp:3963

References IM_ASSERT, stb__barrier_out_b, stb__barrier_out_e, and stb__dout.

Referenced by stb_decompress_token().

+ Here is the caller graph for this function:

◆ stb_adler32()

static unsigned int stb_adler32 ( unsigned int  adler32,
unsigned char *  buffer,
unsigned int  buflen 
)
static
4006{
4007 const unsigned long ADLER_MOD = 65521;
4008 unsigned long s1 = adler32 & 0xffff, s2 = adler32 >> 16;
4009 unsigned long blocklen = buflen % 5552;
4010
4011 unsigned long i;
4012 while (buflen) {
4013 for (i=0; i + 7 < blocklen; i += 8) {
4014 s1 += buffer[0], s2 += s1;
4015 s1 += buffer[1], s2 += s1;
4016 s1 += buffer[2], s2 += s1;
4017 s1 += buffer[3], s2 += s1;
4018 s1 += buffer[4], s2 += s1;
4019 s1 += buffer[5], s2 += s1;
4020 s1 += buffer[6], s2 += s1;
4021 s1 += buffer[7], s2 += s1;
4022
4023 buffer += 8;
4024 }
4025
4026 for (; i < blocklen; ++i)
4027 s1 += *buffer++, s2 += s1;
4028
4029 s1 %= ADLER_MOD, s2 %= ADLER_MOD;
4030 buflen -= blocklen;
4031 blocklen = 5552;
4032 }
4033 return (unsigned int)(s2 << 16) + (unsigned int)s1;
4034}
#define adler32
Definition miniz.h:459

References adler32.

Referenced by stb_decompress().

+ Here is the caller graph for this function:

◆ stb_decompress()

static unsigned int stb_decompress ( unsigned char *  output,
const unsigned char *  input,
unsigned int  length 
)
static
4037{
4038 if (stb__in4(0) != 0x57bC0000) return 0;
4039 if (stb__in4(4) != 0) return 0; // error! stream is > 4GB
4040 const unsigned int olen = stb_decompress_length(i);
4042 stb__barrier_out_e = output + olen;
4043 stb__barrier_out_b = output;
4044 i += 16;
4045
4046 stb__dout = output;
4047 for (;;) {
4048 const unsigned char *old_i = i;
4049 i = stb_decompress_token(i);
4050 if (i == old_i) {
4051 if (*i == 0x05 && i[1] == 0xfa) {
4052 IM_ASSERT(stb__dout == output + olen);
4053 if (stb__dout != output + olen) return 0;
4054 if (stb_adler32(1, output, olen) != (unsigned int) stb__in4(2))
4055 return 0;
4056 return olen;
4057 } else {
4058 IM_ASSERT(0); /* NOTREACHED */
4059 return 0;
4060 }
4061 }
4062 IM_ASSERT(stb__dout <= output + olen);
4063 if (stb__dout > output + olen)
4064 return 0;
4065 }
4066}
static unsigned int stb_adler32(unsigned int adler32, unsigned char *buffer, unsigned int buflen)
Definition imgui_draw.cpp:4005
#define stb__in4(x)
Definition imgui_draw.cpp:3986
static unsigned int stb_decompress_length(const unsigned char *input)
Definition imgui_draw.cpp:3958
static const unsigned char * stb_decompress_token(const unsigned char *i)
Definition imgui_draw.cpp:3988

References IM_ASSERT, stb__barrier_in_b, stb__barrier_out_b, stb__barrier_out_e, stb__dout, stb__in4, stb_adler32(), stb_decompress_length(), and stb_decompress_token().

Referenced by ImFontAtlas::AddFontFromMemoryCompressedTTF().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stb_decompress_length()

static unsigned int stb_decompress_length ( const unsigned char *  input)
static
3959{
3960 return (input[8] << 24) + (input[9] << 16) + (input[10] << 8) + input[11];
3961}
static int input(void)

References input().

Referenced by ImFontAtlas::AddFontFromMemoryCompressedTTF(), and stb_decompress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stb_decompress_token()

static const unsigned char * stb_decompress_token ( const unsigned char *  i)
static
3989{
3990 if (*i >= 0x20) { // use fewer if's for cases that expand small
3991 if (*i >= 0x80) stb__match(stb__dout-i[1]-1, i[0] - 0x80 + 1), i += 2;
3992 else if (*i >= 0x40) stb__match(stb__dout-(stb__in2(0) - 0x4000 + 1), i[2]+1), i += 3;
3993 else /* *i >= 0x20 */ stb__lit(i+1, i[0] - 0x20 + 1), i += 1 + (i[0] - 0x20 + 1);
3994 } else { // more ifs for cases that expand large, since overhead is amortized
3995 if (*i >= 0x18) stb__match(stb__dout-(stb__in3(0) - 0x180000 + 1), i[3]+1), i += 4;
3996 else if (*i >= 0x10) stb__match(stb__dout-(stb__in3(0) - 0x100000 + 1), stb__in2(3)+1), i += 5;
3997 else if (*i >= 0x08) stb__lit(i+2, stb__in2(0) - 0x0800 + 1), i += 2 + (stb__in2(0) - 0x0800 + 1);
3998 else if (*i == 0x07) stb__lit(i+3, stb__in2(1) + 1), i += 3 + (stb__in2(1) + 1);
3999 else if (*i == 0x06) stb__match(stb__dout-(stb__in3(1)+1), i[4]+1), i += 5;
4000 else if (*i == 0x04) stb__match(stb__dout-(stb__in3(1)+1), stb__in2(4)+1), i += 6;
4001 }
4002 return i;
4003}
static void stb__lit(const unsigned char *data, unsigned int length)
Definition imgui_draw.cpp:3975
static void stb__match(const unsigned char *data, unsigned int length)
Definition imgui_draw.cpp:3966
#define stb__in2(x)
Definition imgui_draw.cpp:3984
#define stb__in3(x)
Definition imgui_draw.cpp:3985

References stb__dout, stb__in2, stb__in3, stb__lit(), and stb__match().

Referenced by stb_decompress().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ UnpackAccumulativeOffsetsIntoRanges()

static void UnpackAccumulativeOffsetsIntoRanges ( int  base_codepoint,
const short *  accumulative_offsets,
int  accumulative_offsets_count,
ImWchar out_ranges 
)
static
2848{
2849 for (int n = 0; n < accumulative_offsets_count; n++, out_ranges += 2)
2850 {
2851 out_ranges[0] = out_ranges[1] = (ImWchar)(base_codepoint + accumulative_offsets[n]);
2852 base_codepoint += accumulative_offsets[n];
2853 }
2854 out_ranges[0] = 0;
2855}

Referenced by ImFontAtlas::GetGlyphRangesChineseSimplifiedCommon(), and ImFontAtlas::GetGlyphRangesJapanese().

+ Here is the caller graph for this function:

◆ UnpackBitVectorToFlatIndexList()

static void UnpackBitVectorToFlatIndexList ( const ImBitVector in,
ImVector< int > *  out 
)
static
2317{
2318 IM_ASSERT(sizeof(in->Storage.Data[0]) == sizeof(int));
2319 const ImU32* it_begin = in->Storage.begin();
2320 const ImU32* it_end = in->Storage.end();
2321 for (const ImU32* it = it_begin; it < it_end; it++)
2322 if (ImU32 entries_32 = *it)
2323 for (ImU32 bit_n = 0; bit_n < 32; bit_n++)
2324 if (entries_32 & ((ImU32)1 << bit_n))
2325 out->push_back((int)(((it - it_begin) << 5) + bit_n));
2326}
unsigned int ImU32
Definition imgui.h:229
T * end()
Definition imgui.h:1681
T * begin()
Definition imgui.h:1679

References ImVector< T >::begin(), ImVector< T >::Data, ImVector< T >::end(), IM_ASSERT, ImVector< T >::push_back(), and ImBitVector::Storage.

Referenced by ImFontAtlasBuildWithStbTruetype().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA

const ImVec2 FONT_ATLAS_DEFAULT_TEX_CURSOR_DATA[ImGuiMouseCursor_COUNT][3]
static
Initial value:
=
{
{ ImVec2( 0,3), ImVec2(12,19), ImVec2( 0, 0) },
{ ImVec2(13,0), ImVec2( 7,16), ImVec2( 1, 8) },
{ ImVec2(31,0), ImVec2(23,23), ImVec2(11,11) },
{ ImVec2(21,0), ImVec2( 9,23), ImVec2( 4,11) },
{ ImVec2(55,18),ImVec2(23, 9), ImVec2(11, 4) },
{ ImVec2(73,0), ImVec2(17,17), ImVec2( 8, 8) },
{ ImVec2(55,0), ImVec2(17,17), ImVec2( 8, 8) },
{ ImVec2(91,0), ImVec2(17,22), ImVec2( 5, 0) },
}

Referenced by ImFontAtlas::GetMouseCursorTexData().

◆ FONT_ATLAS_DEFAULT_TEX_DATA_H

const int FONT_ATLAS_DEFAULT_TEX_DATA_H = 27

◆ FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS

const char FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[FONT_ATLAS_DEFAULT_TEX_DATA_W *FONT_ATLAS_DEFAULT_TEX_DATA_H+1]
static
Initial value:
=
{
"..- -XXXXXXX- X - X -XXXXXXX - XXXXXXX- XX "
"..- -X.....X- X.X - X.X -X.....X - X.....X- X..X "
"--- -XXX.XXX- X...X - X...X -X....X - X....X- X..X "
"X - X.X - X.....X - X.....X -X...X - X...X- X..X "
"XX - X.X -X.......X- X.......X -X..X.X - X.X..X- X..X "
"X.X - X.X -XXXX.XXXX- XXXX.XXXX -X.X X.X - X.X X.X- X..XXX "
"X..X - X.X - X.X - X.X -XX X.X - X.X XX- X..X..XXX "
"X...X - X.X - X.X - XX X.X XX - X.X - X.X - X..X..X..XX "
"X....X - X.X - X.X - X.X X.X X.X - X.X - X.X - X..X..X..X.X "
"X.....X - X.X - X.X - X..X X.X X..X - X.X - X.X -XXX X..X..X..X..X"
"X......X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X XX-XX X.X -X..XX........X..X"
"X.......X - X.X - X.X -X.....................X- X.X X.X-X.X X.X -X...X...........X"
"X........X - X.X - X.X - X...XXXXXX.XXXXXX...X - X.X..X-X..X.X - X..............X"
"X.........X -XXX.XXX- X.X - X..X X.X X..X - X...X-X...X - X.............X"
"X..........X-X.....X- X.X - X.X X.X X.X - X....X-X....X - X.............X"
"X......XXXXX-XXXXXXX- X.X - XX X.X XX - X.....X-X.....X - X............X"
"X...X..X --------- X.X - X.X - XXXXXXX-XXXXXXX - X...........X "
"X..X X..X - -XXXX.XXXX- XXXX.XXXX ------------------------------------- X..........X "
"X.X X..X - -X.......X- X.......X - XX XX - - X..........X "
"XX X..X - - X.....X - X.....X - X.X X.X - - X........X "
" X..X - X...X - X...X - X..X X..X - - X........X "
" XX - X.X - X.X - X...XXXXXXXXXXXXX...X - - XXXXXXXXXX "
"------------ - X - X -X.....................X- ------------------"
" ----------------------------------- X...XXXXXXXXXXXXX...X - "
" - X..X X..X - "
" - X.X X.X - "
" - XX XX - "
}

Referenced by ImFontAtlasBuildRenderDefaultTexData().

◆ FONT_ATLAS_DEFAULT_TEX_DATA_W

◆ proggy_clean_ttf_compressed_data_base85

const char proggy_clean_ttf_compressed_data_base85[11980+1]
static

◆ stb__barrier_in_b

const unsigned char* stb__barrier_in_b
static

Referenced by stb__lit(), and stb_decompress().

◆ stb__barrier_out_b

unsigned char * stb__barrier_out_b
static

Referenced by stb__match(), and stb_decompress().

◆ stb__barrier_out_e

unsigned char* stb__barrier_out_e
static

◆ stb__dout

unsigned char* stb__dout
static