Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [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
- 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 <CR> at the end of a line. Case #1362068
- Added support for <CR> 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 <ZWSP> 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 <ZWJ> 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](https://forum.unity.com/threads/fallback-to-emojis-before-fonts.1186174/) for details.
- Fixed duplicated character when using custom validator in conjunction with soft keyboard. Case #1387772
- The <noparse> markup tag will now also affect inline markup tags like <br>, <shy>, 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 <a href="url"> markup tag which can be used as follows: "See <a href="http://url...">this link</a> for details.". This new markup tag is similar to the <link> 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 <a> 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
  • Loading branch information
Unity Technologies committed Mar 7, 2022
1 parent f2d5cfb commit cd02c78
Show file tree
Hide file tree
Showing 51 changed files with 2,557 additions and 2,012 deletions.
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
# 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.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
- 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 <CR> at the end of a line. Case #1362068
- Added support for <CR> 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 <ZWSP> 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 <ZWJ> 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](https://forum.unity.com/threads/fallback-to-emojis-before-fonts.1186174/) for details.
- Fixed duplicated character when using custom validator in conjunction with soft keyboard. Case #1387772
- The <noparse> markup tag will now also affect inline markup tags like <br>, <shy>, 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 <a href="url"> markup tag which can be used as follows: "See <a href="http://url...">this link</a> for details.". This new markup tag is similar to the <link> 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 <a> 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

## [3.2.0-pre.2] - 2021-10-31
### Changes
- Fixed incorrect character spacing when using the <scale> tag. See [forum post](https://forum.unity.com/threads/inconsistent-spacing-between-characters-when-scaling-width.1156967/) for details.
Expand Down
Binary file modified Package Resources/TMP Essential Resources.unitypackage
Binary file not shown.
Binary file modified Package Resources/TMP Examples & Extras.unitypackage
Binary file not shown.
61 changes: 0 additions & 61 deletions Scripts/Editor/PropertyDrawers/GlyphInfoDrawer.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
using UnityEngine.TextCore;
using UnityEngine.TextCore.LowLevel;
using UnityEditor;
using System.Collections;
using System.Text.RegularExpressions;
using System.Collections.Generic;


namespace TMPro.EditorUtilities
Expand All @@ -12,8 +11,10 @@ namespace TMPro.EditorUtilities
[CustomPropertyDrawer(typeof(GlyphPairAdjustmentRecord))]
internal class GlyphPairAdjustmentRecordPropertyDrawer : PropertyDrawer
{
private bool isEditingEnabled = false;
private bool isSelectable = false;
private bool isEditingEnabled;
private bool isSelectable;

private Dictionary<uint, GlyphProxy> m_GlyphLookupDictionary;

private string m_FirstCharacter = string.Empty;
private string m_SecondCharacter = string.Empty;
Expand All @@ -34,6 +35,9 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten

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

if (TMP_PropertyDrawerUtilities.s_RefreshGlyphProxyLookup)
TMP_PropertyDrawerUtilities.RefreshGlyphProxyLookup(property.serializedObject, m_GlyphLookupDictionary);

position.yMin += 2;

float width = position.width / 2;
Expand Down Expand Up @@ -76,7 +80,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
//rect.y += 20;
//EditorGUI.PropertyField(rect, prop_FirstGlyphValueRecord.FindPropertyRelative("m_YAdvance"), new GUIContent("AY:"));

DrawGlyph((uint)prop_FirstGlyphIndex.intValue, new Rect(position.x, position.y, position.width, position.height), property);
DrawGlyph((uint)prop_FirstGlyphIndex.intValue, new Rect(position.x, position.y + 2, 64, 60), property);
}
else
{
Expand Down Expand Up @@ -162,7 +166,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
//rect.y += 20;
//EditorGUI.PropertyField(rect, prop_SecondGlyphAdjustment.FindPropertyRelative("m_YAdvance"), new GUIContent("AY"));

DrawGlyph((uint)prop_SecondGlyphIndex.intValue, new Rect(position.width / 2 + 20, position.y, position.width, position.height), property);
DrawGlyph((uint)prop_SecondGlyphIndex.intValue, new Rect(position.width / 2 + 20, position.y + 2, 64, 60), property);
}
else
{
Expand Down Expand Up @@ -315,59 +319,44 @@ uint GetUnicodeCharacter (string source)

void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
{
// Get a reference to the font asset
TMP_FontAsset fontAsset = property.serializedObject.targetObject as TMP_FontAsset;

if (fontAsset == null)
// Get a reference to the serialized object which can either be a TMP_FontAsset or FontAsset.
SerializedObject so = property.serializedObject;
if (so == null)
return;

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

// Check if glyph is present in the atlas texture.
if (!fontAsset.glyphLookupTable.TryGetValue(glyphIndex, out glyph))
// Try getting a reference to the glyph for the given glyph index.
if (!m_GlyphLookupDictionary.TryGetValue(glyphIndex, out GlyphProxy glyph))
return;

// Get the atlas index of the glyph and lookup its atlas texture
int atlasIndex = glyph.atlasIndex;
Texture2D atlasTexture = fontAsset.atlasTextures.Length > atlasIndex ? fontAsset.atlasTextures[atlasIndex] : null;

if (atlasTexture == null)
Texture2D atlasTexture;
if (TMP_PropertyDrawerUtilities.TryGetAtlasTextureFromSerializedObject(so, glyph.atlasIndex, out atlasTexture) == false)
return;

Material mat;
if (((GlyphRasterModes)fontAsset.atlasRenderMode & GlyphRasterModes.RASTER_MODE_BITMAP) == GlyphRasterModes.RASTER_MODE_BITMAP)
{
mat = TMP_FontAssetEditor.internalBitmapMaterial;

if (mat == null)
return;

mat.mainTexture = atlasTexture;
}
else
{
mat = TMP_FontAssetEditor.internalSDFMaterial;

if (mat == null)
return;

mat.mainTexture = atlasTexture;
mat.SetFloat(ShaderUtilities.ID_GradientScale, fontAsset.atlasPadding + 1);
}
if (TMP_PropertyDrawerUtilities.TryGetMaterial(so, atlasTexture, out mat) == false)
return;

// Draw glyph from atlas texture.
Rect glyphDrawPosition = new Rect(position.x, position.y + 2, 64, 60);
Rect glyphDrawPosition = position;

int padding = so.FindProperty("m_AtlasPadding").intValue;
GlyphRect glyphRect = glyph.glyphRect;

int padding = fontAsset.atlasPadding;

int glyphOriginX = glyphRect.x - padding;
int glyphOriginY = glyphRect.y - padding;
int glyphWidth = glyphRect.width + padding * 2;
int glyphHeight = glyphRect.height + padding * 2;

float normalizedHeight = fontAsset.faceInfo.ascentLine - fontAsset.faceInfo.descentLine;
SerializedProperty faceInfoProperty = so.FindProperty("m_FaceInfo");
float ascentLine = faceInfoProperty.FindPropertyRelative("m_AscentLine").floatValue;
float descentLine = faceInfoProperty.FindPropertyRelative("m_DescentLine").floatValue;

float normalizedHeight = ascentLine - descentLine;
float scale = glyphDrawPosition.width / normalizedHeight;

// Compute the normalized texture coordinates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class LigatureSubstitutionRecordPropertyDrawer : PropertyDrawer
{
//private bool isEditingEnabled;
private bool isSelectable;
private bool m_ShouldRefreshLookupDictionary;

private Dictionary<uint, GlyphProxy> m_GlyphLookupDictionary;

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
Expand All @@ -22,8 +20,8 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
SerializedProperty prop_LigatureGlyphID = property.FindPropertyRelative("m_LigatureGlyphID");

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

Rect rect = position;

Expand Down Expand Up @@ -63,7 +61,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
EditorGUI.DelayedIntField(new Rect(componentGlyphPosition.x - 13, componentGlyphPosition.y + 73, 40, EditorGUIUtility.singleLineHeight), prop_ComponentGlyphIDs.GetArrayElementAtIndex(i), GUIContent.none);
if (EditorGUI.EndChangeCheck())
{
m_ShouldRefreshLookupDictionary = true;

}
}

Expand All @@ -78,7 +76,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
EditorGUI.DelayedIntField(new Rect(ligatureGlyphPosition.x + 24, ligatureGlyphPosition.y + 94, 40, EditorGUIUtility.singleLineHeight), prop_LigatureGlyphID, GUIContent.none);
if (EditorGUI.EndChangeCheck())
{
m_ShouldRefreshLookupDictionary = true;

}
}

Expand All @@ -92,47 +90,25 @@ void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
if (m_GlyphLookupDictionary == null)
{
m_GlyphLookupDictionary = new Dictionary<uint, GlyphProxy>();
TMP_FontAssetEditorUtilities.PopulateGlyphProxyLookupDictionary(so, m_GlyphLookupDictionary);
TMP_PropertyDrawerUtilities.PopulateGlyphProxyLookupDictionary(so, m_GlyphLookupDictionary);
}

// Try getting a reference to the glyph for the given glyph index.
if (!m_GlyphLookupDictionary.TryGetValue(glyphIndex, out GlyphProxy glyph))
return;

// Get the atlas index of the glyph and lookup its atlas texture
SerializedProperty atlasTextureProperty = so.FindProperty("m_AtlasTextures");
Texture2D atlasTexture = atlasTextureProperty.GetArrayElementAtIndex(glyph.atlasIndex).objectReferenceValue as Texture2D;
if (atlasTexture == null)
Texture2D atlasTexture;
if (TMP_PropertyDrawerUtilities.TryGetAtlasTextureFromSerializedObject(so, glyph.atlasIndex, out atlasTexture) == false)
return;

Material mat;

GlyphRenderMode atlasRenderMode = (GlyphRenderMode)so.FindProperty("m_AtlasRenderMode").intValue;
int padding = so.FindProperty("m_AtlasPadding").intValue;

if (((GlyphRasterModes)atlasRenderMode & GlyphRasterModes.RASTER_MODE_BITMAP) == GlyphRasterModes.RASTER_MODE_BITMAP)
{
mat = TMP_FontAssetEditor.internalBitmapMaterial;

if (mat == null)
return;

mat.mainTexture = atlasTexture;
}
else
{
mat = TMP_FontAssetEditor.internalSDFMaterial;

if (mat == null)
return;

mat.mainTexture = atlasTexture;
mat.SetFloat(ShaderUtilities.ID_GradientScale, padding + 1);
}
if (TMP_PropertyDrawerUtilities.TryGetMaterial(so, atlasTexture, out mat) == false)
return;

// Draw glyph from atlas texture.
Rect glyphDrawPosition = new Rect(position.x, position.y + 2, position.width, position.height);
Rect glyphDrawPosition = position;

int padding = so.FindProperty("m_AtlasPadding").intValue;
GlyphRect glyphRect = glyph.glyphRect;
int glyphOriginX = glyphRect.x - padding;
int glyphOriginY = glyphRect.y - padding;
Expand Down Expand Up @@ -160,16 +136,5 @@ void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)
Graphics.DrawTexture(glyphDrawPosition, atlasTexture, texCoords, 0, 0, 0, 0, new Color(1f, 1f, 1f), mat);
}
}

void RefreshLookupDictionary(SerializedObject so)
{
if (m_GlyphLookupDictionary != null)
{
m_GlyphLookupDictionary.Clear();
TMP_FontAssetEditorUtilities.PopulateGlyphProxyLookupDictionary(so, m_GlyphLookupDictionary);
}

m_ShouldRefreshLookupDictionary = false;
}
}
}
Loading

0 comments on commit cd02c78

Please sign in to comment.