Author Topic: UTF 32 Support  (Read 7790 times)

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
UTF 32 Support
« on: September 01, 2015, 01:01:08 AM »
As requested, I added support for UTF 32. In the next release, you will be able to create Font Assets that contains glyph / icons in the UTF 32 range.

You will be able to access these by using the uppercase U as follows "\U0001F3A3" in the Text Input Box. Via scripting, C# already supports this format so string s = "\U0001F3A3"; will work. See the example below.

[ Guests cannot view attachments ]

In this example you can also see that I am using the new font tag to use a different font for the text since this Font Asset containing icons like the fish didn't include any letters.

P.S. Again, you can now access UTF-16 glyphs by using \u00AE (lowercase u) and UTF-32 by using \U0001F3A3 (uppercase U). This works in the Text Input Box as well as in strings.
« Last Edit: September 01, 2015, 01:03:27 AM by Stephan B. »

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: UTF 32 Support
« Reply #1 on: September 01, 2015, 01:10:24 AM »
Here is an image of the Font Asset Creator showing the settings and Custom Range used to generate the UTF-32 icons.



P.S. I actually regenerated this Font Asset using the SDF 16 mode. When testing, I typically use Hinted Smooth to quickly find out what characters are available in the font. Then I switch to Distance Field 16 or 32.

dak

  • Newbie
  • *
  • Posts: 22
Re: UTF 32 Support
« Reply #2 on: October 18, 2015, 11:18:05 PM »
Is this available in the most recent release? Do you have a rough ETA if not? I read that you said "next release" but I'm unsure what has changed since you mentioned it on Sept. 1.
« Last Edit: October 18, 2015, 11:21:16 PM by dak »

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: UTF 32 Support
« Reply #3 on: October 19, 2015, 12:41:19 AM »
Is this available in the most recent release? Do you have a rough ETA if not? I read that you said "next release" but I'm unsure what has changed since you mentioned it on Sept. 1.

UTF-32 support is in the Unity 5.2 releases.

dak

  • Newbie
  • *
  • Posts: 22
Re: UTF 32 Support
« Reply #4 on: October 19, 2015, 06:25:50 AM »
OK, cool. I was having trouble generating an icon font in tmpro. If it is in there, I'll just take a deeper look into how to do it. Thanks again.

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: UTF 32 Support
« Reply #5 on: October 19, 2015, 12:23:40 PM »
OK, cool. I was having trouble generating an icon font in tmpro. If it is in there, I'll just take a deeper look into how to do it. Thanks again.

If you still have issues with that, just link the font you are using and let me know the decimal or hex value / range of the characters you need and I can make sure it all works.

dak

  • Newbie
  • *
  • Posts: 22
Re: UTF 32 Support
« Reply #6 on: October 19, 2015, 08:18:06 PM »
I don't have a range exactly. Basically, I created a custom icon font on icomoon.io that has a select set of characters (as I only need a select subset). How would I go about that if I don't have a range? I've attached the font if that is of any help.

There is a 'lock_outline' character whose values map to the following variations: http://www.unicodemap.org/details/0xE2AD/index.html. Is this possible?
« Last Edit: October 19, 2015, 08:20:12 PM by dak »

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: UTF 32 Support
« Reply #7 on: October 19, 2015, 09:57:39 PM »
I don't have a range exactly. Basically, I created a custom icon font on icomoon.io that has a select set of characters (as I only need a select subset). How would I go about that if I don't have a range? I've attached the font if that is of any help.

There is a 'lock_outline' character whose values map to the following variations: http://www.unicodemap.org/details/0xE2AD/index.html. Is this possible?

In the Font Asset Creator, you can select range by using Decimal values (Custom Range) or Hex values (Unicode Range). The lock icon is located at hex E2AC-E2AD (open and closed version).

[ Guests cannot view attachments ]

This current font doesn't contain any characters other than a few icons (including these locks) so I presume you would want to add those icons to a font that you will be using.

To access these icons since they are in the UTF-16 range, you would type "\ue2ac" in the text input box.

[ Guests cannot view attachments ]


dak

  • Newbie
  • *
  • Posts: 22
Re: UTF 32 Support
« Reply #8 on: October 20, 2015, 06:38:23 AM »
Awesome! Thank you. I was previously using the TextUnicode.cs found at http://forum.unity3d.com/threads/image-fonts-fontawesome.281746/. That is where I noticed you were going to support this too. Your support is outstanding.

dak

  • Newbie
  • *
  • Posts: 22
Re: UTF 32 Support
« Reply #9 on: October 21, 2015, 06:58:54 AM »
I had a few questions:

