dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
6.93k stars 1.15k forks source link

Add support for Color Emoji support #91

Open dotMorten opened 5 years ago

dotMorten commented 5 years ago

Currently when you render emojis in WPF, they are rendered black'n'white, and not rendering with the correct emoji color. It would be good if we could update the text rasterizer renderers to render with the correct color. There's a proof of concept implementation here: https://github.com/samhocevar/emoji.wpf, so perhaps @samhocevar would be willing to contribute? (I'm guessing this would be done on the DirectWrite level though)

Screenshot from Emoji.WPF image

Documentation how this works from https://blogs.windows.com/buildingapps/2017/06/06/using-color-fonts-beautiful-text-icons/#Crwe2VHsjP5PgAXS.97 (thanks @mikedn): image

Also for discussion: Should we have a IsColorFontEnabled property that turns this behavior on/off, and should it be default like in UWP (behavior change). Also only 8.1+ uses the D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT flag, so I'm assuming the behavior would always be black/white on Win7 and 8.0

mikedn commented 5 years ago

I'm guessing this would be done on the DirectWrite level though

Yes, DWrite should already handle this if you tell it so:

https://blogs.windows.com/buildingapps/2017/06/06/using-color-fonts-beautiful-text-icons

dotMorten commented 5 years ago

@mikedn Thanks. Info added to issue

mikedn commented 5 years ago

Ahm, but then WPF doesn't actually use D2D, it only uses DWrite. That might mean that to implement this you need to do some more involved work in WPF's rendering code. I think, it's been a while since I looked at WPF's text rendering...

fabiant3-zz commented 5 years ago

@dotMorten - This looks like a great feature addition. Unfortunately, at this time we are unsure of the exact time when the native layers will be open sourced. I will move this to future for now.

be5invis commented 5 years ago

@mikedn DWRITE already has complete color font support. Just use IDWriteFactory4::TranslateColorGlyphRun

mikedn commented 5 years ago

@be5invis I know, but as I mentioned above DWrite isn't the problem. The problem is WPF's rendering which is unlikely to support colored glyph run. It's been a while since I looked at that code but I don't expect it to be easy to add such support.

be5invis commented 5 years ago

@mikedn

It is not that complex. Color glyph conversion lies at the very final end so you can just wrap your original draw call into something like this: https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/DWriteColorGlyph/cpp/CustomTextRenderer.cpp (this one supports all latest DWRITE's color formats, even SVG).

be5invis commented 5 years ago

Other notable features of Emoji support:

be5invis commented 5 years ago

cc. @fdwr

virzak commented 4 years ago

I know it might not be ideal, but you can solve that issue with Xaml Islands.

https://github.com/windows-toolkit/WindowsCommunityToolkit/issues/3216#issuecomment-617431386

Bart-Verdonck commented 4 years ago

Can't believe this is still not supported out-of-the-box... It's 2020 already 🤦

Lorymi commented 3 years ago

@be5invis @dotMorten @virzak @mikedn @Bart-Verdonck Any news for support colored Emoji in WPF? AFTER 2 YEARS?????

ShankarBUS commented 3 years ago

@Lorymi, WPF is more like "put to maintenance mode". You won't get any new features sticking to it. Just bug fixes and .NET 5+ support. It will be superceded by WinUI, no matter what people wants.

Lorymi commented 3 years ago

@ShankarBUS Thanks. UWP status challenged by the destruction of WINDOWS PHONE No new features will be added to WPF It's very sad that in 2020 Microsoft does not care about desktop programmers While Google, Apple and Facebook and etc.. are all looking for innovations and new features tailored to the needs of users

XamDR commented 3 years ago

@be5invis @dotMorten @virzak @mikedn @Bart-Verdonck Any news for support colored Emoji in WPF? AFTER 2 YEARS?????

If you want support for colored fonts, you could try UWP. It's not ideal, but it has gotten better over the years for desktop development.

fcharlie commented 3 years ago

I want to ask if there is any progress on this question? If PresentationNative_cor3.dll can be open sourced, maybe you can help solve this problem.

samhocevar commented 3 years ago

FYI, I now consider Emoji.Wpf to be in very good shape. It may have its shortcomings and does not replace a native solution, but it’s pretty robust for many uses.

If any people following this thread have been considering it but did not end up using it, I’d be happy to hear why. Also any suggestions and feature requests are welcome.

XamDR commented 3 years ago

FYI, I now consider Emoji.Wpf to be in very good shape. It may have its shortcomings and does not replace a native solution, but it’s pretty robust for many uses.

If any people following this thread have been considering it but did not end up using it, I’d be happy to hear why. Also any suggestions and feature requests are welcome.

Well, in my case the biggest issue is that your library doesn't support the textbox control.

samhocevar commented 3 years ago

Well, in my case the biggest issue is that your library doesn't support the textbox control.

@XamDR Note that emoji:RichTextBox has a bindable Text property (which is even two-way bindable in the current master branch), making it a more acceptable replacement for the standard TextBox.

I understand why one would want a stripped down version that behaves a lot more like TextBox, so you may now follow this issue.

fcharlie commented 1 year ago

It's been almost 5 years since this question was opened, is there any progress on this issue?

pchaurasia14 commented 1 year ago

@fcharlie - Unfortunately no. We haven't been able to pick this item due to existing commitments.

We will get to this as soon as possible.

fdwr commented 1 year ago

@pchaurasia14 When you get to it, feel free to ask me questions, as I worked on DirectWrite for 10 years and integrated color SVG/bitmap fonts into XAML rendering a while back (2016-03-04). Granted, I'm not sure how much code similarity there is between it and WPF.

pchaurasia14 commented 1 year ago

@fdwr - Absolutely :)

alexinea commented 1 month ago

Hey, this issue has been created for 6 years. How is the progress now?