*** Preview 3 Release of Version 2.2.0 and 3.2.0 Now Available! ***

The following releases of the TMP package are now available via the Package Manager. These are version 2.2.0-preview.3 for Unity 2019.4 and version 3.2.0-pre.3 for Unity 2020.x or newer.

These two (2) releases are identical in terms of features and functionality but specific to each Unity releases which is required to address some API and other changes to Unity.

Release Notes for Preview 3
******************

  • Fixed a potential IndexOutOfRangeException when trying to select any portions of text in an Input Field whose child text component is using Overflow mode Truncate or Ellipsis where due to RectTransform width and / or height restrictions have results in the text being fully truncated. Case #1361032
  • Fixed incorrect character sequencing in the Input Field when using Japanese IME in UWP builds. Case #1374755
  • Fixed several potential IndexOutOfRangeException in the Input Field when text is fully truncated when using Text Overflow mode Ellipsis or Truncate.
  • Fixed Input Field incorrect caretPosition and / or stringPosition properties when updating these via scripting. Case #1334622
  • Fixed incorrect event handling on UWP and Hololens 2. Case #1357718 and Case #1351006
  • Fixed Input Field OnSelect event potentially firing twice on some mobile devices including Microsoft Surfaces.
  • Fixed Input Field incorrect caret insertion position when text contains a Carriage Return at the end of a line. Case #1362068
  • Added support for markup tag.
  • Added value range check for the text component margins located in the text component extra settings. Case #1365554
  • Added new overload to the TMP_FontAsset.CreateFontAsset() to enable creating font asset instances using a file path.
  • Added new TMP_ResourceManager.RemoveFontAsset() function to remove a font asset from the TMP Resource Manager. This new function would typically be used prior to unloading bundles and / or resources.
  • Warnings about potentially missing character 0x5F used to display underline or strikethrough will only be displayed when using those features when Display Warning is enabled in the TMP Settings.
  • Fixed incorrect handling of ‘-’ at the end of a line when using Text Overflow Page mode. Case #1382173
  • Fixed incorrect line breaking when a hyphen ‘-’ is preceded by a space. Case #1391990
  • When using Text Wrapping Mode - Preserve White Space or Preserve White Space No Wrap, the character will now contribute to the preferred height when it is the first and only character on a new line.
  • Added ClearFontAssetGlyphCache() function to the TMP_ResourcesManager to enable clearing the font asset fallback glyph cache.
  • Added new markup tag.
  • Added ability to define a list of fallback text assets in the TMP Settings to be used for Emojis.
  • Added new property “emojiFallbackSupport” to text components which is also exposed in the extra settings section of the text component inspector. When enabled, this will prioritize searching the Emoji Fallback Text Assets before the primary font asset for characters defined as Emoji in Unicode 14.0. See forum post for details.
  • Fixed duplicated character when using custom validator in conjunction with soft keyboard. Case #1387772
  • The markup tag will now also affect inline markup tags like
    , , etc.
  • Fixed newly created StyleSheets having two Normal styles.
  • Added new Double Pass SDF shader and example scene to the TMP Examples & Extras to showcase this new shader.
  • Added new context menu option to manually “clear dynamic data” of a dynamic font asset. This performs the same clearing of data as the “Clear Dynamic Data on Build” option when manually triggered.
  • Added new markup tag which can be used as follows: “See this link for details.”. This new markup tag is similar to the tag but does not use an ID.
  • Added new “A” style to the Default Style Sheet referenced in the TMP Settings. This “A” style defines the styling of the new markup tag.
  • The TMP_Text.parseCtrlCharacters property which controls the interpretation and parsing of escape characters in the text component’s Text Input box in the inspector, will now apply to all methods of setting the text on the component. Case #1400008
  • Fixed potential Null Reference Exception when editing the name of a sprite character. Case #1396591
  • Fixed issue where TMP_FontAsset.HasCharacters would return false when called prior to font asset initialization. Case #1394817
  • Minor TMP_InputField UI improvement where “Hide Mobile Input” property will be disabled when “Hide Soft Keyboard” property is disabled. Case #1388243

See ChangeLog in Package Manager for changes contained in previous releases.

Changes Worth Noting


  • TrueType Collection (TTC) support.

  • Support for new OpenType Font Features such as Ligatures and Diacritical Marks.

