mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-16 22:40:48 +00:00
Problem with Russian characters #609
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#609
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello. I'm having troubles displaying Russian characters.
How it looks:
http://dl1.joxi.net/drive/2016/04/25/0001/3646/101950/50/41ddce7ebf.jpg
Atlas texture:
http://dl2.joxi.net/drive/2016/04/25/0001/3646/101950/50/00ef6316db.jpg
Any suggestions?
Omar, I used your code from an issue raised back in 2015 to make some tests:
I get following output:
Hello,
That's not UTF-8, this is using a local russian/cyrillic codepage.
Unfortunately C++ doesn't make it easy to specify UTF-8 literal.
Another solution would be to allow creating glyph redirection in ImFont so you can use your local codepage, but it becomes harder to share code (without UTF-8 non-cyrillic user will see garbage in your literals in the source code). I could add a helper to do so, basically in your ImFont data you need to:
font->IndexLookup[0xCF] = font->IndexLookup[0x043F]; // 043F is codepoint for П
font->IndexXAdvance[0xCF] = font->IndexXAdvance[0x043F];
So you can create a mapping table {{ 0xCF, 0x043F },....} for cyrillic and apply this code over all entries (watch out to check that 0x043F < font->IndexLookup.size();
I could add a helper to remap characters.
Thanks for your reply.
I managed to get it working by storing string as wide chars and then using
WideCharToMultiBytefunction converting toCP_UTF8.Not sure if this is a correct way of doing it but it works for me.
I will introduce the helper to add character remapping in the font shortly, it was already in my todo list and would be helpful for "international" users.
I have added the ImFont::AddRemapChar() function now.
font->AddRemapChar(0xCF, 0x043F)The problem with it is that currently it can only be used AFTER the font has been built, aka after the ImFontAtlas::GetTexData* functions has been called. Looking at my notes this was the reason I didn't add this function earlier. So I have added the function and made it assert if the font hasn't been built and documented it as such. Will fix/improve later.
You can borrow one of those table:
CP1251.TXT
https://en.wikipedia.org/wiki/Windows-1251
And then use local codepage in your code.