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

Most emojis don't work on Windows #23093

Closed
mrcdk opened this issue Oct 17, 2018 · 12 comments · Fixed by #40999
Closed

Most emojis don't work on Windows #23093

mrcdk opened this issue Oct 17, 2018 · 12 comments · Fixed by #40999

Comments

@mrcdk
Copy link
Contributor

mrcdk commented Oct 17, 2018

Godot version:

Godot 3.1 master 0d8284d

OS/device including version:

Window 10

Issue description:

In theory, emoji support was added with this PR #15780 but I've been testing it and I can't get it to work. I tested it with the NotoColorEmoji.ttf font. That's the font I think @volzhs used for both that PR and this issue #10873 but I couldn't make it work. The font doesn't work on windows (opening it with the font viewer throws an error) because Windows doesn't support the type of color font googlefonts/noto-emoji#43 But I'm not sure if it has anything to do with the issue.

Steps to reproduce:

  1. Download the font https://www.google.com/get/noto/#emoji-zsye-color
  2. Use it in a label with an emoji like 😄
@volzhs
Copy link
Contributor

volzhs commented Oct 17, 2018

did you compile with builtin_freetype option?
scons platform=windows builtin_freetype=yes

@mrcdk
Copy link
Contributor Author

mrcdk commented Oct 17, 2018

I didn't specify builtin_freetype=yes explicitly but it's on by default. I tried just in case and still nothing. When I c&p an emoji from the internet this is how it shows in the inspector but nothing shows in the actual label.

https://i.imgur.com/hgcysYG.png

I tried a couple of other emojis and some did work like ✔

https://i.imgur.com/xj8AS79.png

I also tried using a PoolByteArray and push the utf-8 bytes in there but no luck either. I tried:

func _ready():
	var bytes = PoolByteArray()
	bytes.push_back(0xF0)
	bytes.push_back(0x9F)
	bytes.push_back(0x98)
	bytes.push_back(0x84)
	text = bytes.get_string_from_utf8()

Which should be this one https://apps.timwhitlock.info/unicode/inspect?s=%F0%9F%98%84

@bruvzg
Copy link
Member

bruvzg commented Oct 17, 2018

Most emotes have char codes > 0xFFFF.

Godot string is based on wchar_t which is 16-bit on Windows, convention from UTF-8 replaces chars with codes above 0xFFFF with spaces, ustring.cpp#L1497 and Godot doesn't support UTF-16 surrogate pairs (and Windows copy-paste probably use UTF-16).

On Linux an macOS wchar_t is 32-bit and all emotes should work fine.

@mrcdk mrcdk changed the title Emoji fonts don't work Most emojis don't work on Windows Oct 17, 2018
@mrcdk
Copy link
Contributor Author

mrcdk commented Oct 17, 2018

Oh well, I updated the title of the issue to reflect that information. Thanks @bruvzg

@bruvzg
Copy link
Member

bruvzg commented Oct 17, 2018

To be precise Unicode supplementary planes have much more stuff, not just emojis.

BiDi/Shaping PR (#21791) I'm working on, should fix rendering of > 0xFFFF chars on all platforms, but wchar_t size difference still cause some input problems on Windows and excessive encoding conversions on Linux/macOS.

@xpol
Copy link
Contributor

xpol commented Oct 21, 2018

How a bout switch to char32_t?

@bruvzg
Copy link
Member

bruvzg commented Oct 21, 2018

How a bout switch to char32_t?

char32_t and char16_t are C++11 types and Godot currently targets C++03.

And it's probably better to switch to UTF-16 instead for several reasons:

@ConnorBP
Copy link

ConnorBP commented Apr 11, 2019

I wrote some code to handle utf code conversion in c++ somewhere. I can take a look for it. wchar on windows is really quite a pain in the butt, but it can be worked with.

update: I would love to be able to 😏 people in game :^)

@Anutrix
Copy link
Contributor

Anutrix commented Sep 3, 2019

Godot is gonna support C++11 soon so what's the status on this? Are we using UTF-16?

@Anutrix
Copy link
Contributor

Anutrix commented Feb 14, 2020

It's time to switch to char16_t or something else, as Godot now targets C++11.

@MrMrBlackDragon
Copy link

The same goes for Godots ord() where nearly all emojis return 32 (32 is actually the space " "), meaning that the emojis aren't recognized at all. ☹

@Calinou
Copy link
Member

Calinou commented Mar 31, 2022

Note: I changed the milestone to 3.5 as #54625 addresses the main problem described here in 3.5beta1 and later. Try 3.5beta3 for instance.

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

Successfully merging a pull request may close this issue.

9 participants