mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
ImFontAtlas: Refactored internals API to 1) avoid building lookup table multiple times for merged fonts + 2) allow the mapping of custom icons inside fonts (wip, uncommited)
This commit is contained in:
parent
2170b0b278
commit
072d6d8cb5
@ -1539,7 +1539,6 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
dst_font->AddGlyph((ImWchar)codepoint, q.x0 + off_x, q.y0 + off_y, q.x1 + off_x, q.y1 + off_y, q.s0, q.t0, q.s1, q.t1, pc.xadvance);
|
dst_font->AddGlyph((ImWchar)codepoint, q.x0 + off_x, q.y0 + off_y, q.x1 + off_x, q.y1 + off_y, q.s0, q.t0, q.s1, q.t1, pc.xadvance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cfg.DstFont->BuildLookupTable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup temporaries
|
// Cleanup temporaries
|
||||||
@ -1547,8 +1546,7 @@ bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas)
|
|||||||
ImGui::MemFree(buf_ranges);
|
ImGui::MemFree(buf_ranges);
|
||||||
ImGui::MemFree(tmp_array);
|
ImGui::MemFree(tmp_array);
|
||||||
|
|
||||||
// Render into our custom data block
|
ImFontAtlasBuildFinish(atlas);
|
||||||
ImFontAtlasBuildRenderDefaultTexData(atlas);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1600,7 +1598,7 @@ void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* pack_context_opaq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
static void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
||||||
{
|
{
|
||||||
ImFontAtlas::CustomRect& r = atlas->CustomRects[0];
|
ImFontAtlas::CustomRect& r = atlas->CustomRects[0];
|
||||||
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
IM_ASSERT(r.ID == FONT_ATLAS_DEFAULT_TEX_DATA_ID);
|
||||||
@ -1650,6 +1648,16 @@ void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImFontAtlasBuildFinish(ImFontAtlas* atlas)
|
||||||
|
{
|
||||||
|
// Render into our custom data block
|
||||||
|
ImFontAtlasBuildRenderDefaultTexData(atlas);
|
||||||
|
|
||||||
|
// Build all fonts lookup tables
|
||||||
|
for (int i = 0; i < atlas->Fonts.Size; i++)
|
||||||
|
atlas->Fonts[i]->BuildLookupTable();
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve list of range (2 int per range, values are inclusive)
|
// Retrieve list of range (2 int per range, values are inclusive)
|
||||||
const ImWchar* ImFontAtlas::GetGlyphRangesDefault()
|
const ImWchar* ImFontAtlas::GetGlyphRangesDefault()
|
||||||
{
|
{
|
||||||
|
@ -849,7 +849,7 @@ IMGUI_API bool ImFontAtlasBuildWithStbTruetype(ImFontAtlas* atlas);
|
|||||||
IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasBuildRegisterDefaultCustomRects(ImFontAtlas* atlas);
|
||||||
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
IMGUI_API void ImFontAtlasBuildSetupFont(ImFontAtlas* atlas, ImFont* font, ImFontConfig* font_config, float ascent, float descent);
|
||||||
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* spc);
|
IMGUI_API void ImFontAtlasBuildPackCustomRects(ImFontAtlas* atlas, void* spc);
|
||||||
IMGUI_API void ImFontAtlasBuildRenderDefaultTexData(ImFontAtlas* atlas);
|
IMGUI_API void ImFontAtlasBuildFinish(ImFontAtlas* atlas);
|
||||||
IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
|
IMGUI_API void ImFontAtlasBuildMultiplyCalcLookupTable(unsigned char out_table[256], float in_multiply_factor);
|
||||||
IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
|
IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table[256], unsigned char* pixels, int x, int y, int w, int h, int stride);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user