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
Garbage displayed after 6-byte emoji. #2186
Comments
I found a work around:
|
I can't reproduce, could you please send a minimal config? |
Of course you have to have Noto Color Emoji installed. On Debian/Ubuntu:
The real weather command is something like this:
But I cannot guarantee it will be sunny in your locale. I just found that if I drop
I believe the whole issue is that polybar is not handling variation selectors. |
I see. The issue is For now, I would recommend either changing or removing Edit: @patrick96, what do you think? Should Polybar handle the variation selection better? If so, how? |
My understanding, and maybe it's wrong, is that variation selectors modify the previous code point. So, polybar should not just treat it as another character. It should either ignore it or take it in to consideration when selecting the correct variant of the emoji. Polybar could just filter out variation selectors. I'm not quite sure how they are supposed to be handled. You would think the font would need this info. |
You would think. My uneducated guess is that Polybar is displaying each character at a time, so character sequences aren't picked up by fonts. If this were the case, the variation selectors should be filtered out or something. |
I don't have Unifont, and don't have a character to display for |
I have this issue too, can I just ignore it since the emoji is still displayed? |
I found an emoji on emojipedia that was followed by the VS16 code, in polybar the VS16 code would throw warnings as an unmatched character, as a workaround I was able to copy-paste just the emoji code without the VS16 using the corresponding Wikipedia Unicode block page which lists the emoji's with and without the VS's. |
The "dropping unmatched character" warnings are annoying, but if it is displayed fine, then it's no worries. |
The problem is though, that it's NOT displayed fine. For example: U+2197 (↗) shows a northwest arrow, however, it is tiny and unimpressive. However, U+2197,U+FE0F ( EDIT: Funny enough, while editing this message, I see two distinct different glyphs for the northwest arrow. However upon saving, github displays them both as the variant. EDIT2: Alternately, defaulting to automatically display the variation glyphs like github is doing would also be acceptable (to me) |
This wouldn’t solve the problem but just shift it. Now people that want the normal variation can’t properly display the emoji. :) |
Well, commenting on this issue has been on my todo list for a while. The issue here hints at the underlying issues polybar has with font rendering: We do it ourselves using the cairo low-level text api. This is an excerpt from the cairo text api:
As I understand it, this means any kind of algorithm to display all kinds of unicode control characters would have to be done by us, which we don't by the way. This creates a number of issues:
Now, to address some comments in this thread: From @parmort
Yes! We should definitely have proper font handling. Filtering out control characters is at best a temporary workaround to not mess up people's bars.
This is part of the problem, but I am not sure that passing the character together with its variant selector would make a difference. It's likely that the character and variant of the character are two different glyphs inside the font, but I don't know enough about unicode and fonts to be sure. Polybar doesn't always render each character at a time, but due to the way we do font fallback, the variant selector may be displayed using a different font. That's because we treat each character as a printable character and try to find the first font in the list that can display it. So what happens in the original post is, as @parmort has correctly identified, polybar sees that the emoji font can display the sun emoji, but it doesn't find a glyph for the variant selector in the emoji font. Why would it? It's not a printable character. It then goes further down the list and the unifont font happens to have a glyph for it because it tries to provide printable characters for almost every unicode code point (even if they're control characters). From @oldmansutton and @mainrs
I agree.
None of this has been particularly actionable information. How exactly this will/should happen, I am not sure. I have barely any experience with pango, cairo, or font rendering in general (the font renderer was here before I started contributing to polybar). From everything I have read, it may not be possible to just replace the font rendering with pango without breaking existing functionality. If anyone has experience with pango, I would appreciate your insight here:
The answers to this will inform how exactly our solution will look like (maybe we need to translate all formatting tags to pango markup?). In any case, I think pango rendering should be a separate code path while still leaving the current functionality in tact. There should maybe be a setting in the bar section to switch to the new system. If so, it should be as "simple" (the dispatch is simple, the rendering itself probably not) as to distinguish between the two cases in I will open a seperate issue for pango rendering to not clog up specific discussions. I will also add it to the 3.7.0 so that we can focus on this after the next release. EDIT: I have now opened the new issue #2576 |
Some emojis display normally in the terminal but are followed by garbage in polybar.
For example, the following command will produce a sun emoji ☀️:
This works great in the terminal but displays with UTF garbage in polybar.
Oddly it works correctly with this code:
But in the terminal this only displays a small non-color sun emoji.
I'm trying to get
wttr.in
to display correctly on polybar.Edit: Apparently the problematic code is VARIATION SELECTOR-16 in UTF-8 format.
The text was updated successfully, but these errors were encountered: