mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
Fonts: remove ImFontHooks in favor of a AddRemapChar() implementation.
This commit is contained in:
parent
89e880dfd1
commit
f6735c223c
3 changed files with 12 additions and 39 deletions
|
|
@ -4365,12 +4365,11 @@ static void ImFontBaked_BuildGrowIndex(ImFontBaked* baked, int new_size)
|
|||
baked->IndexLookup.resize(new_size, IM_FONTGLYPH_INDEX_UNUSED);
|
||||
}
|
||||
|
||||
static void ImFont_FontHookRemapCodepoint(ImFontAtlas* atlas, ImFont* font, ImWchar* c)
|
||||
static void ImFontAtlas_FontHookRemapCodepoint(ImFontAtlas* atlas, ImFont* font, ImWchar* c)
|
||||
{
|
||||
if (font->FontHooks && font->FontHooks->FontHookRemapCodepoint != NULL)
|
||||
font->FontHooks->FontHookRemapCodepoint(atlas, font, c);
|
||||
else if (atlas->FontHooks && atlas->FontHooks->FontHookRemapCodepoint != NULL)
|
||||
atlas->FontHooks->FontHookRemapCodepoint(atlas, font, c);
|
||||
IM_UNUSED(atlas);
|
||||
if (font->RemapPairs.Data.Size != 0)
|
||||
*c = (ImWchar)font->RemapPairs.GetInt((ImGuiID)*c, (int)*c);
|
||||
}
|
||||
|
||||
static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codepoint)
|
||||
|
|
@ -4387,7 +4386,7 @@ static ImFontGlyph* ImFontBaked_BuildLoadGlyph(ImFontBaked* baked, ImWchar codep
|
|||
|
||||
// User remapping hooks
|
||||
ImWchar src_codepoint = codepoint;
|
||||
ImFont_FontHookRemapCodepoint(atlas, font, &codepoint);
|
||||
ImFontAtlas_FontHookRemapCodepoint(atlas, font, &codepoint);
|
||||
|
||||
//char utf8_buf[5];
|
||||
//IMGUI_DEBUG_LOG("[font] BuildLoadGlyph U+%04X (%s)\n", (unsigned int)codepoint, ImTextCharToUtf8(utf8_buf, (unsigned int)codepoint));
|
||||
|
|
@ -5092,25 +5091,9 @@ void ImFontAtlasBakedSetFontGlyphBitmap(ImFontAtlas* atlas, ImFontBaked* baked,
|
|||
ImFontAtlasTextureBlockQueueUpload(atlas, tex, r->x, r->y, r->w, r->h);
|
||||
}
|
||||
|
||||
// FIXME: Use ImFontHooks::FontHookRemapCodepoint() hooks.
|
||||
void ImFont::AddRemapChar(ImWchar from_codepoint, ImWchar to_codepoint, bool overwrite_dst)
|
||||
void ImFont::AddRemapChar(ImWchar from_codepoint, ImWchar to_codepoint)
|
||||
{
|
||||
IM_UNUSED(from_codepoint);
|
||||
IM_UNUSED(to_codepoint);
|
||||
IM_UNUSED(overwrite_dst);
|
||||
/*
|
||||
IM_ASSERT(IndexLookup.Size > 0); // Currently this can only be called AFTER the font has been built, aka after calling ImFontAtlas::GetTexDataAs*() function.
|
||||
unsigned int index_size = (unsigned int)IndexLookup.Size;
|
||||
|
||||
if (from_codepoint < index_size && IndexLookup.Data[from_codepoint] == (ImU16)-1 && !overwrite_dst) // 'from_codepoint' already exists
|
||||
return;
|
||||
if (to_codepoint >= index_size && from_codepoint >= index_size) // both 'from_codepoint' and 'to_codepoint' don't exist -> no-op
|
||||
return;
|
||||
|
||||
BuildGrowIndex(from_codepoint + 1);
|
||||
IndexLookup[from_codepoint] = (to_codepoint < index_size) ? IndexLookup.Data[to_codepoint] : (ImU16)-1;
|
||||
IndexAdvanceX[from_codepoint] = (to_codepoint < index_size) ? IndexAdvanceX.Data[to_codepoint] : 1.0f;
|
||||
*/
|
||||
RemapPairs.SetInt((ImGuiID)from_codepoint, (int)to_codepoint);
|
||||
}
|
||||
|
||||
// Find glyph, load if necessary, return fallback if missing
|
||||
|
|
@ -5162,7 +5145,7 @@ bool ImFontBaked::IsGlyphLoaded(ImWchar c)
|
|||
bool ImFont::IsGlyphInFont(ImWchar c)
|
||||
{
|
||||
ImFontAtlas* atlas = ContainerAtlas;
|
||||
ImFont_FontHookRemapCodepoint(atlas, this, &c);
|
||||
ImFontAtlas_FontHookRemapCodepoint(atlas, this, &c);
|
||||
for (ImFontConfig* src : Sources)
|
||||
{
|
||||
const ImFontLoader* loader = src->FontLoader ? src->FontLoader : atlas->FontLoader;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue