I am making a 3D environment in Unity which is designed to retrieve Tweets and display them using Unity's TextMesh. The problem arises when a tweet includes an emoji (emoticons such as 😀 and 😉, which should appear as smiley faces in your browser).
When a tweet includes one of these characters, unity renders them as either a "?" symbol, or the following symbol in the editor:
...and like this when using a TextMesh:
What Do I Want?
All I need is to represent any smiley/emoticon as character in the TextMesh, using a TTF font. I don't need to show a full colour image (like your browser/phone does) of the emoji. I realise that there are some extensions in the Unity store which allow you to do that - TextMesh Pro for example. If there's an easy way of doing this though, it would be better than plain characters.
I am specifically looking to do this using TextMesh, not in any of the new GUI system components.
Things I've Tried
You'd have thought that by downloading a font which contains characters for all of the emoticons you can imagine with their correct encoding, and using this as the font for the TextMesh would solve the problem. This was unfortunately not the case when I tried using Symbola (http://users.teilar.gr/~g1951d/). This, along with some other fonts rendered the "?" symbol despite having characters for the emoticons being used.
Related
Unity texts have that feature where certain HTML-style tags can be used to format text, like <b></b> for bold and <color=#ff0000></color> for colored text. Sometimes I see some Unity games display user-provided text (like a nickname or a chat message) and they are not escaped, which means the formatting tags get applied if the user types in those tags. Asking for those devs (I don't dev myself), what's the best/easiest way to escape those tags? Are there built-in functions for that, or should they write/import a new function?
Edit: Yes I did look up "C# HTML escaping" and found a function that escapes < into <, but Unity doesn't render < as < and I got <color=#ff0000> nonsense in the Unity scene. Yes I do realize there is a tick box that disables rich text but there is also a use case where, for example, you actually want to use user-provided text within a rich text context.
Both Text and TMP_Text (TextMeshPro and TextMeshProUGui) have according field Rich Text in the Inspector or via code it is Text.supportRichtText and TMP_Text.richText. By default they come enabled.
Yes I do realize there is a tick box that disables rich text but there is also a use case where, for example, you actually want to use user-provided text within a rich text context.
So quite simple
Enable this option in use cases where you want to allow that rich text tags change the format
Disable this option if you do not want it.
As said you can even switch this on runtime via code when needed.
If you want to further prevent your users from being able to putting certain symbols into input fields at all use the according input type and input validation settings (see e.g. InputField)
I've been trying to make a project that creates Flash Cards , and i wanted to make the user be able to input any text on either sides of the card , the problem I'm facing now is that since the textbox(from TextMeshPro or regular one) has certain font whenever I try to input another languages like Japanese or Arabic it simply shows as squares, I tried the suggestion to use the textmesh pro dynamic font feature but still with no luck.
my question is , is there any way to do what I'm asking for without using fallback assets for every single language?
are there any unity plugins that do the job?
Like I said the aim is to make a textbox that displays whatever language is put in it.
any tips would be appreciated
NOTE: the solution doesn't need to use textmeshpro , it can use standard text component or any other custom ones.
I think the problem is the font. You will need a font that supports all the characters.
Perhaps you could use different fonts for different languages.
TextMeshPro creates a texture from the fonts characters. This texture will get very large if you have a lot of characters (e.g. for chinese). Because of that, the standard Text-component should be easier to work with.
(But I don't exactly know how the dynamic font feature of TextMeshPro works.)
So Since this is the first time I've worked with Fonts it appears that I didn't quite understand how fonts work and now I found the right way to approach the problem so I will give here the steps that I used to solve the multi-language issue:
1)you need a Font that supports as many languages as possible i found out that "Ariel Unicode" fits this need quite well with support to most common used languages support
2)you need to create a TextMeshPro Dynamic font asset that uses the font chosen in step one. (I tried using TextMeshPro Dynamic font before but i was mistakenly under the impression that the dynamic feature "search" for a font that has a certain character rather than we need to supply the font and it searches within the font for a character, that was a bit of a stupid assumption at my part created from the fact that I didn't understand how fonts work) .Here is a link how to use Dynamic SDF textmeshPro
I hope this helps someone with this process.
I have a native app that uses Mapbox, my app is mainly for Kurdish customers.
I have a really big problem, the texts and addresses shown on the app use a font that displays the Kurdish texts poorly, I like to make the map show all texts and addresses using Noto Kufi Arabic font or any other font I like.
But how do I do that?
You can customise your style in Mapbox Studio by replacing the font to your liking, then publish your new style and use it in your app.
How can i add text outline in unity over a text UI object?
I want to do it in the designer/editor view. i cant see to find any useful topic and i also cant see how to add it from the designer view.
My project is 2d and i'm using the latest unity version 5.3. I want to achieve similar effect.
Or. Alternatively to Joe's answer. To simply add a outline effect to a normal .ttf font :
Click on the text object from the Hierarchy
Click the Add Component button in the inspector
Type "outline" in the search bar.
Add the outline component.
Note! This explains how to make custom type ("sprite sheet type") in Unity.
Before reading it, check Uri's & Programmer's answer which explains using the handy new "outline" feature in .UI ! It may well be enough!
Unity does not have any fancy type handling at all.
You can drop in "normal" .ttf fonts,
or, you can drop in "image fonts", called custom fonts by Unity, where you literally make each letter on a sprite sheet.
A font sprite sheet looks something like this:
Here's exactly how to do it ...
(1) you have to use GlyphDesigner (or any similar product) to actually make your custom font sheet. Find the product you like for your Mac or PC to do this.
(2) There is a critical trick.
Unity completely forgot to include a type matcher for custom fonts. (They may fix this in Unity 6.) It's one of the stupidest things in Unity. So, fortunately there is a free and perfect script
BitmapFontImporter.cs
https://github.com/BenoitFreslon/BitmapFontImporter
There's a full and long tutorial link at that page.
You have to include that to make custom fonts work. It's just one of those weird things about Unity.
So in short, firstly you have to literally "draw" such custom fonts, letter by letter. In fact you need to use something like GlyphDesigner to do that.
Secondly in Unity you have to use the extremely handy script mentioned above or it won't work. Enjoy!
http://answers.unity3d.com/answers/1105527/view.html
TextMesh Pro from the Asset Store does the job and it can be imported for free.
This gives plenty of possibilities fort texts, including how thick the outline should be.
I have a problem about the font in iphone/ipad
Everyone knows UILabel can't do rich text.
So I choose FrontLabel http://github.com/zynga/FontLabel/blob/master/README
I guess what FrontLabel is doing is something like NSAttributedString and core text framework, and also, it is quite low level. But anyway, I have a problem.
If I want to display a mixed language text, let's say English + Chinese, and give the whole string a font of "ArialMT", then all Chinese characters are displayed like small squares.
I have tried, if I assign "STHeitiTC-Light" font to the text, no problem, both Chinese and English can be displayed, because STHeitiTC-Light is a Chinese font in iphone/ipad.
I think FrontLabel can't automatically select best font for non-latin text if the given font does not apply.
If I use UILabel and assign it as "ArialMT", and let it display text of Chinese or Japanese, NO problem, right? I guess apple is detecting font for different language?
Please give me some clues how can I solve this problem if I want to use FrontLabel?
Thanks
author of FontLabel here.
You're right, FontLabel does not do automatic font fallback if the glyph cannot be found in the selected font. Implementing such a behavior was outside the scope of the project, as it can be quite complex. UILabel does perform this, as it uses WebKit to do the actual text rendering and WebKit supports font fallback. I am unsure if CoreText provides this or if it behaves like FontLabel. In any case, if you need multiple fonts in FontLabel, you can specify different fonts for different ranges of your ZAttributedString. Unfortunately there's no easy way to determine which ranges are necessary without inspecting your string directly. If you know you're only working with English and Chinese, you could iterate over the characters in your string to determine if they're likely to be english or chinese characters, and use that to determine which ranges to assign fonts to. The alternative would be to teach FontLabel how to perform font fallback, but as I said before, that's quite complicated.
Alternatively, if you're comfortable require 4.0 or above on iPhone, you can try using CoreText. As I said before, I'm unsure if it does font fallback, but it's worth investigating.