Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.5.0-preview.6] - 2020-03-06
## [2.1.0-preview.6]
## [3.0.0-preview.6]
### Changes
- Reverted recent change to the TMP_SubMeshUI OnDisable() function that could result in a Missing Reference Exception in the GraphicRaycaster.cs script. See the following [forum post](https://forum.unity.com/threads/version-1-5-0-2-1-0-preview-5-now-available-for-testing.753587/page-2#post-5523412).
- Fixed glyph drawing issue in the Font Asset Inspector Glyph Adjustment Table when Multi Atlas Texture is enabled and the glyph is not located in the main atlas texture or at atlasTextures[0].
- Added support for &ltZWSP&gt tag which is internally replaced by a zero width space or \u200B.
- Improved line breaking handling when using &ltNBSP&gt and / or &ltNOBR&gt tags where instead of breaking these line segments per character, they will break at any possible soft breaking space when these segments exceed the width of the text container.
- Improved PreferredHeight calculations and handling when using Text Auto Size.
- Fixed incorrect color being applied to the underline or strikethrough line segments when using <u> and / or <s> tags along with a <color> tag while at the same time applying an Underline or Strikethrough font style on the whole text object.
- Fixed SDF Scale not getting updated when using SetText() with StringBuilder when the lossyScale of the text object changes. Case #1216007
- Added Non Breaking Space \u00A0 and Soft Hyphen \u00AD to list of synthesized characters in the event they are not present in the source font file.
- Fixed stack overflow issue when using TMP_FontAsset.HasCharacter and TMP_FontAsset.HasCharacters function on font assets that have circular fallback references. Case #1222574
- Fixed atlas texture not getting set correctly to IsReadable when switching a static font asset to dynamic in the Generation Settings of the Font Asset Inspector.
- Added check for RectTransform.sizeDelta change when OnRectTransformDimensionsChange() is called by the Canvas system to get around potential rounding error that erroneously trigger this callback when the RectTransform is using Stretch Anchor mode.
- As requested by a few users, TMP_FontAsset.faceInfo setter is now public instead of internal.
  • Loading branch information
Unity Technologies committed Mar 5, 2020
1 parent e6c8e28 commit 23c7626
Show file tree
Hide file tree
Showing 9 changed files with 977 additions and 482 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
# 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

## [1.5.0-preview.6] - 2020-03-06
## [2.1.0-preview.6]
## [3.0.0-preview.6]
### Changes
- Reverted recent change to the TMP_SubMeshUI OnDisable() function that could result in a Missing Reference Exception in the GraphicRaycaster.cs script. See the following [forum post](https://forum.unity.com/threads/version-1-5-0-2-1-0-preview-5-now-available-for-testing.753587/page-2#post-5523412).
- Fixed glyph drawing issue in the Font Asset Inspector Glyph Adjustment Table when Multi Atlas Texture is enabled and the glyph is not located in the main atlas texture or at atlasTextures[0].
- Added support for &ltZWSP&gt tag which is internally replaced by a zero width space or \u200B.
- Improved line breaking handling when using &ltNBSP&gt and / or &ltNOBR&gt tags where instead of breaking these line segments per character, they will break at any possible soft breaking space when these segments exceed the width of the text container.
- Improved PreferredHeight calculations and handling when using Text Auto Size.
- Fixed incorrect color being applied to the underline or strikethrough line segments when using <u> and / or <s> tags along with a <color> tag while at the same time applying an Underline or Strikethrough font style on the whole text object.
- Fixed SDF Scale not getting updated when using SetText() with StringBuilder when the lossyScale of the text object changes. Case #1216007
- Added Non Breaking Space \u00A0 and Soft Hyphen \u00AD to list of synthesized characters in the event they are not present in the source font file.
- Fixed stack overflow issue when using TMP_FontAsset.HasCharacter and TMP_FontAsset.HasCharacters function on font assets that have circular fallback references. Case #1222574
- Fixed atlas texture not getting set correctly to IsReadable when switching a static font asset to dynamic in the Generation Settings of the Font Asset Inspector.
- Added check for RectTransform.sizeDelta change when OnRectTransformDimensionsChange() is called by the Canvas system to get around potential rounding error that erroneously trigger this callback when the RectTransform is using Stretch Anchor mode.
- As requested by a few users, TMP_FontAsset.faceInfo setter is now public instead of internal.

## [1.5.0-preview.5] - 2020-02-25
## [2.1.0-preview.5]
## [3.0.0-preview.5]
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Editor/TMP_FontAssetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public override void OnInspectorGUI()
{
#if UNITY_EDITOR && UNITY_2018_4_OR_NEWER
#if !(UNITY_2018_4_0 || UNITY_2018_4_1 || UNITY_2018_4_2 || UNITY_2018_4_3 || UNITY_2018_4_4)
FontEngineEditorUtilities.SetAtlasTextureIsReadable(tex, false);
FontEngineEditorUtilities.SetAtlasTextureIsReadable(tex, true);
#endif
#endif
}
Expand Down
27 changes: 17 additions & 10 deletions Scripts/Editor/TMP_GlyphPairAdjustmentRecordPropertyDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,20 +316,20 @@ uint GetUnicodeCharacter (string source)

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

if (fontAsset == null)
return;

Glyph glyph;

// Check if glyph currently exists in the atlas texture.
// Check if glyph is present in the atlas texture.
if (!fontAsset.glyphLookupTable.TryGetValue(glyphIndex, out glyph))
return;

// Get reference to atlas texture.
int atlasIndex = fontAsset.m_AtlasTextureIndex;
// 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)
Expand Down Expand Up @@ -361,18 +361,25 @@ void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)

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;
float scale = glyphDrawPosition.width / normalizedHeight;

// Compute the normalized texture coordinates
Rect texCoords = new Rect((float)glyphRect.x / atlasTexture.width, (float)glyphRect.y / atlasTexture.height, (float)glyphRect.width / atlasTexture.width, (float)glyphRect.height / atlasTexture.height);
Rect texCoords = new Rect((float)glyphOriginX / atlasTexture.width, (float)glyphOriginY / atlasTexture.height, (float)glyphWidth / atlasTexture.width, (float)glyphHeight / atlasTexture.height);

if (Event.current.type == EventType.Repaint)
{
glyphDrawPosition.x += (glyphDrawPosition.width - glyphRect.width * scale) / 2;
glyphDrawPosition.y += (glyphDrawPosition.height - glyphRect.height * scale) / 2;
glyphDrawPosition.width = glyphRect.width * scale;
glyphDrawPosition.height = glyphRect.height * scale;
glyphDrawPosition.x += (glyphDrawPosition.width - glyphWidth * scale) / 2;
glyphDrawPosition.y += (glyphDrawPosition.height - glyphHeight * scale) / 2;
glyphDrawPosition.width = glyphWidth * scale;
glyphDrawPosition.height = glyphHeight * scale;

// Could switch to using the default material of the font asset which would require passing scale to the shader.
Graphics.DrawTexture(glyphDrawPosition, atlasTexture, texCoords, 0, 0, 0, 0, new Color(1f, 1f, 1f), mat);
Expand All @@ -381,4 +388,4 @@ void DrawGlyph(uint glyphIndex, Rect position, SerializedProperty property)


}
}
}
Loading

0 comments on commit 23c7626

Please sign in to comment.