1) In the "Glyph Info" panel, is it possible to visually show the glyph and/or see the UTF-16 code and not just the Ascii? This would be handy in quickly knowing which icon is mapped to what (attachment).

Quote
To access these icons since they are in the UTF-16 range, you would type "\ue2ac" in the text input box.

2) Is it possible for the "Unicode Range (hex)" to take multiple ranges in an effort to get just the exact characters into the tmpro font asset?

3) Maybe I'm thinking about this the wrong way, but what I'd like to do is have the icons (that are currently working) in addition to the numbers "0-9" and the "%" symbol all in a single font asset. Any thoughts on this approach or tips on how best to do it? Previously I was using UGUI text (plus the TextUnicode.cs) and the icon font was working and would fall back to (and thus display) the "0-9" and "%" characters. When changing to TMPro, I get the warnings:

Code: [Select]
Character with ASCII value of 48 was not found in the Font Asset Glyph Table.
I believe achieving question two would alleviate this issue. As I currently understand it, I will need to add the "0-9" and "%" characters to my iconfont so I have all my target characters to display. Any thoughts?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: UTF 32 Support
« Reply #10 on: October 21, 2015, 12:16:21 PM »
I had a few questions:

1) In the "Glyph Info" panel, is it possible to visually show the glyph and/or see the UTF-16 code and not just the Ascii? This would be handy in quickly knowing which icon is mapped to what (attachment).
The Glyph Info panel allows you to see all glyphs contained in the Font Asset. The values are shown as Decimal values so I guess you might be asking about showing the Hex values in additional to decimal value?

Quote
2) Is it possible for the "Unicode Range (hex)" to take multiple ranges in an effort to get just the exact characters into the tmpro font asset?

Yes. Ranges for both Decimal and Hex are defined as follows. "32-126,160-255" and so forth.

Quote
3) Maybe I'm thinking about this the wrong way, but what I'd like to do is have the icons (that are currently working) in addition to the numbers "0-9" and the "%" symbol all in a single font asset. Any thoughts on this approach or tips on how best to do it? Previously I was using UGUI text (plus the TextUnicode.cs) and the icon font was working and would fall back to (and thus display) the "0-9" and "%" characters. When changing to TMPro, I get the warnings:

In the next major release, TextMesh Pro will be able to use Fallback fonts where your icons could be contained in a different font asset instead of having to include them in each font asset used.


Quote
I believe achieving question two would alleviate this issue. As I currently understand it, I will need to add the "0-9" and "%" characters to my iconfont so I have all my target characters to display. Any thoughts?

Until the Font Fallback is available, you can certain add those icons to the font asset you are planning on using by defining the appropriate range. This will get easier with the fallback system of course.

dak

  • Newbie
  • *
  • Posts: 22
Re: UTF 32 Support
« Reply #11 on: October 21, 2015, 05:54:36 PM »
For #1, I was referring to ideally seeing the actual icon displayed so it is easily understood what icon maps to which encoding (and hex would be nice too). Anyway, thanks for the feedback, I really appreciate it. Out of curiosity, what is your rough eta on the next major release?

Stephan B.

  • Administrator
  • Hero Member
  • *****
  • Posts: 5687
Re: UTF 32 Support
« Reply #12 on: October 21, 2015, 06:00:10 PM »
For #1, I was referring to ideally seeing the actual icon displayed so it is easily understood what icon maps to which encoding (and hex would be nice too).

Showing the icon is trickier as it would require rendering each of them into small textures. Adding the Hex value next to Decimal is pretty simple and I could get that in the next minor release.

Quote
Anyway, thanks for the feedback, I really appreciate it. Out of curiosity, what is your rough eta on the next major release?

I don't have a firm ETA yet as I am still chasing a few Unity 5.2 / 5.3 issues. I do want to get another release out which includes some performance improvements, the additional TMP Settings to control default properties of newly created text object along with some minor fixes here and there.
« Last Edit: October 21, 2015, 06:02:54 PM by Stephan B. »

dak

  • Newbie
  • *
  • Posts: 22
Re: UTF 32 Support
« Reply #13 on: October 21, 2015, 06:07:34 PM »
Cool, I look forward to it :)

dak

  • Newbie
  • *
  • Posts: 22
Re: UTF 32 Support
« Reply #14 on: October 25, 2015, 03:30:32 PM »
I'm getting an odd display issue (attached), any thoughts? If I select the 'AB' or 'SC' font style, the text doesn't get any odd spacing issues. I toyed with various settings to try to fix the spacing issue, but I've had no luck. As you can see there are no spaces in the 'Text Input Box' area but when the text is actually rendered there are spacing issues (far left 'Common Pairs').
« Last Edit: October 25, 2015, 03:39:37 PM by dak »