Author Topic: How to add and use images in fonts? (emoticons)  (Read 4607 times)

bkinsey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 30
    • View Profile
How to add and use images in fonts? (emoticons)
« on: September 22, 2014, 12:07:13 PM »
Is it possible to get emoticons to appear just by setting the symbol in a Label's text, using a font with an emoticon set?  Does the emoticon have to be the same size of a font glyph?  I have a ModalDialog widget I created with displays a message, and I'd like the message to contain images.

Steps:
1. Add a .ttf file to assets location
2. Open Font Maker tab, select .ttf as source.
3. "Create the Font". Save the prefab somewhere.
4. Add an emoticon from the "Symbols and Emoticons" panel in the inspector. (I've tried symbols ":brains:" and ":)". I want to show an icon of brains, its an undead kind of game)
5. myUILabelInstance.text = ":brains";  Or myUILabelInstance.text = ":)";
6. The font the label is using is the same as the font I added the emoticon to.

When I run the game, the dialog does not have any image displayed. What am I doing wrong?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to add and use images in fonts? (emoticons)
« Reply #1 on: September 23, 2014, 11:03:39 AM »
Your symbol must match exactly. In your example you have ":brains:" symbol, but text is ":brains", which is missing one colon. NGUI's Wooden Atlas in the examples folder comes with some pre-added emoticons. Note that for the emoticons to work they must be present in the atlas.

bkinsey

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: How to add and use images in fonts? (emoticons)
« Reply #2 on: September 23, 2014, 10:08:10 PM »
Oops, that was a typo. I tried both ":brains" and ":brains:" but it did not work.  I'm guessing the issue might be that the image needs to be a specific size, and I don't know what size it needs to be? I can define a font as size 20, for example, but then the Label properties let me scale that to any value I want, so I'm not sure what size I would need, the UILabel font size, or the font prefab declared size.

I'll take a look at the example and see what I can find.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to add and use images in fonts? (emoticons)
« Reply #3 on: September 24, 2014, 01:38:12 PM »
Nope, emoticon sprites can be of any size. In Windward I use size 20 emoticons in both size 18 and 22 fonts.