|
|
|
@ -1368,6 +1368,7 @@ ImFontAtlas::ImFontAtlas()
|
|
|
|
|
TexWidth = TexHeight = 0;
|
|
|
|
|
TexUvScale = ImVec2(0.0f, 0.0f);
|
|
|
|
|
TexUvWhitePixel = ImVec2(0.0f, 0.0f);
|
|
|
|
|
Flags = 0x00;
|
|
|
|
|
for (int n = 0; n < IM_ARRAYSIZE(CustomRectIds); n++)
|
|
|
|
|
CustomRectIds[n] = -1;
|
|
|
|
|
}
|
|
|
|
@ -1619,6 +1620,8 @@ bool ImFontAtlas::GetMouseCursorTexData(ImGuiMouseCursor cursor_type, ImVec2* ou
|
|
|
|
|
{
|
|
|
|
|
if (cursor_type <= ImGuiMouseCursor_None || cursor_type >= ImGuiMouseCursor_Count_)
|
|
|
|
|
return false;
|
|
|
|
|
if (Flags & ImFontAtlasFlags_NoMouseCursors)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
ImFontAtlas::CustomRect& r = CustomRects[CustomRectIds[0]];
|
|
|
|
|
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
|
|
|
@ -1774,7 +1777,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|
|
|
|
IM_ASSERT(buf_ranges_n == total_ranges_count);
|
|
|
|
|
|
|
|
|
|
// Create texture
|
|
|
|
|
atlas->TexHeight = ImUpperPowerOfTwo(atlas->TexHeight);
|
|
|
|
|
atlas->TexHeight = (atlas->Flags & ImFontAtlasFlags_NoPowerOfTwoHeight) ? (atlas->TexHeight + 1) : ImUpperPowerOfTwo(atlas->TexHeight);
|
|
|
|
|
atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight);
|
|
|
|
|
atlas->TexPixelsAlpha8 = (unsigned char*)ImGui::MemAlloc(atlas->TexWidth * atlas->TexHeight);
|
|
|
|
|
memset(atlas->TexPixelsAlpha8, 0, atlas->TexWidth * atlas->TexHeight);
|
|
|
|
@ -1854,8 +1857,12 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|
|
|
|
|
|
|
|
|
void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas)
|
|
|
|
|
{
|
|
|
|
|
if (atlas->CustomRectIds[0] < 0)
|
|
|
|
|
if (atlas->CustomRectIds[0] >= 0)
|
|
|
|
|
return;
|
|
|
|
|
if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
|
|
|
|
|
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1, FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
|
|
|
|
else
|
|
|
|
|
atlas->CustomRectIds[0] = atlas->AddCustomRectRegular(FONT_ATLAS_DEFAULT_TEX_DATA_ID, 2, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent)
|
|
|
|
@ -1901,22 +1908,31 @@ void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* pack_context_opaq
|
|
|
|
|
static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
|
|
|
|
{
|
|
|
|
|
IM_ASSERT(atlas->CustomRectIds[0] >= 0);
|
|
|
|
|
IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
|
|
|
|
|
ImFontAtlas::CustomRect& r = atlas->CustomRects[atlas->CustomRectIds[0]];
|
|
|
|
|
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
|
|
|
|
IM_ASSERT(r.Width == FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF*2+1);
|
|
|
|
|
IM_ASSERT(r.Height == FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
|
|
|
|
IM_ASSERT(r.IsPacked());
|
|
|
|
|
IM_ASSERT(atlas->TexPixelsAlpha8 != NULL);
|
|
|
|
|
|
|
|
|
|
const int w = atlas->TexWidth;
|
|
|
|
|
if (!(atlas->Flags & ImFontAtlasFlags_NoMouseCursors))
|
|
|
|
|
{
|
|
|
|
|
// Render/copy pixels
|
|
|
|
|
IM_ASSERT(r.Width == FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF * 2 + 1 && r.Height == FONT_ATLAS_DEFAULT_TEX_DATA_H);
|
|
|
|
|
for (int y = 0, n = 0; y < FONT_ATLAS_DEFAULT_TEX_DATA_H; y++)
|
|
|
|
|
for (int x = 0; x < FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF; x++, n++)
|
|
|
|
|
{
|
|
|
|
|
const int offset0 = (int)(r.X + x) + (int)(r.Y + y) * atlas->TexWidth;
|
|
|
|
|
const int offset0 = (int)(r.X + x) + (int)(r.Y + y) * w;
|
|
|
|
|
const int offset1 = offset0 + FONT_ATLAS_DEFAULT_TEX_DATA_W_HALF + 1;
|
|
|
|
|
atlas->TexPixelsAlpha8[offset0] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == '.' ? 0xFF : 0x00;
|
|
|
|
|
atlas->TexPixelsAlpha8[offset1] = FONT_ATLAS_DEFAULT_TEX_DATA_PIXELS[n] == 'X' ? 0xFF : 0x00;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
IM_ASSERT(r.Width == 2 && r.Height == 2);
|
|
|
|
|
const int offset = (int)(r.X) + (int)(r.Y) * w;
|
|
|
|
|
atlas->TexPixelsAlpha8[offset] = atlas->TexPixelsAlpha8[offset + 1] = atlas->TexPixelsAlpha8[offset + w] = atlas->TexPixelsAlpha8[offset + w + 1] = 0xFF;
|
|
|
|
|
}
|
|
|
|
|
atlas->TexUvWhitePixel = ImVec2((r.X + 0.5f) * atlas->TexUvScale.x, (r.Y + 0.5f) * atlas->TexUvScale.y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|