7953013--1018441--upload_2022-3-9_15-3-37.png

  • Dynamic OS Font Assets

  • Text Wrapping Mode

  • Double Pass Shader

This latest release actually contains most of the changes to support native emoji and additional font features but these will require a new version of the Unity Editor as some of this functionality is contained in the TextCore FontEngine which is implemented on the native side which I am still working on. Although my release estimates have been horrible lately, I am hoping to have these changes to the FontEngine available within the next 45 - 60 days.

Here is an example of color glyph / native emoji support which includes Emoji modifier support as well as those are OpenType font features.

Please post any potential issues you uncover with these latest release in this thread.

7 Likes

Yay, thanks for getting it out the door! I look forward to updating and integrating this into our project and finalizing our text/font features for our game. Some questions:

What specific features need a new TextCore (new Unity version)? Could you mark them in the changelog or in the post above? Also when you know which version, the version they’ll be in?

Do you have ligatures exposed on a per label or runtime accessible settings so can use to enable/disable ligatures in our GameOptions? Some of our ligatures can be a little “extreme” and we want to provide our users with that option.

Is this the targeted feature set for 3.2 final or are you planning on squeezing in a few others?

This may be a problem custom to my project or I might need to wait on a Unity upgrade, but we’re still not seeing either the ligatures or glyph pair kerning implemented (one of the big reasons we’re trying to upgrade). I tried creating the font from the .ttf and .otf version of the font and they’re still not being included? Neither the ligatures or the glyph adjustment pairs are being exported. Let me know if you want me to DM you one of our fonts so you can see if this is an authoring problem.

7955326--1019185--upload_2022-3-10_12-38-32.png
7955326--1019182--upload_2022-3-10_12-37-43.png

With the upcoming editor update for emoji support will there be an update to the TMP Input field to have an option to block emoji input? We currently only support emojis in chat and don’t want players to be able to enter them in their names. This would be helpful option.

1 Like

The main ones are the automatic extraction of OpenType features from the font files and the ability to raster color glyphs into RGBA atlas texture.

I am planning on replacing the “Kerning” option in the Extra Settings of text components by a list of features that users can enable / disable per text component. For instance, you would see the “liga” and “dlig” feature where you may choose to have default “liga” enabled but have discretionary ligatures “dlig” disabled.

I am planning on adding full support for OpenType features in this preview cycle while keeping these releases stable where what is considered beta / preview are those new features while the core existing functionality remains stable where it actually contains bug fixes to issues reported in 3.0.6 and previous preview releases.

The ability to extract those font features from the font file is the functionality that is part of the TextCore FontEngine which will require a Unity upgrade.

Until then you will have to manually populate those tables in the font asset, if you want need any of those features. You will also need to make sure the data is also relative to the sampling point size. For example, in the case of positional adjustments, the values in the font file are specified at the font’s Unit per EM scale so if your sampling point size is 100 then you have to adjust / scale your values to be 1/10 of those in the font file.

1 Like

In the TMP Settings, a new table was added which is the “Fallback Emoji Text Assets” which defines which assets are to be searched for characters that are defined in the Unicode as Emojis. If no asset is defined there then the text system will search thru font assets and fallbacks as it been doing previously. Ie. no change here.

7955458--1019206--upload_2022-3-10_14-28-18.png

A new option was also added in the text component Extra Settings where you can disable Emoji Fallback Support.

This is great! Thanks Stephan!

Just to clarify, with this preview release on its own, can I get Arabic fonts working in Unity out-of-the-box, or is this dependent on the completion of the changes in the TextCore FontEngine you spoke about above?

Also, will these changes allow Arabic fonts/text to render correctly within the Unity editor interface (and editor plugin UI), or is this only relevant to in-game UI elements that use TextMeshPro?

Are there any more plans for ‘native integration’, for lack of a better term? It seems that newer Unity versions moved Text to the Legacy menu. I teach Unity and every single new user is completely confused what this TextMeshPro in the menu is supposed to be and how UI works now.

I’ve noticed that they just want to add text or a button, so basically something that should be extremely simple and quick. But then they get a popup asking them to import TMP essentials. Some close the window, because they don’t want to break anything. Or they want to import a font and have no idea why they can’t just add it to the component, and are confused when I tell them to open this kind of hidden menu to create font assets. And then they want to script with it and I have to explain that UI.Text isn’t actually what they want, but they need this TextMeshProUGUI thing and import TMPro instead of the UI package, which you would never know without googling explicitily for TextMeshPro.

