Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to render colored emoji? #4169

Closed
AllenDang opened this issue May 24, 2021 · 3 comments
Closed

How to render colored emoji? #4169

AllenDang opened this issue May 24, 2021 · 3 comments

Comments

@AllenDang
Copy link

Version/Branch of Dear ImGui:

Version: 1.82
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Operating System: MacOS

My Issue/Question:

How to render colored emoji?

Here is what I've done:

  1. Add #define IMGUI_USE_WCHAR32 to imconfig.h.
  2. Add "Apple Color Emoji.ttc" font with minimal glyph range "⌚️<-watch 😊<-smile" to test emoji rendering.
  3. Create imgui.TextUnformated("⌚️<-watch 😊<-smile")

The emoji doesn't be rendered. Do I have to change anything in the renderer or platformer to render them correctly?

Screenshots/Video
截屏2021-05-24 下午6 03 55

@ocornut
Copy link
Owner

ocornut commented May 24, 2021

Hello,

If I type "How to render colored emoji" into the search box I find #3369

image

The short-answer is:

  • It only work with imgui_freetype rasterizer (need Freetype library)
  • You need to use the ImGuiFreeTypeBuilderFlags_LoadColor flag.
  • Not every font will work.

When you load a font and have a problem, always use Style Editor>Fonts to browse the loaded fonts data.

I will now work on updating the FONTS.md documentation and imgui_freeytpe documentation to mention this. Thank you!

@ocornut ocornut closed this as completed May 24, 2021
ocornut added a commit that referenced this issue May 24, 2021
…4169, #3369) + Add Fonts to Metrics. Removed IMGUI_HAS_TABLE markers.
@ocornut
Copy link
Owner

ocornut commented May 24, 2021

I will now work on updating the FONTS.md documentation and imgui_freeytpe documentation to mention this. Thank you!

Added a new section in FONTS.md now:
https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#using-colorful-glyphsemojis

And link to it from imgui_freetype/README as well.

@ocornut ocornut added the doc label May 24, 2021
@AllenDang
Copy link
Author

@ocornut Thanks for the guidance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants