4

I have just started developing a Chrome Extension, and I am almost done except for this one little problem.

I want to set a Unicode character as the badge text on a browser action, but what I've tried so far is NOT working.

Here's how it looks now. enter image description here

  • Unicode Character - ๐Ÿ’ฉ (also known as 'poop')
  • Its Unicode - U+1F4A9 (from here)

What I tried till now:

chrome.browserAction.setBadgeText({text: '💩'});   //shows '💩'
chrome.browserAction.setBadgeText({text: 'U+1F4A9;'});    //shows 'รš+1F4A9;'
chrome.browserAction.setBadgeText({text: '\U1F4A9;'});    //shows '\U1F4A9;'
chrome.browserAction.setBadgeText({text: '\\U1F4A9;'});   //shows '\\U1F4A9;'
chrome.browserAction.setBadgeText({text: ''});          //shows empty box

What should I do so that it shows ?

UPDATE : As mentioned by @Xan in his answer and in a comment, that UI rendering cannot be controlled.

So, I tried doing this <title></title> to see whether Chrome can render that and can it show in the tab heading.

Turned out that Chrome can. enter image description here

So, Why can't Chrome render in one place (browser Action) and can in another place (Tab heading or title bar) ?

Shrinivas Shukla
  • 4,325
  • 2
  • 21
  • 33
  • 2
    Scroll down to "C/C++/Java Src" on your web page, and you'll see the correct escape sequence: `\uD83D\uDCA9`. If you see a box (that's what I see in Firefox and Chrome), then the font does not have the Pile of Poo glyph. โ€“ Rob W Jul 19 '15 at 09:17
  • What OS are you trying this under? Do you have any better luck when you use a literal, say, 'ั'? โ€“ pvg Jul 19 '15 at 10:36
  • @pvg I am trying this on Windows 8.1 OS - 64bit and the character `ั` works fine but `` doesn't. โ€“ Shrinivas Shukla Jul 19 '15 at 10:43
  • That is probably because 'ั' or 'ya' is cyrillic and a single character, supported by pretty much any international font. Most emoji consist of two characters. โ€“ Stephan Bijzitter Jul 19 '15 at 14:17

1 Answers1

4

As Rob's comment shows, the last form is correct.

However, the font used for the badges simply does not have that Unicode character, and Chrome only ever uses 1 font for the badge, not looking for substitutions.

As such, you're out of luck.

Xan
  • 74,770
  • 16
  • 179
  • 206
  • Is there any way to include such a font in my Chrome extension which supports ``, like we do in regular web application? โ€“ Shrinivas Shukla Jul 19 '15 at 12:53
  • No; you cannot specify which font is used for UI rendering. โ€“ Xan Jul 19 '15 at 13:01
  • @ShrinivasShukla Why does the font matter? Shouldn't the font substitution algorithm fall back to using any font whatsoever for missing glyphs in the default one? โ€“ tchrist Jul 19 '15 at 14:11
  • @tchrist In web content, yes. In Chrome's own UI elements, apparently not. โ€“ Xan Jul 19 '15 at 14:18
  • @ShrinivasShukla \*shrug\* Chrome simply does _not_ do any substitutions for badges. There's a set font and that's it. โ€“ Xan Jul 19 '15 at 16:08
  • @Xan, Thank for everything. Seems like I will have to compromise. :( โ€“ Shrinivas Shukla Jul 19 '15 at 16:11