feat: Initial commit

This commit is contained in:
2025-02-14 16:06:00 +08:00
commit da75a84e02
1056 changed files with 163517 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
using System.Runtime.CompilerServices;
// Allow internal visibility for testing purposes.
[assembly: InternalsVisibleTo("Unity.TextCore")]
[assembly: InternalsVisibleTo("Unity.FontEngine.Tests")]
#if UNITY_EDITOR
[assembly: InternalsVisibleTo("Unity.TextCore.Editor")]
[assembly: InternalsVisibleTo("Unity.TextMeshPro.Editor")]
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cc4155a9f4c4a61478dced5053f1bd07
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
// This file is used by Code Analysis to maintain SuppressMessage
// attributes that are applied to this project.
// Project-level suppressions either have no target or are given
// a specific target and scoped to a namespace, type, member, etc.
using System.Diagnostics.CodeAnalysis;
[assembly: SuppressMessage("Performance", "UNT0026")]
[assembly: SuppressMessage("Performance", "UNT0035")]
[assembly: SuppressMessage("Style", "IDE0017")]
[assembly: SuppressMessage("Style", "IDE0018")]
[assembly: SuppressMessage("Style", "IDE0031")]
[assembly: SuppressMessage("Style", "IDE0034")]
[assembly: SuppressMessage("Style", "IDE0044")]
[assembly: SuppressMessage("Style", "IDE0051")]
[assembly: SuppressMessage("Style", "IDE0052")]
[assembly: SuppressMessage("Style", "IDE0054")]
[assembly: SuppressMessage("Style", "IDE0056")]
[assembly: SuppressMessage("Style", "IDE0057")]
[assembly: SuppressMessage("Style", "IDE0059")]
[assembly: SuppressMessage("Style", "IDE0060")]
[assembly: SuppressMessage("Style", "IDE0063")]
[assembly: SuppressMessage("Style", "IDE0066")]
[assembly: SuppressMessage("Style", "IDE0074")]
[assembly: SuppressMessage("Style", "IDE0079")]
[assembly: SuppressMessage("Style", "IDE0083")]
[assembly: SuppressMessage("Style", "IDE0090")]
[assembly: SuppressMessage("Style", "IDE0180")]
[assembly: SuppressMessage("Style", "IDE0251")]
[assembly: SuppressMessage("Style", "IDE1005")]
[assembly: SuppressMessage("Style", "IDE1006")]

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b51b4f4c3bc4c0844b9eb517250fe406
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
namespace TMPro
{
/// <summary>
/// Interface used for preprocessing and shaping of text.
/// </summary>
public interface ITextPreprocessor
{
/// <summary>
/// Function used for preprocessing of text
/// </summary>
/// <param name="text">Source text to be processed</param>
/// <returns>Processed text</returns>
string PreprocessText(string text);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04973cf92f7eb984989cc757a35ce78c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 3fd0378c8b128984483147606e14726e
timeCreated: 1449743129
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,220 @@
using System.Diagnostics;
using UnityEngine;
using UnityEngine.TextCore;
using UnityEngine.TextCore.Text;
namespace TMPro
{
public struct TMP_Vertex
{
public Vector3 position;
public Vector4 uv;
public Vector2 uv2;
//public Vector2 uv4;
public Color32 color;
public static TMP_Vertex zero { get { return k_Zero; } }
//public Vector3 normal;
//public Vector4 tangent;
static readonly TMP_Vertex k_Zero = new TMP_Vertex();
}
/// <summary>
///
/// </summary>
public struct TMP_Offset
{
public float left { get { return m_Left; } set { m_Left = value; } }
public float right { get { return m_Right; } set { m_Right = value; } }
public float top { get { return m_Top; } set { m_Top = value; } }
public float bottom { get { return m_Bottom; } set { m_Bottom = value; } }
public float horizontal { get { return m_Left; } set { m_Left = value; m_Right = value; } }
public float vertical { get { return m_Top; } set { m_Top = value; m_Bottom = value; } }
/// <summary>
///
/// </summary>
public static TMP_Offset zero { get { return k_ZeroOffset; } }
// =============================================
// Private backing fields for public properties.
// =============================================
float m_Left;
float m_Right;
float m_Top;
float m_Bottom;
static readonly TMP_Offset k_ZeroOffset = new TMP_Offset(0F, 0F, 0F, 0F);
/// <summary>
///
/// </summary>
/// <param name="left"></param>
/// <param name="right"></param>
/// <param name="top"></param>
/// <param name="bottom"></param>
public TMP_Offset(float left, float right, float top, float bottom)
{
m_Left = left;
m_Right = right;
m_Top = top;
m_Bottom = bottom;
}
/// <summary>
///
/// </summary>
/// <param name="horizontal"></param>
/// <param name="vertical"></param>
public TMP_Offset(float horizontal, float vertical)
{
m_Left = horizontal;
m_Right = horizontal;
m_Top = vertical;
m_Bottom = vertical;
}
public static bool operator ==(TMP_Offset lhs, TMP_Offset rhs)
{
return lhs.m_Left == rhs.m_Left &&
lhs.m_Right == rhs.m_Right &&
lhs.m_Top == rhs.m_Top &&
lhs.m_Bottom == rhs.m_Bottom;
}
public static bool operator !=(TMP_Offset lhs, TMP_Offset rhs)
{
return !(lhs == rhs);
}
public static TMP_Offset operator *(TMP_Offset a, float b)
{
return new TMP_Offset(a.m_Left * b, a.m_Right * b, a.m_Top * b, a.m_Bottom * b);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public bool Equals(TMP_Offset other)
{
return base.Equals(other);
}
}
/// <summary>
///
/// </summary>
public struct HighlightState
{
public Color32 color;
public TMP_Offset padding;
public HighlightState(Color32 color, TMP_Offset padding)
{
this.color = color;
this.padding = padding;
}
public static bool operator ==(HighlightState lhs, HighlightState rhs)
{
return lhs.color.Compare(rhs.color) && lhs.padding == rhs.padding;
}
public static bool operator !=(HighlightState lhs, HighlightState rhs)
{
return !(lhs == rhs);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public bool Equals(HighlightState other)
{
return base.Equals(other);
}
}
/// <summary>
/// Structure containing information about individual text elements (character or sprites).
/// </summary>
[DebuggerDisplay("Unicode '{character}' ({((uint)character).ToString(\"X\")})")]
public struct TMP_CharacterInfo
{
public TMP_TextElementType elementType;
public char character; // Should be changed to an uint to handle UTF32
public int index;
public int stringLength;
public TextElement textElement;
public Glyph alternativeGlyph;
public FontAsset fontAsset;
public Material material;
public int materialReferenceIndex;
public bool isUsingAlternateTypeface;
public float pointSize;
//public short wordNumber;
public int lineNumber;
//public short charNumber;
public int pageNumber;
public int vertexIndex;
public TMP_Vertex vertex_BL;
public TMP_Vertex vertex_TL;
public TMP_Vertex vertex_TR;
public TMP_Vertex vertex_BR;
public Vector3 topLeft;
public Vector3 bottomLeft;
public Vector3 topRight;
public Vector3 bottomRight;
public float origin;
public float xAdvance;
public float ascender;
public float baseLine;
public float descender;
internal float adjustedAscender;
internal float adjustedDescender;
internal float adjustedHorizontalAdvance;
public float aspectRatio;
public float scale;
public Color32 color;
public Color32 underlineColor;
public int underlineVertexIndex;
public Color32 strikethroughColor;
public int strikethroughVertexIndex;
public Color32 highlightColor;
public HighlightState highlightState;
public FontStyles style;
public bool isVisible;
//public bool isIgnoringAlignment;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 78117be65f9ab544a9a373a26f4148f0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,74 @@
using UnityEngine;
using System.Collections;
namespace TMPro
{
// Class used to convert scenes and objects saved in version 0.1.44 to the new Text Container
public static class TMP_Compatibility
{
public enum AnchorPositions { TopLeft, Top, TopRight, Left, Center, Right, BottomLeft, Bottom, BottomRight, BaseLine, None };
/// <summary>
/// Function used to convert text alignment option enumeration format.
/// </summary>
/// <param name="oldValue"></param>
/// <returns></returns>
public static TextAlignmentOptions ConvertTextAlignmentEnumValues(TextAlignmentOptions oldValue)
{
switch ((int)oldValue)
{
case 0:
return TextAlignmentOptions.TopLeft;
case 1:
return TextAlignmentOptions.Top;
case 2:
return TextAlignmentOptions.TopRight;
case 3:
return TextAlignmentOptions.TopJustified;
case 4:
return TextAlignmentOptions.Left;
case 5:
return TextAlignmentOptions.Center;
case 6:
return TextAlignmentOptions.Right;
case 7:
return TextAlignmentOptions.Justified;
case 8:
return TextAlignmentOptions.BottomLeft;
case 9:
return TextAlignmentOptions.Bottom;
case 10:
return TextAlignmentOptions.BottomRight;
case 11:
return TextAlignmentOptions.BottomJustified;
case 12:
return TextAlignmentOptions.BaselineLeft;
case 13:
return TextAlignmentOptions.Baseline;
case 14:
return TextAlignmentOptions.BaselineRight;
case 15:
return TextAlignmentOptions.BaselineJustified;
case 16:
return TextAlignmentOptions.MidlineLeft;
case 17:
return TextAlignmentOptions.Midline;
case 18:
return TextAlignmentOptions.MidlineRight;
case 19:
return TextAlignmentOptions.MidlineJustified;
case 20:
return TextAlignmentOptions.CaplineLeft;
case 21:
return TextAlignmentOptions.Capline;
case 22:
return TextAlignmentOptions.CaplineRight;
case 23:
return TextAlignmentOptions.CaplineJustified;
}
return TextAlignmentOptions.TopLeft;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2c9cc00f0e8000543a1ed26c2a0f1f0b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,246 @@
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
namespace TMPro
{
// Base interface for tweeners,
// using an interface instead of
// an abstract class as we want the
// tweens to be structs.
internal interface ITweenValue
{
void TweenValue(float floatPercentage);
bool ignoreTimeScale { get; }
float duration { get; }
bool ValidTarget();
}
// Color tween class, receives the
// TweenValue callback and then sets
// the value on the target.
internal struct ColorTween : ITweenValue
{
public enum ColorTweenMode
{
All,
RGB,
Alpha
}
public class ColorTweenCallback : UnityEvent<Color> { }
private ColorTweenCallback m_Target;
private Color m_StartColor;
private Color m_TargetColor;
private ColorTweenMode m_TweenMode;
private float m_Duration;
private bool m_IgnoreTimeScale;
public Color startColor
{
get { return m_StartColor; }
set { m_StartColor = value; }
}
public Color targetColor
{
get { return m_TargetColor; }
set { m_TargetColor = value; }
}
public ColorTweenMode tweenMode
{
get { return m_TweenMode; }
set { m_TweenMode = value; }
}
public float duration
{
get { return m_Duration; }
set { m_Duration = value; }
}
public bool ignoreTimeScale
{
get { return m_IgnoreTimeScale; }
set { m_IgnoreTimeScale = value; }
}
public void TweenValue(float floatPercentage)
{
if (!ValidTarget())
return;
var newColor = Color.Lerp(m_StartColor, m_TargetColor, floatPercentage);
if (m_TweenMode == ColorTweenMode.Alpha)
{
newColor.r = m_StartColor.r;
newColor.g = m_StartColor.g;
newColor.b = m_StartColor.b;
}
else if (m_TweenMode == ColorTweenMode.RGB)
{
newColor.a = m_StartColor.a;
}
m_Target.Invoke(newColor);
}
public void AddOnChangedCallback(UnityAction<Color> callback)
{
if (m_Target == null)
m_Target = new ColorTweenCallback();
m_Target.AddListener(callback);
}
public bool GetIgnoreTimescale()
{
return m_IgnoreTimeScale;
}
public float GetDuration()
{
return m_Duration;
}
public bool ValidTarget()
{
return m_Target != null;
}
}
// Float tween class, receives the
// TweenValue callback and then sets
// the value on the target.
internal struct FloatTween : ITweenValue
{
public class FloatTweenCallback : UnityEvent<float> { }
private FloatTweenCallback m_Target;
private float m_StartValue;
private float m_TargetValue;
private float m_Duration;
private bool m_IgnoreTimeScale;
public float startValue
{
get { return m_StartValue; }
set { m_StartValue = value; }
}
public float targetValue
{
get { return m_TargetValue; }
set { m_TargetValue = value; }
}
public float duration
{
get { return m_Duration; }
set { m_Duration = value; }
}
public bool ignoreTimeScale
{
get { return m_IgnoreTimeScale; }
set { m_IgnoreTimeScale = value; }
}
public void TweenValue(float floatPercentage)
{
if (!ValidTarget())
return;
var newValue = Mathf.Lerp(m_StartValue, m_TargetValue, floatPercentage);
m_Target.Invoke(newValue);
}
public void AddOnChangedCallback(UnityAction<float> callback)
{
if (m_Target == null)
m_Target = new FloatTweenCallback();
m_Target.AddListener(callback);
}
public bool GetIgnoreTimescale()
{
return m_IgnoreTimeScale;
}
public float GetDuration()
{
return m_Duration;
}
public bool ValidTarget()
{
return m_Target != null;
}
}
// Tween runner, executes the given tween.
// The coroutine will live within the given
// behaviour container.
internal class TweenRunner<T> where T : struct, ITweenValue
{
protected MonoBehaviour m_CoroutineContainer;
protected IEnumerator m_Tween;
// utility function for starting the tween
private static IEnumerator Start(T tweenInfo)
{
if (!tweenInfo.ValidTarget())
yield break;
var elapsedTime = 0.0f;
while (elapsedTime < tweenInfo.duration)
{
elapsedTime += tweenInfo.ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime;
var percentage = Mathf.Clamp01(elapsedTime / tweenInfo.duration);
tweenInfo.TweenValue(percentage);
yield return null;
}
tweenInfo.TweenValue(1.0f);
}
public void Init(MonoBehaviour coroutineContainer)
{
m_CoroutineContainer = coroutineContainer;
}
public void StartTween(T info)
{
if (m_CoroutineContainer == null)
{
Debug.LogWarning("Coroutine container not configured... did you forget to call Init?");
return;
}
StopTween();
if (!m_CoroutineContainer.gameObject.activeInHierarchy)
{
info.TweenValue(1.0f);
return;
}
m_Tween = Start(info);
m_CoroutineContainer.StartCoroutine(m_Tween);
}
public void StopTween()
{
if (m_Tween != null)
{
m_CoroutineContainer.StopCoroutine(m_Tween);
m_Tween = null;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 38133bafd4674d242835faca6f9f864f
timeCreated: 1464850953
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 094d5dbc4aa34bc40baa80a884b5ff3c
timeCreated: 1446378357
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c0a28a6dcbb780342a6fc7a12c3d160e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: a7ec9e7ad8b847b7ae4510af83c5d868, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,188 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.TextCore.LowLevel;
namespace TMPro
{
internal class TMP_DynamicFontAssetUtilities
{
private static TMP_DynamicFontAssetUtilities s_Instance = new TMP_DynamicFontAssetUtilities();
private Dictionary<ulong, FontReference> s_SystemFontLookup;
private string[] s_SystemFontPaths;
private uint s_RegularStyleNameHashCode = 1291372090;
public struct FontReference
{
public string familyName;
public string styleName;
public int faceIndex;
public string filePath;
public ulong hashCode;
/// <summary>
/// Constructor for new FontReference
/// </summary>
/// <param name="faceNameAndStyle">String that combines the family name with style name</param>
/// <param name="index">Index of the font face and style.</param>
public FontReference(string fontFilePath, string faceNameAndStyle, int index)
{
familyName = null;
styleName = null;
faceIndex = index;
uint familyNameHashCode = 0;
uint styleNameHashCode = 0;
filePath = fontFilePath;
int length = faceNameAndStyle.Length;
char[] conversionArray = new char[length];
int readingFlag = 0;
int writingIndex = 0;
for (int i = 0; i < length; i++)
{
char c = faceNameAndStyle[i];
// Read family name
if (readingFlag == 0)
{
bool isSeparator = i + 2 < length && c == ' ' && faceNameAndStyle[i + 1] == '-' && faceNameAndStyle[i + 2] == ' ';
if (isSeparator)
{
readingFlag = 1;
this.familyName = new string(conversionArray, 0, writingIndex);
i += 2;
writingIndex = 0;
continue;
}
familyNameHashCode = (familyNameHashCode << 5) + familyNameHashCode ^ TMP_TextUtilities.ToUpperFast(c);
conversionArray[writingIndex++] = c;
continue;
}
// Read style name
if (readingFlag == 1)
{
styleNameHashCode = (styleNameHashCode << 5) + styleNameHashCode ^ TMP_TextUtilities.ToUpperFast(c);
conversionArray[writingIndex++] = c;
if (i + 1 == length)
this.styleName = new string(conversionArray, 0, writingIndex);
}
}
hashCode = (ulong)styleNameHashCode << 32 | familyNameHashCode;
}
}
void InitializeSystemFontReferenceCache()
{
if (s_SystemFontLookup == null)
s_SystemFontLookup = new Dictionary<ulong, FontReference>();
else
s_SystemFontLookup.Clear();
if (s_SystemFontPaths == null)
s_SystemFontPaths = Font.GetPathsToOSFonts();
for (int i = 0; i < s_SystemFontPaths.Length; i++)
{
// Load font at the given path
FontEngineError error = FontEngine.LoadFontFace(s_SystemFontPaths[i]);
if (error != FontEngineError.Success)
{
Debug.LogWarning("Error [" + error + "] trying to load the font at path [" + s_SystemFontPaths[i] + "].");
continue;
}
// Get font faces and styles for this font
string[] fontFaces = FontEngine.GetFontFaces();
// Iterate over each font face
for (int j = 0; j < fontFaces.Length; j++)
{
FontReference fontRef = new FontReference(s_SystemFontPaths[i], fontFaces[j], j);
if (s_SystemFontLookup.ContainsKey(fontRef.hashCode))
{
//Debug.Log("<color=#FFFF80>[" + i + "]</color> Family Name <color=#FFFF80>[" + fontRef.familyName + "]</color> Style Name <color=#FFFF80>[" + fontRef.styleName + "]</color> Index [" + fontRef.faceIndex + "] HashCode [" + fontRef.hashCode + "] Path [" + fontRef.filePath + "].");
continue;
}
// Add font reference to lookup dictionary
s_SystemFontLookup.Add(fontRef.hashCode, fontRef);
Debug.Log("[" + i + "] Family Name [" + fontRef.familyName + "] Style Name [" + fontRef.styleName + "] Index [" + fontRef.faceIndex + "] HashCode [" + fontRef.hashCode + "] Path [" + fontRef.filePath + "].");
}
// Unload current font face.
FontEngine.UnloadFontFace();
}
}
/// <summary>
///
/// </summary>
/// <param name="familyName"></param>
/// <param name="fontRef"></param>
/// <returns></returns>
public static bool TryGetSystemFontReference(string familyName, out FontReference fontRef)
{
return s_Instance.TryGetSystemFontReferenceInternal(familyName, null, out fontRef);
}
/// <summary>
///
/// </summary>
/// <param name="familyName"></param>
/// <param name="styleName"></param>
/// <param name="fontRef"></param>
/// <returns></returns>
public static bool TryGetSystemFontReference(string familyName, string styleName, out FontReference fontRef)
{
return s_Instance.TryGetSystemFontReferenceInternal(familyName, styleName, out fontRef);
}
bool TryGetSystemFontReferenceInternal(string familyName, string styleName, out FontReference fontRef)
{
if (s_SystemFontLookup == null)
InitializeSystemFontReferenceCache();
fontRef = new FontReference();
// Compute family name hash code
uint familyNameHashCode = TMP_TextUtilities.GetHashCodeCaseInSensitive(familyName);
uint styleNameHashCode = string.IsNullOrEmpty(styleName) ? s_RegularStyleNameHashCode : TMP_TextUtilities.GetHashCodeCaseInSensitive(styleName);
ulong key = (ulong)styleNameHashCode << 32 | familyNameHashCode;
// Lookup font reference
if (s_SystemFontLookup.ContainsKey(key))
{
fontRef = s_SystemFontLookup[key];
return true;
}
// Return if specified family and style name is not found.
if (styleNameHashCode != s_RegularStyleNameHashCode)
return false;
// Return first potential reference for the given family name
foreach (KeyValuePair<ulong, FontReference> pair in s_SystemFontLookup)
{
if (pair.Value.familyName == familyName)
{
fontRef = pair.Value;
return true;
}
}
return false;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: aaf9006568d76504f982305b517fb490
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 7c5c60f80f1a9814eb7e246f2e88afd4
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a4a26a81fe2bc7b42ba0c6aefa6f0cdb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,219 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.TextCore.LowLevel;
namespace TMPro
{
/// <summary>
/// The values used to adjust the position of a glyph or set of glyphs.
/// </summary>
[Serializable]
public struct TMP_GlyphValueRecord
{
/// <summary>
/// The positional adjustment affecting the horizontal bearing X of the glyph.
/// </summary>
public float xPlacement { get { return m_XPlacement; } set { m_XPlacement = value; } }
/// <summary>
/// The positional adjustment affecting the horizontal bearing Y of the glyph.
/// </summary>
public float yPlacement { get { return m_YPlacement; } set { m_YPlacement = value; } }
/// <summary>
/// The positional adjustment affecting the horizontal advance of the glyph.
/// </summary>
public float xAdvance { get { return m_XAdvance; } set { m_XAdvance = value; } }
/// <summary>
/// The positional adjustment affecting the vertical advance of the glyph.
/// </summary>
public float yAdvance { get { return m_YAdvance; } set { m_YAdvance = value; } }
// =============================================
// Private backing fields for public properties.
// =============================================
[SerializeField]
internal float m_XPlacement;
[SerializeField]
internal float m_YPlacement;
[SerializeField]
internal float m_XAdvance;
[SerializeField]
internal float m_YAdvance;
/// <summary>
/// Constructor
/// </summary>
/// <param name="xPlacement">The positional adjustment affecting the horizontal bearing X of the glyph.</param>
/// <param name="yPlacement">The positional adjustment affecting the horizontal bearing Y of the glyph.</param>
/// <param name="xAdvance">The positional adjustment affecting the horizontal advance of the glyph.</param>
/// <param name="yAdvance">The positional adjustment affecting the vertical advance of the glyph.</param>
public TMP_GlyphValueRecord(float xPlacement, float yPlacement, float xAdvance, float yAdvance)
{
m_XPlacement = xPlacement;
m_YPlacement = yPlacement;
m_XAdvance = xAdvance;
m_YAdvance = yAdvance;
}
internal TMP_GlyphValueRecord(GlyphValueRecord_Legacy valueRecord)
{
m_XPlacement = valueRecord.xPlacement;
m_YPlacement = valueRecord.yPlacement;
m_XAdvance = valueRecord.xAdvance;
m_YAdvance = valueRecord.yAdvance;
}
internal TMP_GlyphValueRecord(GlyphValueRecord valueRecord)
{
m_XPlacement = valueRecord.xPlacement;
m_YPlacement = valueRecord.yPlacement;
m_XAdvance = valueRecord.xAdvance;
m_YAdvance = valueRecord.yAdvance;
}
public static TMP_GlyphValueRecord operator +(TMP_GlyphValueRecord a, TMP_GlyphValueRecord b)
{
TMP_GlyphValueRecord c;
c.m_XPlacement = a.xPlacement + b.xPlacement;
c.m_YPlacement = a.yPlacement + b.yPlacement;
c.m_XAdvance = a.xAdvance + b.xAdvance;
c.m_YAdvance = a.yAdvance + b.yAdvance;
return c;
}
}
/// <summary>
/// The positional adjustment values of a glyph.
/// </summary>
[Serializable]
public struct TMP_GlyphAdjustmentRecord
{
/// <summary>
/// The index of the glyph in the source font file.
/// </summary>
public uint glyphIndex { get { return m_GlyphIndex; } set { m_GlyphIndex = value; } }
/// <summary>
/// The GlyphValueRecord contains the positional adjustments of the glyph.
/// </summary>
public TMP_GlyphValueRecord glyphValueRecord { get { return m_GlyphValueRecord; } set { m_GlyphValueRecord = value; } }
// =============================================
// Private backing fields for public properties.
// =============================================
[SerializeField]
internal uint m_GlyphIndex;
[SerializeField]
internal TMP_GlyphValueRecord m_GlyphValueRecord;
/// <summary>
/// Constructor
/// </summary>
/// <param name="glyphIndex">The index of the glyph in the source font file.</param>
/// <param name="glyphValueRecord">The GlyphValueRecord contains the positional adjustments of the glyph.</param>
public TMP_GlyphAdjustmentRecord(uint glyphIndex, TMP_GlyphValueRecord glyphValueRecord)
{
m_GlyphIndex = glyphIndex;
m_GlyphValueRecord = glyphValueRecord;
}
internal TMP_GlyphAdjustmentRecord(GlyphAdjustmentRecord adjustmentRecord)
{
m_GlyphIndex = adjustmentRecord.glyphIndex;
m_GlyphValueRecord = new TMP_GlyphValueRecord(adjustmentRecord.glyphValueRecord);
}
}
/// <summary>
/// The positional adjustment values for a pair of glyphs.
/// </summary>
[Serializable]
public class TMP_GlyphPairAdjustmentRecord
{
/// <summary>
/// Contains the positional adjustment values for the first glyph.
/// </summary>
public TMP_GlyphAdjustmentRecord firstAdjustmentRecord { get { return m_FirstAdjustmentRecord; } set { m_FirstAdjustmentRecord = value; } }
/// <summary>
/// Contains the positional adjustment values for the second glyph.
/// </summary>
public TMP_GlyphAdjustmentRecord secondAdjustmentRecord { get { return m_SecondAdjustmentRecord; } set { m_SecondAdjustmentRecord = value; } }
/// <summary>
///
/// </summary>
public FontFeatureLookupFlags featureLookupFlags { get { return m_FeatureLookupFlags; } set { m_FeatureLookupFlags = value; } }
// =============================================
// Private backing fields for public properties.
// =============================================
[SerializeField]
internal TMP_GlyphAdjustmentRecord m_FirstAdjustmentRecord;
[SerializeField]
internal TMP_GlyphAdjustmentRecord m_SecondAdjustmentRecord;
[SerializeField]
internal FontFeatureLookupFlags m_FeatureLookupFlags;
/// <summary>
/// Constructor
/// </summary>
/// <param name="firstAdjustmentRecord">First glyph adjustment record.</param>
/// <param name="secondAdjustmentRecord">Second glyph adjustment record.</param>
public TMP_GlyphPairAdjustmentRecord(TMP_GlyphAdjustmentRecord firstAdjustmentRecord, TMP_GlyphAdjustmentRecord secondAdjustmentRecord)
{
m_FirstAdjustmentRecord = firstAdjustmentRecord;
m_SecondAdjustmentRecord = secondAdjustmentRecord;
m_FeatureLookupFlags = FontFeatureLookupFlags.None;
}
/// <summary>
/// Internal constructor
/// </summary>
/// <param name="firstAdjustmentRecord"></param>
/// <param name="secondAdjustmentRecord"></param>
internal TMP_GlyphPairAdjustmentRecord(GlyphPairAdjustmentRecord glyphPairAdjustmentRecord)
{
m_FirstAdjustmentRecord = new TMP_GlyphAdjustmentRecord(glyphPairAdjustmentRecord.firstAdjustmentRecord);
m_SecondAdjustmentRecord = new TMP_GlyphAdjustmentRecord(glyphPairAdjustmentRecord.secondAdjustmentRecord);
m_FeatureLookupFlags = FontFeatureLookupFlags.None;
}
}
public struct GlyphPairKey
{
public uint firstGlyphIndex;
public uint secondGlyphIndex;
public uint key;
public GlyphPairKey(uint firstGlyphIndex, uint secondGlyphIndex)
{
this.firstGlyphIndex = firstGlyphIndex;
this.secondGlyphIndex = secondGlyphIndex;
key = secondGlyphIndex << 16 | firstGlyphIndex;
}
internal GlyphPairKey(TMP_GlyphPairAdjustmentRecord record)
{
firstGlyphIndex = record.firstAdjustmentRecord.glyphIndex;
secondGlyphIndex = record.secondAdjustmentRecord.glyphIndex;
key = secondGlyphIndex << 16 | firstGlyphIndex;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3d7de7dd98a0728419392bf8b2f46a37
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5f332b1d4d7bb2d4a921f0787a93e5e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {fileID: 2800000, guid: 3ee40aa79cd242a5b53b0b0ca4f13f0f, type: 3}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
using UnityEngine;
using System.Collections;
namespace TMPro
{
/// <summary>
/// Custom text input validator where user can implement their own custom character validation.
/// </summary>
[System.Serializable]
public abstract class TMP_InputValidator : ScriptableObject
{
public abstract char Validate(ref string text, ref int pos, char ch);
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d98fc3935c2bc5f41bf9090a00b3f5f2
timeCreated: 1473021069
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More