Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Text Mesh Pro - The Ultimate Text Solution for Unity - Powerful & Flexible - Advanced Text Rendering

Discussion in 'Assets and Asset Store' started by Stephan-B, May 29, 2014.

Thread Status:
Not open for further replies.
  1. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    If you are using the paid / source code version of TextMesh Pro, you have to get the updated version from the TextMesh Pro user forum as projects created with these two versions are not compatible with each other.
     
  2. ceebeee

    ceebeee

    Joined:
    Mar 7, 2017
    Posts:
    397
    I've started using Unity's version of TMPro with Unity 2017. It seems TMPro doesn't support the new Sprite Atlas that was introduced with 2017. Is there any plan to add support for that?
     
  3. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    There are no immediate plans to support the new Sprite Atlas. As I get to that part in the development of the new integrated version of TMP, I'll take a look to see if it could be possible to use / leverage the new Sprite Atlas system.

    Text Sprite Assets will always be required as they contain the relevant information / metrics to add graphics inline with the text which normal sprite have no idea about.
     
  4. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    991
    @Stephan-B

    Hi Stephan,

    I am getting the below error on a custom font, I created. It happens pretty randomly and the text displays fine.
    There is for sure a character with ASCII 32 in my charset (it is shown in the glyph table). To me the warning kind of reads, I replace "SPACE" with "SPACE"... it seems to happen for:
    - OnPreRenderCanvas
    - GetPreferredWidth
    - GetPreferredHeight

    Do you know what the issue could be?

    Character with ASCII value of 32 was not found in the Font Asset Glyph Table. It was replaced by a space.
    UnityEngine.Debug:LogWarning(Object, Object)
    TMPro.TextMeshProUGUI:SetArraySizes(Int32[])
    TMPro.TMP_Text:parseInputText()
    TMPro.TextMeshProUGUI:OnPreRenderCanvas()
    TMPro.TextMeshProUGUI:Rebuild(CanvasUpdate)
    UnityEngine.Canvas:SendWillRenderCanvases()

    Character with ASCII value of 32 was not found in the Font Asset Glyph Table. It was replaced by a space.
    UnityEngine.Debug:LogWarning(Object, Object)
    TMPro.TextMeshProUGUI:SetArraySizes(Int32[])
    TMPro.TMP_Text:parseInputText()
    TMPro.TMP_Text:GetPreferredWidth()
    TMPro.TextMeshProUGUI:CalculateLayoutInputHorizontal()
    UnityEngine.Canvas:SendWillRenderCanvases()

    Character with ASCII value of 32 was not found in the Font Asset Glyph Table. It was replaced by a space.
    UnityEngine.Debug:LogWarning(Object, Object)
    TMPro.TextMeshProUGUI:SetArraySizes(Int32[])
    TMPro.TMP_Text:parseInputText()
    TMPro.TMP_Text:GetPreferredHeight()
    TMPro.TextMeshProUGUI:CalculateLayoutInputVertical()
    UnityEngine.Canvas:SendWillRenderCanvases()

    Edit:
    Unity 2017.1.1p3
    TMP 1.0.55...b12
     
    Last edited: Nov 1, 2017
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    If you are able to reliably reproduce this, could you please provide me with a simple Repro scene or just export the font asset in questions with the steps to reproduce the warning.
     
  6. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    991
    Thank you for your swift reply, I will try if I can isolate the problem in a simple scene. This will take 2 days though since I won't be working on the project till then.

    I will PM you the font in question now, maybe that already clears up things for you or at least rules out I did something wrong when creating it.
     
  7. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    991
    @Stephan-B

    I think I have nailed down the culprit.

    My string contains the character '’', "\u2019" or Decimal 8217, this one is not included in the Glyph table and is causing the issue.

    Maybe you can check the code that creates the debug message, what was misleading is that it reported ASCII of value 32 was not found.
     
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    I had a chance to look into this and the reason you are getting this warning is as follows:

    As you speculated, you are getting this warning as a result of this missing \u2019 glyph.

    So why are you then getting a warning about this missing glyph with ASCII of value 32? To answer that, I have to explain how missing glyphs are handled.

    (1) When a glyph / character is requested, TMP will first look through the font asset assigned to the text object which I refer to as the Primary font asset.

    (2) If the Primary does not contain the glyph then TMP will look through the fallback font assets assigned to the Primary as well as their own fallbacks.

    (3) If a sprite asset is assigned to the text object, TMP will search it in case it contains a sprite matching this unicode / character.

    (4) TMP then will search through the general fallback list in the TMP Settings file.

    (5) TMP will search the default font asset assigned in the TMP Settings file.

    (6) TMP will search the Default Sprite Asset for a sprite using this unicode value.

    (7) At this point, this glyph is not available anywhere so we replace it by the Missing Glyph Replacement defined in the TMP Settings file which is ASCII 0 or the .notdef glyph.

    (8) If we can't find that glyph either then as a last ditch effort TMP will try to find and use a space (32) which in your case is why your are getting this warning.

    I guess I could replace this last warning to reference the original glyph which would be clearer.
     
  9. sngdan

    sngdan

    Joined:
    Feb 7, 2014
    Posts:
    991
    Thank's great explanation and also fantastic what logic TMP handles in the background.
    - Yes, i think it would be good to log the ASCII value of the glyph that could not be resolved
    - At what stage do you actually provide a log warning? Only at stage (8) or also at an earlier stage?
     
  10. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    Only at the last stage as with the previous stages you would either the requested glyph although it might be coming from a fallback or the .notdef glyph.

    I have already made the change on my end to report the glyph that was requested and missing.
     
  11. ramin1000

    ramin1000

    Joined:
    Apr 1, 2017
    Posts:
    14
    Hi,
    Can I use this for RTL Language. Unity does not support RTL language.:(:(:(:(
     
  12. ramin1000

    ramin1000

    Joined:
    Apr 1, 2017
    Posts:
    14
    any help appreciate
     
  13. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    TextMesh Pro does include basic RTL support but doesn't yet have support for OpenType features which is used heavily by RTL languages. See the following thread from the TMP user forum.
     
  14. ramin1000

    ramin1000

    Joined:
    Apr 1, 2017
    Posts:
    14
    Thank you Stephan, Can we hope to have TMP Open Type features in future?
     
  15. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    As I posted in one of these threads, support for OpenType font features is one of the main new features planned for the new / integrated version of TMP.
     
  16. ramin1000

    ramin1000

    Joined:
    Apr 1, 2017
    Posts:
    14
  17. ramin1000

    ramin1000

    Joined:
    Apr 1, 2017
    Posts:
    14
    Thank you Stephan.
     
  18. ramin1000

    ramin1000

    Joined:
    Apr 1, 2017
    Posts:
    14
    When will the new version be prepared Sir?
     
  19. ramin1000

    ramin1000

    Joined:
    Apr 1, 2017
    Posts:
    14
    In free version or paid?
     
  20. ramin1000

    ramin1000

    Joined:
    Apr 1, 2017
    Posts:
    14
    I read RTL link (TMP Forum). 1- I couldn't register 2- I follow your step by step tutorial about using arabic free RTL support tools and TMP, But I see Squares instead fcorrect font. why?
     
  21. pep_dj

    pep_dj

    Joined:
    Nov 7, 2014
    Posts:
    156
    In the Font Asset Creator, please, can you add the possibility to use more than one font sources? So, if a glyph is not found in the first font source, it will search on the second font source, and if not found, in the third, etc... Like the fallback system in font assets, but in the creator.

    I would like to generate all the glyphs I need in one font asset.
     
  22. oLDo

    oLDo

    Joined:
    Mar 14, 2017
    Posts:
    55
    I still have a issue with TextMeshPro shaders in unity2017.2. I received two errors while I was building a scene. My solution:

    TMP_Sprite.shader after line 83 with content "v2f OUT;" I put
    UNITY_INITIALIZE_OUTPUT(v2f, OUT);

    And in TMP_Bitmap-Mobile.shader I removed "float4 vert" variable in method "vert" which starts on line 82. After then I replaced all variable references in that method for "v.vertex".
     
  23. k1ljcore

    k1ljcore

    Joined:
    Nov 21, 2014
    Posts:
    4
    Hello,

    Unity 2017.2.0f3, TM Pro (latest version) 1.0.55.xx.0b12 (Aug 10, 2017)

    I have some issue with glow effect - I can't set black color for glow.



    I have found that my problem exist due to next lines:



    So, I changed it to:



    And it works for me.



    Just curious, is there some reasons to use exactly faceColor.rgb instead of faceColor.rgba here? Maybe I missed something?

    Tried to find something about such situation in web (and within this thread), but without success.
     
  24. arvzg

    arvzg

    Joined:
    Jun 28, 2009
    Posts:
    574
    Hi guys,

    TextMesh Pro's Outline uses the center of the font, so if you increase the thickness it eventually envelops the text.

    I'm wondering if there's a way to make outline outside of the text so when you increase the thickness the font stays the same but the thickness moves away from the (like Photoshop's 'outside' Stroke setting)
     
  25. blittlstar

    blittlstar

    Joined:
    Apr 12, 2017
    Posts:
    3
    @Stephan-B

    Hi Stephan,

    I'm running into an issue after upgrading from Unity 5.6 to 2017.2 that involves a RectMask2D, a Raw Image, and a TMPro Text box. Basically we have a grid view of images that scroll up/down behind a mask (so only a portion of the images are seen at any given time). The text box, mask, and images are all parented to the same object. If the text box is active, then when the scroll happens, we can see a flickering of the images outside of the mask, in a region that should be hidden. If, however, we either disable the text box, or move the text box to be parented under a different gameobject, then the flickering stops and it acts appropriately. Any thoughts on why this may be the case? (And to be clear, this was not happening in Unity 5.6). Here is a visual: https://gyazo.com/cb0c2d2f6fa021d0c1af81fe727fe70a

    Thanks,

    Brandon
     
  26. Wanderer13

    Wanderer13

    Joined:
    Feb 11, 2016
    Posts:
    14
    Hi,
    Seems like word wrapping not works for text with truncate option enabled. Does there any workaround?
     

    Attached Files:

  27. AdamSingle

    AdamSingle

    Joined:
    Apr 18, 2013
    Posts:
    20
    I'm having some trouble with outlines. I'm using a pool of textmesh pro UGUI prefabs that get set up at runtime from data. In some cases, they will be given an outline.
    This is done simply setting the property, as I couldn't see another way. So

    TMP_Text text;
    text.outlineWidth = value;

    However in practice this is generating a child object onto my prefab. This object is called "TMP SubMeshUI [ChelseaMarket Material]" (ChelseaMarket is the FontAsset in my test case).

    This sub object has a shared version of the material and has the outline value set on it, so all the other instances of the prefab, with different text on them, are using that material and now have the outline also. But the parent object, the original prefab, now has an instanced version of the material, with the value also set, but having no effect. So if I, in editor at runtime, manually lower the submesh outline value back to 0 so all the other prefabs don't have the outline, the one that should also loses it's outline. And it seems to ignore any value on the parent prefab.

    If I don't set the outline, I don't get this sub mesh object.
    Am I missing something or doing something wrong here?
     
    Last edited: Nov 24, 2017
  28. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    69
    @Stephan_B I have some ambitious multi-language plans, which includes support for asian languages and several types of TMP Fallback fonts.

    Now I consider TMP a fantastic asset, but it seems that a big hindrance for using TMP would be the requirement to support some dynamically changing texts in big asian languages. These may include characters which are not originally bundled with the build.

    I understand using asset bundles for additional fonts is one option, but has it drawbacks, and I'd like to not rely on just them, but have a simple dynamic fallback system to device fonts, like the default Unity text system does. I assume you know the Unity system inside out by now, and having TMP in Unity itself is a big relief to me.

    I assume that new Unity inbuilt system must somehow then be able to either use device fonts, creating the required assets dynamically - OR if not, some other fallback system, like simply switching back to the other old Unity text type, or what is the plan?

    I'm not going to wait for this to happen in Unity itself, so my question is how can I script this behavior myself? That is:

    1. Check if any character is missing from the SDF font assets OR their fallbacks font assets.

    2. If any characters are mssing, disable the TMP script temporarily and enable an old Text component with the text, which can then fallback to device fonts.

    3. When the text is next changed and all characters can be displayed by TMP, then switch it back on (and disable old Text).
     
  29. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    First my apologies to everyone who has been asking question. For whatever reason the forum has decided not to alert me to any of these post until today.

    Going forward, please post in the Unity UI & TextMesh Pro section of the user forum. Be sure to pick the TextMeshPro label to make it easier for me to identify TMP related posts.

    Posting there will also make it easier for other user to search and better overall for all TMP users.

    Combing multiple fonts in a single font asset is not possible / really practical mostly due fonts having different metrics. For instance, the Line Height or Ascender or Descender position could all be completely different.
     
    Last edited: Nov 24, 2017
  30. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    Unless you did not upgrade to the release of TMP for 2017.2, you should not be getting any errors on the shaders. What version of TextMesh Pro are you using? You can identify the version by looking at the full name of the DLL's contained in the TextMesh Pro/Plugins folder.
     
  31. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    By using Dilation in conjunction with Outline, you can control where the outline appears. For instance, if you add Outline of 0.25 and Dilation of 0.25, the Outline will be outside.
     
  32. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    The RectMask 2D now uses a Shader Keyword in 2017.2 which could be impacting this. Can you please submit a bug report and be sure to include some Repro project?
     
  33. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    The Truncate option will truncate words that do not fit and thus wrap. I am not sure I understand the issue you are reporting. Can you provide more details on what you expect the behavior to be?
     
  34. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    First, the outline width / thickness is a material property so this text.outlineWidth property is provided for convenience. Instead of using this property, you could access the material directly to set the outline or any other material properties. There are utility functions include with TMP to do this. Refer to posts like this on the TMP user forum.

    Next, by convention in Unity whenever we access the material property vs the sharedMaterial property, we get an instance of the material. So when using this text.outlineWidth, internally it creates an instance of the material.

    In terms of the behavior, it would appear that you end up using some fallback which automatically tries to match the material preset used by the Primary font asset assigned to the text object. However in your case, you end up with an instance of that material which is likely resulting in the wrong material being used. I would need a Repro project take a closer look to see if I could improve / make this behavior more intuitive.

    Having said that, instead of changing the outline by code (assuming this value for width is not random), I would recommend creating material presets offline with the material properties / outline values that you want and then via code assigning these pre-created material presets via scripting at runtime. So instead of ending up with several material instances, you would end up with some text objects using / sharing a material preset that has an outline while others continue to use the default material of the primary font asset.
     
    AdamSingle likes this.
  35. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    TextMesh Pro already includes a few API functions to check if a font asset contains certain characters. See the following post or release notes. Let me know if you can achieve the results you seek with that.

    Longer term, the new Text System / integrated / re-write of TextMesh Pro will include support for dynamic fallback / fonts assets which will be different than the current system but will have the ability to add new glyphs and characters into font assets and font atlas textures in the editor and runtime.

    In the new system, you will be able to have font assets that are partially filled with glyphs and characters but still marked as dynamic where new glyphs and characters can still be added in the editor or runtime. In the editor those changes will be persistent (if enabled) whereas at runtime, they will not.

    The idea / goal is to allow developers to continue to be able to create font assets that contain all the glyphs and characters their project contains in the editor / offline which is best from a performance and quality assurance point of view while still making it possible to dynamically add whatever potential and few glyphs and characters might be missing at runtime.
     
    Last edited: Nov 24, 2017
    ilmario likes this.
  36. pep_dj

    pep_dj

    Joined:
    Nov 7, 2014
    Posts:
    156
    Thanks for your answer. I'm using Glyph app to combine different fonts into one, and it's working well. Maybe line height, ascender or descender are different, but it works as I need.

    Why I'm doing it? Because my game is localized to multiple languages (English, Russian, Chinese...) and I want to have all characters I need in only one file. I know I could use the fallback system for it, but I want to avoid having more draw calls.
     
  37. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    Since each font can have very different metrics, it will always be best to keep them as separate font assets especially once support for OpenType Font Features is added. Although combining glyphs from multiple font assets into a single font atlas texture could be possible it don't think it is really practical especially that it might only result in saving a few draw calls (in most case 1 to maybe 3 draw calls).

    To support all Latin languages, you only really need 2 fonts assets and perhaps just one if you go to 2048 X 2048 and given these batch together, we are only talking about 2 draw calls.

    With regards to Chinese, Japanese and Korea, you might end up with 4 font assets for each which includes the primary and fallbacks but again, we are talking about 3 to 4 draw calls where the performance difference would be hard to measure.

    The package size is where having multiple atlas matters but you can get around this with Asset Bundles.

    Keep in mind that even if we could add all these glyphs and characters into a single texture, the size of textures is mostly limited to 2048 X 2048 (for mobile) and as such you cannot fit all Latin + Cyrillic + Chinese or Japanese or Korean into a single font atlas texture anyway.
     
  38. pep_dj

    pep_dj

    Joined:
    Nov 7, 2014
    Posts:
    156
    In a scene I have 4 different text objects inside other objects, resulting in 4 draw calls. If I use the fallback system, they will turn into 4x4=16 draw calls...

    You are right: I can't save all Latin + Chinese + Japanese + Cyrillic characters in one font, so I created a unity script that tells me what characters I used in my strings, for each language. And then, I created another script for Glyphs app that only copies those characters I'm using in my game.
     
  39. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    Are those 4 text objects overlapping? With the normal mesh renderer, provided you are using the same font asset and material preset, those 4 text objects should batch into 1 draw call.

    With the Canvas system, it is more complicated but unless something changed and unless they overlap, these 4 text objects should still batch. So even with fallback, we should only be looking at 4 drawcalls and not 16. (Edit: With nested objects and the canvas sorting handling, I guess it is possible those might not batch.)

    In terms of font asset preparation, most projects don't actually contain that many characters (outside of user input) so provided you select a font file which includes support for the different languages you need, you should be able to (using a script or some other tool) get a list of all the characters used in your project and to generate a single or perhaps two fonts assets that will support all those languages.

    P.S. I am most certainly open / willing to explore ways to improve workflow and flexibility while making sure we don't negatively impact quality and performance. The more information / examples and use case scenarios presented the more data I have to consider / think about ways to accommodate all these things. In the end, I am not designing this for me but for Unity users like you.
     
    Last edited: Nov 25, 2017
  40. pep_dj

    pep_dj

    Joined:
    Nov 7, 2014
    Posts:
    156
    I have 4 different objects, each one with its own canvas, that's because draw calls does not batch.
     
  41. ilmario

    ilmario

    Joined:
    Feb 16, 2015
    Posts:
    69
    That should do it, thanks!
     
    Stephan_B likes this.
  42. Wanderer13

    Wanderer13

    Joined:
    Feb 11, 2016
    Posts:
    14
    Thanks for answer. At screenshot You can see that word "word" truncated to letters "wo". I need to words, that can't be shown in full length to not show completely. So "wo" should not be displayed at all.
     
  43. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    Truncate by design cuts off the characters / lines that do not fit. It is similar to Ellipsis which instead adds the Ellipsis at the end.

    upload_2017-11-26_23-29-46.png

    When I have time, I can look at adding a mode where instead of truncating characters, it would truncate words which I believe is the behavior you seek.
     
  44. Wanderer13

    Wanderer13

    Joined:
    Feb 11, 2016
    Posts:
    14
    It would be perfect, thanks.
     
  45. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    Actually, try using the Overflow Linked mode but just don't assign another text object to the link. I believe this will give you the behavior you seek.
     
  46. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    Added a new rich text tag <gradient> </gradient> which makes it possible to assign a Color Gradient Preset on the text enclosed between those two tags.

    The format for the tag is as follow: <gradient="Name of Color Gradient Preset">Some text</gradient>

    Since these Color Gradient Presets will need to be loaded at runtime and similar to other TMP assets, these have to be located within a Resources folder. The specific location within Resources folders can be defined in the TMP Settings file.

    Here is an example using this new tag.



    Please note <gradient> tags can also be nested like many other tags in TMP.

    This new feature will be in the next release of TMP which should be available later tonight. You will find direct links to download these new releases in the top sticky post in the Unity UI & TextMesh Pro section of the user forum. These releases will also be available thru the asset store within the next few days. As usual be sure to read the Release and Upgrade notes and to always back up your project before upgrading to new releases.
     
  47. nyonge

    nyonge

    Joined:
    Jul 11, 2013
    Posts:
    31
    @Stephan_B hi! Is there a way to modify font asset face/outline settings - specifically, Dilation - through code? Sorry if it's already answered, I couldn't find it in the 44 pages of this thread. Thank you!
     
  48. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,972
    There are a few examples of this on the TextMesh Pro user forum. Here is one such post.
     
  49. PerunCreative

    PerunCreative

    Joined:
    Nov 2, 2015
    Posts:
    93
    Hi, can I ask is it possible to use UTF-8 coding and it is compatible with chinese? because we are really happy with this asset but community want chinese
     
  50. tosiabunio

    tosiabunio

    Joined:
    Jun 29, 2010
    Posts:
    112
    Yes, you can make easily the Chinese localization with TMP.
     
Thread Status:
Not open for further replies.
unityunity