With the de facto ‘removal’ of the old Text component, I feel like you really need to streamline the entire Text functionality. People shouldn’t have to import these essentials manually if TMP is to be used as the default text. Adding and changing text through code should just work out of the box without much explanation.

Hi, not sure if this is the best place to post my problem, but I can’t get access the download for the pre release TMP in package manager no matter what I try.

I am on Unity 2021.2.1 & am not shown any preview packages for TMP.

Is there a specific git URL I can use for version 3.2?

Thanks,

EDIT:

Ok found a solution. If anyone else is having this issue enter this into the “add package by name” option:

com.unity.textmeshpro
3.2.0-pre.3

6 Likes

This is great! Does Dynamic OS Font Assets work on WebGL? I have not been able to get it to work.

EDIT: I noticed that you can load a font binary into FontEngine.LoadFontFace, however I don’t know how to get the Font from there into a TMP_FontAsset. I could not find any documentation on how it works.

Does anybody know how to do this?

Alternatively, could the font asset keep a reference to byte[ ] and just use that?

This would allow us to load font files from streamingAssets at runtime.

EDIT 2: Did a few changes myself and got it working, now i just need to see if this is stable.

If you want to do this yourself, google how to modify a package, and here is the code i modified.

        // CUSTOM : Added data field and function for data
        byte[] data;
        public static TMP_FontAsset CreateFontAsset(byte[] data)
        {
            return CreateFontAssetInstance(null, 9, GlyphRenderMode.SDFAA, 1024, 1024, AtlasPopulationMode.Dynamic, true, data);
        }

        // CUSTOM : Modified CreateFontAssetInstance to add data parameter
        static TMP_FontAsset CreateFontAssetInstance(Font font, int atlasPadding, GlyphRenderMode renderMode, int atlasWidth, int atlasHeight, AtlasPopulationMode atlasPopulationMode, bool enableMultiAtlasSupport, byte[] data = null)
        {
           // CUSTOM : If data, load it
           if (data != null) {
                var result = FontEngine.LoadFontFace(data, 90);
                if (result != FontEngineError.Success) throw new($"Failed to load font. {result}");
            }

            // Create new font asset
            TMP_FontAsset fontAsset = CreateInstance<TMP_FontAsset>();
         
           // CUSTOM : Assign data
            fontAsset.data = data;

/// Find the LoadFontFace function, and modify it with
        FontEngineError LoadFontFace()
        {
            if (m_AtlasPopulationMode == AtlasPopulationMode.Dynamic)
            {
                // Font Asset should have a valid reference to a font in the Editor.
                #if UNITY_EDITOR
                if (m_SourceFontFile == null)
                    m_SourceFontFile = SourceFont_EditorRef;
                #endif

                // CUSTOM : If data, load it
                if (data != null) return FontEngine.LoadFontFace(data, m_FaceInfo.pointSize, m_FaceInfo.faceIndex);

EDIT 3: Usage example.

public class Test : MonoBehaviour {
    public TMP_Text tmp;

    IEnumerator Start() {
        using var request = UnityWebRequest.Get($"{Application.streamingAssetsPath}/fonts/NotoSansSC-Regular.otf");
        yield return request.SendWebRequest();
        if (request.result != UnityWebRequest.Result.Success) throw new("Failed to get font file.");

        TMP_Settings.fallbackFontAssets.Add(TMP_FontAsset.CreateFontAsset(request.downloadHandler.data));

        tmp.text = "Hello 你弽 World";
    }
}

Is there a fix for TMPro in World Space/VR? (or can yall add something in a new update)? Posting a picture below of how it looks in VR - Basically like perspective view. (It is from another post that was “resovled” and not exactly related to my issue). When I disable “Additional Shader Channels” - (select nothing) it renders fine, but then automatically enables itself. Would it be possible to create an override when using worldspace canvas? 2nd Image shows my setup that “works” - but after a little bit, Text Mesh Pro reenabled the other shader channels and it needs to be disabled again during runtime.
8007959--1030256--upload_2022-3-30_21-58-54.png

Would these TextCore OpenType features by chance going to be backported to the 2021 LTS (our targeted release version) or has that ship sailed and will require 2022.x?

The plan is to have these changes and functionality available in Unity 2020.3 and up.

2 Likes

Hi Stephan, thank you for the great work.
I would like to report an issue with the Text Wrapping Mode.

The spacing seems not be correctly preserved once a word is pushed into a new line by leading spaces.
How to replicate:

  1. Create new Text - TextMeshPro object
  2. Set Text Wrapping Mode to “Preserve White spaces”
  3. (optional) Stretch Rect Transform to fill the entire screen and have better visual clue of line ending.
  4. In the editor set Text Input to “Sample Text”.
  5. Start adding leading spaces until “Text” word is pushed to new line.
  6. ISSUE: Any additional leading space added at this time will cause “Sample” to advance forward, but “Text” will not move. After a certain amount of spaces (possibly depending on the word length and font used) “Sample” is pushed in the new line too. Again, multiple additional spaces will be required to make the words move forwards.

– EDIT –

One note on my previous post, just discovered that other text editors behave in similar manner (notably Office Word and Notepad++).
If this is intended behavior please ignore this report.

I will still review the above but I did indeed tried to mirror the behavior from MS Word, Notepad ++, etc.

Any chance you could add an option to never save to dynamic font assets in the first place instead of clearing them?
Kinda annoying to have them reload before/after every build due to the clear option if one doesn’t care about the contents anyways (and having random version control changes even though nobody actually changed the asset)

1 Like

Since we have users who want this data to be persistent, I am still looking for a clean way to provide for both behaviors.

Disabling serialization of dynamic data would mean they are always repopulated at runtime as characters and glyphs are requested.

Having dynamic data persist means larger build size since the atlas texture is not empty as you ship but It also means better performance at runtime as characters and glyphs contained in those assets does not have to be re-added and glyphs re-rastered into the atlas texture.

The only issue with the currently handling is source control related as you can control what happens to this data when you create a build. Note that Clear Dynamic Data on Build now also clears this data when you close the Editor. It can now also be manually cleared via the font asset context menu option seen below,

8087213--1045967--upload_2022-4-28_15-8-1.png

To avoid confusion, I do understand the desire to not have this dynamic data serialized at all. Thus the only use case for this is source control related. I will continue to explore how we could provide this functionality.

1 Like

the Mark to Base and Mark to Mark adjustment tables are fantastic.
we developed something similar to manage arabic diacritics, but we used the unicodes as IDs, now you ask for the glyph ID…
what happens if we reimport the font? will IDs change? could we use char unicodes as IDs?

thank you!

OpenType Layout features reference glyph indexes (IDs).

It is pretty common to have several characters point to the same glyph index.

It is also pretty common for fonts to contain many glyphs that are not mapped to any specific code point. For instance, the glyph used for the “ffi” Ligature typically does not have a Unicode code point associated with it.

Another example is Alternate Substitutions where a single glyph can be replaced by many alternate forms / glyphs. In this case you have a single unicode code point potentially pointing to several other glyphs.

If you look at the character table of a font asset, you will notice that a character is assigned a Unicode code point and points to a glyph index. Many characters can point to the same glyph index. The glyph table contains the glyphs and their metrics.

Once I am done implementing all of this, these OpenType Layout features and relevant data will be automatically extracted from the font file and populated in the font asset provide such data exists in the font. If the selected font doesn’t contain any OpenType Layout features, users will be able to manually add such data if desired.

With respect to Diacritical Marks, since both the base and mark are inputted sequentially by the user, the marks are assigned a Unicode code point. Although you could make this work by referencing these Unicode code point for Diacritical Marks, this is not the case for all OpenType Layout feature hence why the Mark-to-Base and Mark-to-Ligature and Mark-to-Mark tables in the GPOS table of the font file reference these glyphs by the index.

Re-importing or creating a new font asset from the same font file should have no affect on this. Having said that, if whoever designed the font created a new version with new glyphs and features, you would have to treat this like a new font (which it is) and either Reset the font asset to clear the existing font data which may now be invalid or create a new font asset.

1 Like

Hello everyone , any idea about this issue? Thank you.

Any updates on when the changes to the FontEngine will be available in a Unity upgrade? I haven’t seen anything mentioned in the release notes.