Skip to content

Commit

Permalink
com.unity.textmeshpro@3.2.0-pre.4
Browse files Browse the repository at this point in the history
## [3.2.0-pre.4] - 2022-12-16
### Changes
- Fixed italic horizontal displacement of punctuation. (TMPB-133)
- Updated Input Field to not restore the original text when the X in the HoloLens keyboard is pressed.
- Fixed MissingReferenceException when changing scenes. See case [TMPB-120](https://issuetracker.unity3d.com/issues/missingreferenceexception-thrown-when-changing-scenes) and forum [thread](https://forum.unity.com/threads/tmpro-submeshui-error-when-changing-scenes.1129724/) for more info.
- Fixed Undo operation not correctly undoing some newly created TMP objects. Case #1400391
- Fixed glyphs not being drawn in the various font asset inspector tables although present in the glyph table until unselecting and re-selecting the font asset.
- Fixed incorrect line breaking when using a mixture of Latin and CJK text.
- Fixed potential NullReferenceException when creating font asset with multiple atlas textures. See [forum post](https://forum.unity.com/threads/how-can-i-submit-bugs-or-issues-for-tmp.628687/#post-8186100) for details.
- Fixed potential issue when using the <mark> tag in conjunction with Ellipsis.
- Added new "Get Font Features" option in the Generation Settings of Font Assets to provide control over fetching of font feature data.
- Fix potential duplication of Ligature data when using Dynamic Font Assets.
- Added new "duospace" attribute to the <mspace=value> markup tag where the spacing of the '.', ':' and ',' characters will be half of the value. This was added as an option when displaying numerical values using this markup tag.
- With the addition of support for new OpenType Layout features such as Ligatures, Mark-to-Base and Mark-to-Mark, we have made the following changes:
  - The "Kerning" option in the Extra Settings of the text component inspector has been replaced by a new popup menu to independently control these features which are "kern", "liga", "mark" and "mkmk"
  - The "enableKerning" property has been deprecated and replaced by the "fontFeatures" property which is a list that contains which features are enabled on the text component.
- Fixed two potential NullReferenceException related to missing material references or materials on SubMesh text objects. See [forum post](https://forum.unity.com/threads/tmpro-submeshui-error-when-changing-scenes.1129724/#post-8462771) for details.
- Fixed for text alignment mode Justified and Flush blending not working correctly when using <NBSP> in the text.
- Fixed external keyboard on iOS/tvOS and Android when Hide Soft Keyboard is used
  • Loading branch information
Unity Technologies committed Dec 16, 2022
1 parent cd02c78 commit 02381a5
Show file tree
Hide file tree
Showing 51 changed files with 940 additions and 389 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# Changelog
These are the release notes for the TextMesh Pro UPM package which was first introduced with Unity 2018.1. Please see the following link for the Release Notes for prior versions of TextMesh Pro. http://digitalnativestudios.com/forum/index.php?topic=1363.0

## [3.2.0-pre.4] - 2022-12-16
### Changes
- Fixed italic horizontal displacement of punctuation. (TMPB-133)
- Updated Input Field to not restore the original text when the X in the HoloLens keyboard is pressed.
- Fixed MissingReferenceException when changing scenes. See case [TMPB-120](https://issuetracker.unity3d.com/issues/missingreferenceexception-thrown-when-changing-scenes) and forum [thread](https://forum.unity.com/threads/tmpro-submeshui-error-when-changing-scenes.1129724/) for more info.
- Fixed Undo operation not correctly undoing some newly created TMP objects. Case #1400391
- Fixed glyphs not being drawn in the various font asset inspector tables although present in the glyph table until unselecting and re-selecting the font asset.
- Fixed incorrect line breaking when using a mixture of Latin and CJK text.
- Fixed potential NullReferenceException when creating font asset with multiple atlas textures. See [forum post](https://forum.unity.com/threads/how-can-i-submit-bugs-or-issues-for-tmp.628687/#post-8186100) for details.
- Fixed potential issue when using the <mark> tag in conjunction with Ellipsis.
- Added new "Get Font Features" option in the Generation Settings of Font Assets to provide control over fetching of font feature data.
- Fix potential duplication of Ligature data when using Dynamic Font Assets.
- Added new "duospace" attribute to the <mspace=value> markup tag where the spacing of the '.', ':' and ',' characters will be half of the value. This was added as an option when displaying numerical values using this markup tag.
- With the addition of support for new OpenType Layout features such as Ligatures, Mark-to-Base and Mark-to-Mark, we have made the following changes:
- The "Kerning" option in the Extra Settings of the text component inspector has been replaced by a new popup menu to independently control these features which are "kern", "liga", "mark" and "mkmk"
- The "enableKerning" property has been deprecated and replaced by the "fontFeatures" property which is a list that contains which features are enabled on the text component.
- Fixed two potential NullReferenceException related to missing material references or materials on SubMesh text objects. See [forum post](https://forum.unity.com/threads/tmpro-submeshui-error-when-changing-scenes.1129724/#post-8462771) for details.
- Fixed for text alignment mode Justified and Flush blending not working correctly when using <NBSP> in the text.
- Fixed external keyboard on iOS/tvOS and Android when Hide Soft Keyboard is used

## [3.2.0-pre.3] - 2022-03-07
### Changes
- 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
Expand Down
56 changes: 56 additions & 0 deletions Documentation~/ColorEmojis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Color emojis

You can include color glyphs and emojis in text. To do so, import a font file that has color emojis in it and set it as the fallback emojis text assets.

![](images/NativeEmojiExample.png)

## Set up color emojis

Create a color font asset and add it to the TMP Settings Fallback. Note this is the same as the Project Settings/TextMeshPro/Settings as depicted in the image.

1. In your project, import a font file that has color emojis in it.
2. Right click in the `Asset` folder, and then select **Create > TextMeshPro > FontAsset > Color**. This ensures that you create the font asset with the right shader (Sprite) and the right atlas rendering mode (Color).
3. Open the TMP Settings asset or alternatively via the **Edit > ProjectSettings > TextMesh Pro > Settings**.
4. Add the emoji font asset to the **Fallback Emoji Text Assets** section.

![](images/FallbackEmoji.png)

Alternatively, assigning a color font asset to the text object will work fine provided that the [Emoji Fallback Support](ColorEmojis) option in the Extra Settings of the text component is disabled.

## Include emojis in text

To include emojis in text, do the following:

- Include emojis in text through their Unicode. For example, enter `\U00001f60` to represent a smile.
- Use OS Virtual Keyboard.
- Copy the emojis from an external Text Editing tool and paste them in your text field.

To find more information about the Unicode Emojis Standard, see this [link](http://unicode.org/Public/emoji/14.0/).

## Control Emoji Fallback Search

The "Emoji Fallback Support" option controls where we search for characters defined in the Unicode Standards as Emojis.

When this option is enabled (default), the "Fallback Emoji Text Assets" list will be search first for any characters defined as Emojis.

When this option is disabled, the Primary font asset assigned to the text component will be searched first.

Basically, this option overrides the character search to prioritize searching thru the "Fallback Emoji Text Assets" list first when the character is an emoji.

This option is also useful when a font contains black-and-white emojis as it allows the user to control if the emojis contained in the primary will be used or those from the "Fallback Emoji Text Assets" list.

To update the `Emoji Fallback Support`:
1. Select the **Text (TMP)** field in the hierarchy.
2. In the Inspector window, under the `Extra Settings` foldout of the **Text (TMP)** field, select the **Emoji Fallback Support** toggle.

![](images/EmojiFallbackSupport.png)

## Limitations

The color emojis feature has the following limitations:

- It doesn't support some OpenType font features, such as chain context and single substitution.
- It doesn't support Apple fonts that use the AAT format. It's a predecessor to OpenType.
- It doesn't support SVG color glyphs.
- Dynamic OS FontAsset has limited support on some iOS devices. The `Apple Color Emoji` font file found on OSX and several iOS devices works fine. However, the `Apple Color Emoji-160px` found on newer iOS devices is not support as the emoji's are encoded in JPEG format which is not supported by FreeType.
- Prior to Unity 2023.1, adding a UTF-32 through the inspector sends an error. The emojis won't display in the inspector.
43 changes: 43 additions & 0 deletions Documentation~/FontAssets.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,46 @@ Font Assets can have the following types of font atlas:
* **Smooth/Hinted Smooth:** This type of atlas is an antialiased bitmap texture. A Hinted smooth atlas aligns glyph pixels with texture pixels to produce a smoother result.<br/><br/>Smooth atlases work well for static text that is viewed head on, in situations where there is a good correspondence between texture pixels and screen pixels. Transforming text generated from a smooth atlas blurs the text edges.

* **Raster/Raster Hinted:** Raster atlases are un-smoothed bitmap textures. They almost always produce text with jagged, pixellated edges. The Hinted rater atlases align glyph pixels with texture pixels to produce a smoother result.

## Get Font Features

This option determines if OpenType font features should be retrieved from the source font file as new characters and glyphs are added to the font asset. Disabling this option will prevent extracting font features.

To update the Get Font Features option on a FontAsset:
1. Select the FontAsset
2. In the FontAsset inspector, navigate to the Generation Settings section.
3. Select **Get Font Features**.

![](images/GetFontFeatures.png)

## Reset
The `Reset` context menu option clears all tables which includes the Character and Glyph tables along with all font features tables such as the Ligature, Glyph Adjustment, Mark to Base, Mark to Mark tables. This option also clears the font asset's atlas texture and resets it back to size zero.

To reset a FontAsset:
1. Select the FontAsset
2. Expand the top right menu in the FontAsset Inspector.
3. Select **Reset**.

![](images/ResetMenuItem.png)

## Clear Dynamic Data
The `Clear Dynamic Data` context menu option clears the character and glyph tables as well as the font asset's atlas texture which is also resized back to size zero. This option preserves all font feature table data such as Ligatures, Glyph Adjustment, Mark to Base, Mark to Mark, etc.

To clear a FontAsset:
1. Select the FontAsset
2. Expand the top right menu in the FontAsset Inspector.
3. Select **Clear Dynamic Data**.

![](images/ClearDynamicDataMenuItem.png)

This preserves the custom ligatures, kernings, and diacritical marks you added to the font asset when clearing the atlas.

## Clear Dynamic Data on Build
The "Clear Dynamic Data on Build" performs the same function as the "Clear Dynamic Data" context menu option but performs this operation when creating a build as well as when closing the Editor.

To update the Clear Dynamic Data on Build option:
1. Select the FontAsset
2. In the FontAsset inspector, navigate to the Generation Settings section.
3. Select **Clear Dynamic Data on Build**.

![](images/ClearDynamicDataOnBuild.png)
17 changes: 17 additions & 0 deletions Documentation~/TMPObjects.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,20 @@ TextMesh Pro 3D text objects are nearly identical to their UI counterparts, but
1. From the menu, choose **GameObject > 3D GameObject > TextMesh Pro - Text**.
1. In the **TextMesh Pro** Inspector, enter your text.
1. Adjust the [3D text properties](TMPObject3DText.md) as needed.

## OpenType FontFeature
Font Features define the typographic capabilities of a font asset. These features define potential substitutions or positional adjustments of glyphs. The following are the currently supported Font Features:

- **Ligatures:** Defines the substitution of multiple glyphs by a single glyph, such as 'fi' or 'ffl'. This features is identified as "liga".

- **Kerning:** Defines positional adjustments between two glyphs relative to each other. This features is identified as "kern".

- **Diacritical Marks:** Defines positional adjustments between Base glyphs and Mark glyphs.

The Mark-to-Base feature "mark" defines the positional adjustments of Mark glyphs relative to Base glyphs.

The Mark-to-Mark feature "mkmk" defines the positional adjustments of Mark glyphs relative to Base Mark glyphs.

You can enable or disable the Font Features through the Font Features field in the Text component's Extra Settings section shown in the image below:

![](images/FontFeatures.png)
1 change: 1 addition & 0 deletions Documentation~/TableOfContents.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* [Signed Distance Fields](FontAssetsSDF)
* [Dynamic Fonts](FontAssetsDynamicFonts)
* [The Fallback Chain](FontAssetsFallback)
* [Color emojis](ColorEmojis)
* [Rich Text Tags](RichText)
* [Supported Tags](RichTextSupportedTags)
* [<align>](RichTextAlignment)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/ClearDynamicDataOnBuild.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/EmojiFallbackSupport.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/FallbackEmoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/FontFeatures.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/GetFontFeatures.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/NativeEmojiExample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Documentation~/images/ResetMenuItem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
TextMesh Pro copyright © 2021 Unity Technologies ApS
TextMesh Pro copyright © 2022 Unity Technologies ApS

Licensed under the Unity Companion License for Unity-dependent projects--see [Unity Companion License](http://www.unity3d.com/legal/licenses/Unity_Companion_License).

Expand Down
Binary file modified Package Resources/TMP Examples & Extras.unitypackage
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten

SerializedProperty prop_FontFeatureLookupFlags = property.FindPropertyRelative("m_FeatureLookupFlags");

// Refresh glyph proxy lookup dictionary if needed
if (TMP_PropertyDrawerUtilities.s_RefreshGlyphProxyLookup)
TMP_PropertyDrawerUtilities.RefreshGlyphProxyLookup(property.serializedObject, m_GlyphLookupDictionary);
TMP_PropertyDrawerUtilities.RefreshGlyphProxyLookup(property.serializedObject);

position.yMin += 2;

Expand Down Expand Up @@ -317,18 +318,15 @@ uint GetUnicodeCharacter (string source)
return unicode;
}

void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
void DrawGlyph(uint glyphIndex, Rect glyphDrawPosition, SerializedProperty property)
{
// Get a reference to the serialized object which can either be a TMP_FontAsset or FontAsset.
SerializedObject so = property.serializedObject;
if (so == null)
return;

if (m_GlyphLookupDictionary == null)
{
m_GlyphLookupDictionary = new Dictionary<uint, GlyphProxy>();
TMP_PropertyDrawerUtilities.PopulateGlyphProxyLookupDictionary(so, m_GlyphLookupDictionary);
}
m_GlyphLookupDictionary = TMP_PropertyDrawerUtilities.GetGlyphProxyLookupDictionary(so);

// Try getting a reference to the glyph for the given glyph index.
if (!m_GlyphLookupDictionary.TryGetValue(glyphIndex, out GlyphProxy glyph))
Expand All @@ -342,9 +340,6 @@ void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
if (TMP_PropertyDrawerUtilities.TryGetMaterial(so, atlasTexture, out mat) == false)
return;

// Draw glyph from atlas texture.
Rect glyphDrawPosition = position;

int padding = so.FindProperty("m_AtlasPadding").intValue;
GlyphRect glyphRect = glyph.glyphRect;
int glyphOriginX = glyphRect.x - padding;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
namespace TMPro.EditorUtilities
{
[CustomPropertyDrawer(typeof(LigatureSubstitutionRecord))]
public class LigatureSubstitutionRecordPropertyDrawer : PropertyDrawer
class LigatureSubstitutionRecordPropertyDrawer : PropertyDrawer
{
//private bool isEditingEnabled;
private bool isSelectable;
private Dictionary<uint, GlyphProxy> m_GlyphLookupDictionary;

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
Expand All @@ -19,21 +17,12 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
int ComponentGlyphIDCount = prop_ComponentGlyphIDs.arraySize;
SerializedProperty prop_LigatureGlyphID = property.FindPropertyRelative("m_LigatureGlyphID");

// Refresh glyph proxy lookup dictionary if needed.
// Refresh glyph proxy lookup dictionary if needed
if (TMP_PropertyDrawerUtilities.s_RefreshGlyphProxyLookup)
TMP_PropertyDrawerUtilities.RefreshGlyphProxyLookup(property.serializedObject, m_GlyphLookupDictionary);
TMP_PropertyDrawerUtilities.RefreshGlyphProxyLookup(property.serializedObject);

Rect rect = position;

//isEditingEnabled = GUI.enabled;
isSelectable = label.text == "Selectable";

if (isSelectable)
GUILayoutUtility.GetRect(position.width, 100);
else
GUILayoutUtility.GetRect(position.width, 80);

//GUIStyle style = new GUIStyle(EditorStyles.label) {richText = true, alignment = TextAnchor.UpperCenter};
GUILayoutUtility.GetRect(position.width, 100);

EditorGUIUtility.labelWidth = 115;
EditorGUI.BeginChangeCheck();
Expand Down Expand Up @@ -80,18 +69,15 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
}
}

void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
void DrawGlyph(uint glyphIndex, Rect glyphDrawPosition, SerializedProperty property)
{
// Get a reference to the serialized object which can either be a TMP_FontAsset or FontAsset.
SerializedObject so = property.serializedObject;
if (so == null)
return;

if (m_GlyphLookupDictionary == null)
{
m_GlyphLookupDictionary = new Dictionary<uint, GlyphProxy>();
TMP_PropertyDrawerUtilities.PopulateGlyphProxyLookupDictionary(so, m_GlyphLookupDictionary);
}
m_GlyphLookupDictionary = TMP_PropertyDrawerUtilities.GetGlyphProxyLookupDictionary(so);

// Try getting a reference to the glyph for the given glyph index.
if (!m_GlyphLookupDictionary.TryGetValue(glyphIndex, out GlyphProxy glyph))
Expand All @@ -105,9 +91,6 @@ void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
if (TMP_PropertyDrawerUtilities.TryGetMaterial(so, atlasTexture, out mat) == false)
return;

// Draw glyph from atlas texture.
Rect glyphDrawPosition = position;

int padding = so.FindProperty("m_AtlasPadding").intValue;
GlyphRect glyphRect = glyph.glyphRect;
int glyphOriginX = glyphRect.x - padding;
Expand Down
13 changes: 4 additions & 9 deletions Scripts/Editor/PropertyDrawers/TMP_CharacterPropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
SerializedProperty prop_GlyphIndex = property.FindPropertyRelative("m_GlyphIndex");
SerializedProperty prop_Scale = property.FindPropertyRelative("m_Scale");

// Refresh glyph proxy lookup dictionary if needed
if (TMP_PropertyDrawerUtilities.s_RefreshGlyphProxyLookup)
TMP_PropertyDrawerUtilities.RefreshGlyphProxyLookup(property.serializedObject, m_GlyphLookupDictionary);
TMP_PropertyDrawerUtilities.RefreshGlyphProxyLookup(property.serializedObject);

GUIStyle style = new GUIStyle(EditorStyles.label);
style.richText = true;
Expand Down Expand Up @@ -154,18 +155,15 @@ public override float GetPropertyHeight(SerializedProperty property, GUIContent
return 58;
}

void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
void DrawGlyph(uint glyphIndex, Rect glyphDrawPosition, SerializedProperty property)
{
// Get a reference to the serialized object which can either be a TMP_FontAsset or FontAsset.
SerializedObject so = property.serializedObject;
if (so == null)
return;

if (m_GlyphLookupDictionary == null)
{
m_GlyphLookupDictionary = new Dictionary<uint, GlyphProxy>();
TMP_PropertyDrawerUtilities.PopulateGlyphProxyLookupDictionary(so, m_GlyphLookupDictionary);
}
m_GlyphLookupDictionary = TMP_PropertyDrawerUtilities.GetGlyphProxyLookupDictionary(so);

// Try getting a reference to the glyph for the given glyph index.
if (!m_GlyphLookupDictionary.TryGetValue(glyphIndex, out GlyphProxy glyph))
Expand All @@ -179,9 +177,6 @@ void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
if (TMP_PropertyDrawerUtilities.TryGetMaterial(so, atlasTexture, out mat) == false)
return;

// Draw glyph from atlas texture.
Rect glyphDrawPosition = position;

int padding = so.FindProperty("m_AtlasPadding").intValue;
GlyphRect glyphRect = glyph.glyphRect;
int glyphOriginX = glyphRect.x - padding;
Expand Down
Loading

0 comments on commit 02381a5

Please sign in to comment.