Search Unity

TextMesh Pro - Advanced Text Rendering for Unity - Beta now available in Asset Store

Discussion in 'Works In Progress - Archive' started by Stephan-B, Feb 11, 2014.

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

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    One of the major new features that I am working on for the new text system (aka integrated version of TMP) is support for OpenType font features. As I have stated before, I don't have an ETA yet on this new system but I am working on it.
     
    flyingbanana likes this.
  2. dreamhst7

    dreamhst7

    Joined:
    Mar 27, 2014
    Posts:
    13
    Hello Stephan! Thanks for your TextMeshPro! Can you help me? I want to generate font asset from thai font, i tried Courier Monotype, Angsana, DB ThaiText but it's not working. No one symbol generated. Can you tell me which font i'll can use and what settings i'll must to set? May be you have some thai font for this purpose?
     
  3. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    According to the Unicode Chart, Thai characters should be located in the 0E00 - 0E7F range.

    When I take a look at the Angsana or DB Thai font, it appears the Thai characters have been moved and are not in the proper Unicode range for the Thai language.

    I would suggest getting some font tool like Font Creator (you can use the demo) which will allow you to see the characters contained in a font and where they are located.

    With one of those font tools, you'll be able to see exactly where the characters are located and then define their range in the TMP Font Asset Creator.
     
  4. dreamhst7

    dreamhst7

    Joined:
    Mar 27, 2014
    Posts:
    13
    Thanks a lot!
     
    Stephan_B likes this.
  5. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    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.
     
  6. Milo_del_mal

    Milo_del_mal

    Joined:
    Jan 27, 2013
    Posts:
    43
    Hi, I recently joined the TextMeshPro furor, and I LOVE it.
    I was wondering if is there a built in way to "Arc up" text in TextMesh Pro?
     
  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Take a look at Example 23 included with TextMesh Pro which includes a few scripts that modify vertex attributes like in this case color and position.

    Then take a look at the WarpTextExample.cs script which you can add to any TMP text object and similar to the other scripts, this will bend the text.
     
    Milo_del_mal likes this.
  8. Milo_del_mal

    Milo_del_mal

    Joined:
    Jan 27, 2013
    Posts:
    43
    Thank you, today I was already toying with it!
     
  9. Jayme65

    Jayme65

    Joined:
    Dec 11, 2016
    Posts:
    94
    What would please be the quickest and most effective way to transform a TMP text block to RawTexure/Texture2D?

    Why? I've a long list displaying logo images and when no image is available I have to provide a descriptive text (transformed to image since that list only works with images)

    So far, I've worked with a specific camera, shooting to a render texture! Is there any better way? Is there a TMP native method?

    Thanks!!
     
  10. Eruheran4

    Eruheran4

    Joined:
    Jan 6, 2013
    Posts:
    19
    Is it possible to use TMPro in Custom Editor OnGUI? I want to write a text on a curved path, but haven't found anything yet.
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    It should work in the sense of changing object properties. However, just be mindful that OnGUI() can get called multiple times per frame.
     
  12. Eruheran4

    Eruheran4

    Joined:
    Jan 6, 2013
    Posts:
    19
    Yea guess I wont use it for an OnGUI()-Situation. Although I haven't found any solution to put a 3D Text on a Bezier curve. Can you help me where to find? Thanks!
     
  13. rockyip

    rockyip

    Joined:
    Jul 23, 2012
    Posts:
    10
    Hi, I created a set of font assets around 8Mb in total, which is used on TextField in both scenes and prefabs.
    I meet a problem when I try to grab some prefabs as Asset Bundles, the font assets will also included in each bundles.
    Therefore in runtime, there are many duplicate font assets created from scenes and those bundles.

    Is there any method to prevent such duplication?
     
  14. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    That's an Asset Bundle thing in terms of how it determines and includes dependencies. I think with the Asset Bundle Browser you might be able to split those bundles to avoid duplication but I am not totally certain as I have not worked much with bundles.

    I am certain several people using AssetBundles have run into this so I would check / search the forum or post maybe in scripting about how to avoid resource duplication between bundles that use / share the same base resources.
     
  15. rockyip

    rockyip

    Joined:
    Jul 23, 2012
    Posts:
    10
    Um, finally I have created a script to extract the name of font asset and material from TextMeshProGUI Component and make all text use the default font asset. After that the asset Bundle do not contains the custom font.
    Although it's still duplicated the default font, but the size of the bundle is obviously reduced a lot.
    Then after downloaded, I load the original font asset and materials from Resources. It works as expected.

    Code (csharp):
    1.  
    2. [RequireComponent(typeof(TMP_Text))]
    3. public class TextMeshProFontReference : MonoBehaviour
    4. {
    5.     [SerializeField]
    6.     private TMP_Text text;
    7.     [SerializeField]
    8.     private string fontName;
    9.     [SerializeField]
    10.     private string materialName;
    11.  
    12.     public void Start()
    13.     {
    14.         text = GetComponent<TMP_Text>();
    15.         if (Application.isPlaying == true)
    16.         {
    17.             Apply();
    18.         }
    19.     }
    20.  
    21.     public void Apply()
    22.     {
    23.         if (text != null)
    24.         {
    25.             TMP_FontAsset fontAsset = null;
    26.             int fontAssetHashCode = TMP_TextUtilities.GetSimpleHashCode(fontName);
    27.             if (MaterialReferenceManager.TryGetFontAsset(fontAssetHashCode, out fontAsset) == false)
    28.             {
    29.                 fontAsset = Resources.Load<TMP_FontAsset>(TMP_Settings.defaultFontAssetPath + fontName);
    30.                 if (fontAsset != null)
    31.                 {
    32.                     MaterialReferenceManager.AddFontAsset(fontAsset);
    33.                 }
    34.             }
    35.  
    36.             if (fontAsset != null)
    37.             {
    38.                 text.font = fontAsset;
    39.  
    40.                 Material fontSharedMaterial = null;
    41.                 int fontMaterialHashCode = TMP_TextUtilities.GetSimpleHashCode(materialName);
    42.                 if (MaterialReferenceManager.TryGetMaterial(fontMaterialHashCode, out fontSharedMaterial) == false)
    43.                 {
    44.                     fontSharedMaterial = Resources.Load<Material>(TMP_Settings.defaultFontAssetPath + materialName);
    45.                     if (fontSharedMaterial != null)
    46.                     {
    47.                         MaterialReferenceManager.AddFontMaterial(fontMaterialHashCode, fontSharedMaterial);
    48.                     }
    49.                 }
    50.                 if (fontSharedMaterial != null)
    51.                 {
    52.                     text.fontSharedMaterial = fontSharedMaterial;
    53.                 }
    54.  
    55.             }
    56.         }
    57.     }
    58. }
    59.  
    Code (csharp):
    1.  
    2. using UnityEditor;
    3. using UnityEngine;
    4. using TMPro;
    5. using TMPro.EditorUtilities;
    6.  
    7. [CustomEditor(typeof(TextMeshProFontReference), true)]
    8. [CanEditMultipleObjects]
    9. public class TextMeshProFontReferenceInspector : Editor {
    10.     SerializedProperty fontName;
    11.     SerializedProperty materialName;
    12.  
    13.     void OnEnable()
    14.     {
    15.         fontName = serializedObject.FindProperty("fontName");
    16.         materialName = serializedObject.FindProperty("materialName");
    17.     }
    18.     public override void OnInspectorGUI()
    19.     {
    20.         base.OnInspectorGUI();
    21.         serializedObject.Update();
    22.  
    23.         TextMeshProFontReference fontRef = (target as TextMeshProFontReference);
    24.  
    25.         if (Application.isPlaying == false)
    26.         {
    27.             EditorGUILayout.BeginHorizontal();
    28.             if (GUILayout.Button("Extract"))
    29.             {
    30.                 TMP_Text t = fontRef.GetComponent<TMP_Text>();
    31.                 fontName.stringValue = t.font.name;
    32.                 materialName.stringValue = t.fontSharedMaterial.name;
    33.                 t.font = null;
    34.                 serializedObject.ApplyModifiedProperties();
    35.             }
    36.             if (GUILayout.Button("Paste"))
    37.             {
    38.                 fontRef.Apply();
    39.             }
    40.             if (GUILayout.Button("Apply"))
    41.             {
    42.                 GameObject go = PrefabUtility.FindRootGameObjectWithSameParentPrefab(fontRef.gameObject);
    43.                 Object root = PrefabUtility.GetPrefabParent(go);
    44.                 PrefabUtility.ReplacePrefab(go, root, ReplacePrefabOptions.ConnectToPrefab);
    45.             }
    46.             EditorGUILayout.EndHorizontal();
    47.         }
    48.  
    49.     }
    50. }
    51.  
    52.  
     
    Stephan_B likes this.
  16. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    Hi, how can we access via script outline, bevel, lightning etc. of TextMeshPro?
     
  17. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    298
    Here's how I'm doing it

    Code (CSharp):
    1.             case (PulseStyle.Glow):
    2.                 currentGlow = Mathf.SmoothStep(startingGlow, endingGlow, Mathf.PingPong(Time.time / glowTime, 1));
    3.                 textMaterial.SetFloat(/*"_GlowPower"*/ "_GlowInner", currentGlow);
    4.                 break;
     
    RoyalCoder likes this.
  18. RoyalCoder

    RoyalCoder

    Joined:
    Oct 4, 2013
    Posts:
    301
    Hi @ModularBuilds ,

    Thanks for your suggestion, I will give'it a try ;)

    P.S: Do you guys get artifacts of TMPro UGUI text, like in my attached screenshot?
    screenTMP.png
     
  19. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This is due to the ratio of Sampling point size to padding being too small for the material property values you are using on things like Dilation, Outline, Underlay, etc.

    See FAQ Question #2 and #11.
     
  20. TeohRIK

    TeohRIK

    Joined:
    Jan 22, 2014
    Posts:
    106
    Hi, I realize I having some artifacts for the text issue when I enable the screen space reflection in post processing v2.

    The circle in the picture I attached is the artifacts caused by screen space reflection
     

    Attached Files:

  21. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I would suggest submitting a bug report about an issue with "Screen Space Reflection" which I presume should ignore the text objects.
     
  22. Sovcenko

    Sovcenko

    Joined:
    Apr 17, 2018
    Posts:
    6
    Hi everybody !
    I'm trying to add a dissolve map on a TextMesh Pro asset :


    I searched a bit around, but didn't found a way to get this effect with TextMesh Pro.
    Do you have an idea ?
    Thanks. :)
     
  23. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Take a look at example 19 included with TextMesh Pro. It uses a modified shader that uses a texture with alpha to define the fading. There is also a slider that allow to control the fading based on the shape of the alpha of the texture. It also provides for the ability to assign a color at the edge.

    This is similar to what you have and might need tweaks but it should be enough to get you on the right direction.
     
  24. MarSolo

    MarSolo

    Joined:
    May 17, 2014
    Posts:
    2
    Hey Stephen, I really enjoy this TextMesh Pro. I'm just having one problem that I'm sure you already answered in here (so apologies if it's already been answered) but I'm getting a "`TMPro.TextMeshProUGUI' does not contain a definition for `hasChanged' and no extension method `hasChanged' of type `TMPro.TextMeshProUGUI' could be found." when I'm trying to do the Scrolling Text Manager:

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using TMPro;
    4.  
    5. public class ScrollingTextManager : MonoBehaviour {
    6.  
    7.     public TextMeshProUGUI TextMeshProComponent;
    8.     public float scrollSpeed = 10;
    9.  
    10.     private TextMeshProUGUI m_cloneTextObject;
    11.  
    12.     private RectTransform m_textRectTransform;
    13.     private string sourceText;
    14.     private string tempText;
    15.  
    16.     void Awake(){
    17.         m_textRectTransform = TextMeshProComponent.GetComponent<RectTransform>();
    18.  
    19.         m_cloneTextObject = Instantiate(TextMeshProComponent) as TextMeshProUGUI;
    20.         RectTransform cloneRectTransform = m_cloneTextObject.GetComponent<RectTransform>();
    21.         cloneRectTransform.SetParent(m_textRectTransform);
    22.         cloneRectTransform.anchorMin = new Vector2(1, 0.5f);
    23.         cloneRectTransform.localScale = new Vector3(1,1,1);
    24.     }
    25.  
    26.     // Use this for initialization
    27.     IEnumerator Start () {
    28.         float width = TextMeshProComponent.preferredWidth;
    29.         Vector3 startPosition = m_textRectTransform.position;
    30.  
    31.         float scrollPosition = 0;
    32.  
    33.         while (true){
    34.             // Re-Compute the width of the RectTransform if the text object has changed
    35.             if (TextMeshProComponent.hasChanged){
    36.                 width = TextMeshProComponent.preferredWidth;
    37.                 m_cloneTextObject.text = TextMeshProComponent.text;
    38.             }
    39.  
    40.             // Scroll the text across the screen by moving the RectTransform
    41.             m_textRectTransform.position = new Vector3(-scrollPosition % width, startPosition.y, startPosition.z);
    42.  
    43.             scrollPosition += scrollSpeed * 20 * Time.deltaTime;
    44.  
    45.             yield return null;
    46.         }
    47.     }
    48. }
    49.  
    Thanks!
     
  25. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This hasChanged property was removed a while ago. This has been replaced by ON_TEXT_CHANGED. Take a look at the example script VertexJitter.cs included in the Examples & Extras/Scripts folder.
     
    MarSolo likes this.
  26. MarSolo

    MarSolo

    Joined:
    May 17, 2014
    Posts:
    2
    Woo! Thanks for the hint! Back to work I go.
     
  27. ArnoldRauers_Tinytouchtales

    ArnoldRauers_Tinytouchtales

    Joined:
    Jan 25, 2015
    Posts:
    33
    Hi,
    i’m using the free version of TMP and i’m trying to integrate
    a Thai font that can display all the vowels correctly. So far i have not found
    a font that actually works. Do you have any suggestions here?

    You can see that someone showed a working font here:
    https://forum.unity.com/threads/tex...ble-in-asset-store.227790/page-4#post-1624714
    But this font is pretty bad in general.

    I found out that someone actually developed a fix for the Thai vowels but you
    can only use it when you have access to the source which i don’t have as a free user.
    Maybe this could be integrated on your side as well?
    https://gist.github.com/allfake/d4fde9c573eaa4d5461a07ad446faf18
     
  28. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,188
    In 2018.2 you can access the source when you install through the package manager. Once installed, it will shows "Packages" under your asset folders. If you go to the location, it should be a common location. Copy the textmeshpro folder into your projects "Packages" folder. You will then create a project based copy of tmp. Remove the @1.2.4 from the tmp folder name so it only says com.unity.textmeshpro.

    You will also need to remove the read only part on the textmeshpro folder so that you can modify the scripts.

    Reopen your project in Unity and when you go back to the packages folder, it will now point to the project based tmp and you can modify the scripts.
     
    Stephan_B likes this.
  29. ArnoldRauers_Tinytouchtales

    ArnoldRauers_Tinytouchtales

    Joined:
    Jan 25, 2015
    Posts:
    33

    Ok,

    I've seen that @Stephan_B liked your post. I'm assuming this is the only way to get this to work right now, which is frankly kind of awkward. I'll have to see if my project will be able to upgrade to the latest Unity version. Still you should consider to fix the Thai font vowel in general.
     
  30. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    I will most certainly take a look and consider this proposed implementation.
     
  31. ArnoldRauers_Tinytouchtales

    ArnoldRauers_Tinytouchtales

    Joined:
    Jan 25, 2015
    Posts:
    33
    Quick update:
    I just used the Unity 2018.2 trick added the fix from my link and the issue is still the same.
    So this seems to be another issue:

    Text should look like this: จี้ - two vowels stacked on top of each other,
    this is how it looks in game:



    The only font that works out of the box is this one:
    https://drive.google.com/file/d/1tSmcAVd7sJLP4A3VkjroVh2bRWZwd1-q/view?usp=sharing

    But idk what it does differently, from all the other fonts.

     
    Last edited: Jul 20, 2018
    yty likes this.
  32. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This characters rely on diacritical marks / glyph positioning which is an OpenType Font Feature. Until support for OpenType Font Features is added, you can try to define a Glyph Adjustment Pair for the first and second diacritical mark and adjusting the position of the second relative to the first.

    You can access the Glyph Adjustment Table via the Font Asset inspector.
     
  33. ArnoldRauers_Tinytouchtales

    ArnoldRauers_Tinytouchtales

    Joined:
    Jan 25, 2015
    Posts:
    33
    Ok cool, i give that a try, thanks.
     
  34. Eco-Editor

    Eco-Editor

    Joined:
    Jun 29, 2016
    Posts:
    71
    Hello @Stephan_B and everybody,

    Stephan, I wonder if I can use TMP for curved text.
    I saw in this thread in 2011 you wrote something about the text going around the y axis (around a sphere) but the example is not clear (the picture was erased or no longer available).

    In the scene I need the text to surround the viewer 360 degrees. I started to use curvy asset, but as great it is it gives me some trouble... and I need a solution.

    Is it possible to use TPM to create a 360 curve with text? if yes, please give me any hint. Thanks!
    Please don't suggest Curved UI to me, as this asset does not support 360 for VR (only 180).
     
  35. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    You can use MegaFiers, I use it to deform my text in all sorts of different ways.
     
  36. Eco-Editor

    Eco-Editor

    Joined:
    Jun 29, 2016
    Posts:
    71
    Hi @MikeUpchat it will cost me 150 dollars.... its out of my budget...
    Hey do you have it? and can sent me for free??
     
  37. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Don't ask for pirate software if you don't want time off the forums.
     
    AlejMC, hopeful and BTStone like this.
  38. samlabs_lea

    samlabs_lea

    Joined:
    May 1, 2018
    Posts:
    7
    I have two questions:

    How do you get Arabic characters to properly connect cursively?

    Why is the atlas memory size 16MB at 4096x4096 if only one color channel is being used? Could this not take as little as 4MB for one channel?

    Many thanks
     
Thread Status:
Not open for further replies.