Request for ImFontBaked::FindGlyphByGlyphId
Version/Branch of Dear ImGui:
Version v1.92.9b
Back-ends:
n/a
Compiler, OS:
all
Full config/build information:
No response
Details:
I'm writing a program that uses ImGui as the main UI, and then reuses the ImGui font atlas to render text in some canvas. It works great, but now I'm doing some low level stuff with the fonts, and I need to access some glyphs in my TTF that don't have a char mapped (think of alternative shapes, custom ligatures and the like).
For normal characters I just call ImFontBaked::FindGlyph(ImWchar c), but for these weird glyphs I would need a ImFontBaked::FindGlyphByGlyphId(uint32_t glyph_id) and that it bypass the char->glyph_id mapping.
Naturally I can use AddCustomRect() but that forces me to do the render of the font myself, and the code for that is already there inside ImGui...
I reckon this is a niche need, and that it may break some assumptions in the code (everything is indexed by codepoint). But I was thinking that if instead one function ImFontLoader::FontBakedLoadGlyph(ImWchar codepoint, ...) we had two: uint32_t ImFontLoader::FontSrcMapCodepointToGlyphId(ImWchar codepoint) and then ImFontLoader::FontBakedLoadGlyph(uint32_t glyphId, ...). Then I could just subclass the standard ImFontLoader, and add my desired glyph_ids to the private unicode block....
Source: ocornut/imgui