本文整理汇总了C#中SymbolStyle类的典型用法代码示例。如果您正苦于以下问题:C# SymbolStyle类的具体用法?C# SymbolStyle怎么用?C# SymbolStyle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SymbolStyle类属于命名空间,在下文中一共展示了SymbolStyle类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Print
public void Print (string text, Color32 color, BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols,
bool encoding, SymbolStyle symbolStyle, Alignment alignment, int lineWidth, bool premultiply)
#endif
{
if (mReplacement != null)
{
mReplacement.Print(text, color, verts, uvs, cols, encoding, symbolStyle, alignment, lineWidth, premultiply);
}
else if (mFont != null && text != null)
{
if (!mFont.isValid)
{
Debug.LogError("Attempting to print using an invalid font!");
return;
}
mColors.Clear();
mColors.Add(color);
Vector2 scale = mFont.charSize > 0 ? new Vector2(1f / mFont.charSize, 1f / mFont.charSize) : Vector2.one;
int indexOffset = verts.size;
int maxX = 0;
int x = 0;
int y = 0;
int prev = 0;
int lineHeight = (mFont.charSize + mSpacingY);
Vector3 v0 = Vector3.zero, v1 = Vector3.zero;
Vector2 u0 = Vector2.zero, u1 = Vector2.zero;
float invX = uvRect.width / mFont.texWidth;
float invY = mUVRect.height / mFont.texHeight;
int textLength = text.Length;
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols && sprite != null;
for (int i = 0; i < textLength; ++i)
{
char c = text[i];
if (c == '\n')
{
if (x > maxX) maxX = x;
if (alignment != Alignment.Left)
{
Align(verts, indexOffset, alignment, x, lineWidth);
indexOffset = verts.size;
}
x = 0;
y += lineHeight;
prev = 0;
continue;
}
if (c < ' ')
{
prev = 0;
continue;
}
if (encoding && c == '[')
{
int retVal = NGUITools.ParseSymbol(text, i, mColors, premultiply);
if (retVal > 0)
{
color = mColors[mColors.Count - 1];
i += retVal - 1;
continue;
}
}
// See if there is a symbol matching this text
BMSymbol symbol = useSymbols ? MatchSymbol(text, i, textLength) : null;
if (symbol == null || !symbol.Validate(atlas))
{
BMGlyph glyph = mFont.GetGlyph(c);
if (glyph == null) continue;
if (prev != 0) x += glyph.GetKerning(prev);
if (c == ' ')
{
x += mSpacingX + glyph.advance;
prev = c;
continue;
}
v0.x = scale.x * (x + glyph.offsetX);
v0.y = -scale.y * (y + glyph.offsetY);
v1.x = v0.x + scale.x * glyph.width;
v1.y = v0.y - scale.y * glyph.height;
u0.x = mUVRect.xMin + invX * glyph.x;
u0.y = mUVRect.yMax - invY * glyph.y;
u1.x = u0.x + invX * glyph.width;
u1.y = u0.y - invY * glyph.height;
//.........这里部分代码省略.........
示例2: WrapText
/// <summary>
/// Text wrapping functionality. The 'maxWidth' should be in local coordinates (take pixels and divide them by transform's scale).
/// </summary>
public string WrapText(string text, float maxWidth, int maxLineCount, bool encoding, SymbolStyle symbolStyle)
{
if (mReplacement != null) return mReplacement.WrapText(text, maxWidth, maxLineCount, encoding, symbolStyle);
// Width of the line in pixels
int lineWidth = Mathf.RoundToInt(maxWidth * size);
if (lineWidth < 1) return text;
StringBuilder sb = new StringBuilder();
int textLength = text.Length;
int remainingWidth = lineWidth;
int previousChar = 0;
int start = 0;
int offset = 0;
bool lineIsEmpty = true;
bool multiline = (maxLineCount != 1);
int lineCount = 1;
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols;
// Run through all characters
for (; offset < textLength; ++offset)
{
char ch = text[offset];
// New line character -- start a new line
if (ch == '\n')
{
if (!multiline || lineCount == maxLineCount ) break;
remainingWidth = lineWidth;
// Add the previous word to the final string
if (start < offset) sb.Append(text.Substring(start, offset - start + 1));
else sb.Append(ch);
lineIsEmpty = true;
++lineCount;
start = offset + 1;
previousChar = 0;
continue;
}
// If this marks the end of a word, add it to the final string.
if (ch == ' ' && previousChar != ' ' && start < offset)
{
sb.Append(text.Substring(start, offset - start + 1));
lineIsEmpty = false;
start = offset + 1;
previousChar = ch;
}
// When encoded symbols such as [RrGgBb] or [-] are encountered, skip past them
if (encoding && ch == '[')
{
if (offset + 2 < textLength)
{
if (text[offset + 1] == '-' && text[offset + 2] == ']')
{
offset += 2;
continue;
}
else if (offset + 7 < textLength && text[offset + 7] == ']')
{
if (NGUITools.EncodeColor(NGUITools.ParseColor(text, offset + 1)) == text.Substring(offset + 1, 6).ToUpper())
{
offset += 7;
continue;
}
}
}
}
// See if there is a symbol matching this text
BMSymbol symbol = useSymbols ? MatchSymbol(text, offset, textLength) : null;
// Calculate how wide this symbol or character is going to be
int glyphWidth = mSpacingX;
if (symbol != null && symbol.Validate(atlas))
{
glyphWidth += symbol.advance;
}
else
{
// Find the glyph for this character
BMGlyph glyph = (symbol == null) ? mFont.GetGlyph(ch) : null;
if (glyph != null)
{
glyphWidth += (previousChar != 0) ? glyph.advance + glyph.GetKerning(previousChar) : glyph.advance;
}
else continue;
}
// Remaining width after this glyph gets printed
remainingWidth -= glyphWidth;
//.........这里部分代码省略.........
示例3: CalculatePrintedSize
/// <summary>
/// Get the printed size of the specified string. The returned value is in local coordinates. Multiply by transform's scale to get pixels.
/// </summary>
public Vector2 CalculatePrintedSize (string text, bool encoding, SymbolStyle symbolStyle)
{
if (mReplacement != null) return mReplacement.CalculatePrintedSize(text, encoding, symbolStyle);
Vector2 v = Vector2.zero;
if (mFont != null && mFont.isValid && !string.IsNullOrEmpty(text))
{
if (encoding) text = NGUITools.StripSymbols(text);
int length = text.Length;
int maxX = 0;
int x = 0;
int y = 0;
int prev = 0;
int lineHeight = (mFont.charSize + mSpacingY);
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols;
for (int i = 0; i < length; ++i)
{
char c = text[i];
// Start a new line
if (c == '\n')
{
if (x > maxX) maxX = x;
x = 0;
y += lineHeight;
prev = 0;
continue;
}
// Skip invalid characters
if (c < ' ') { prev = 0; continue; }
// See if there is a symbol matching this text
BMSymbol symbol = useSymbols ? MatchSymbol(text, i, length) : null;
if (symbol == null || !symbol.Validate(atlas))
{
// Get the glyph for this character
BMGlyph glyph = mFont.GetGlyph(c);
if (glyph != null)
{
x += mSpacingX + ((prev != 0) ? glyph.advance + glyph.GetKerning(prev) : glyph.advance);
prev = c;
}
}
else
{
// Symbol found -- use it
x += mSpacingX + symbol.advance;
i += symbol.length - 1;
prev = 0;
}
}
// Convert from pixel coordinates to local coordinates
float scale = (mFont.charSize > 0) ? 1f / mFont.charSize : 1f;
v.x = scale * ((x > maxX) ? x : maxX);
v.y = scale * (y + lineHeight);
}
return v;
}
示例4: GetEndOfLineThatFits
/// <summary>
/// Different line wrapping functionality -- contributed by MightyM.
/// http://www.tasharen.com/forum/index.php?topic=1049.0
/// </summary>
public string GetEndOfLineThatFits (string text, float maxWidth, bool encoding, SymbolStyle symbolStyle)
{
if (mReplacement != null) return mReplacement.GetEndOfLineThatFits(text, maxWidth, encoding, symbolStyle);
int lineWidth = Mathf.RoundToInt(maxWidth * size);
if (lineWidth < 1) return text;
int textLength = text.Length;
int remainingWidth = lineWidth;
BMGlyph followingGlyph = null;
int currentCharacterIndex = textLength;
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols;
while (currentCharacterIndex > 0 && remainingWidth > 0)
{
char currentCharacter = text[--currentCharacterIndex];
// See if there is a symbol matching this text
BMSymbol symbol = useSymbols ? MatchSymbol(text, currentCharacterIndex, textLength) : null;
// Calculate how wide this symbol or character is going to be
int glyphWidth = mSpacingX;
if (symbol != null && symbol.Validate(atlas))
{
glyphWidth += symbol.advance;
}
else
{
// Find the glyph for this character
BMGlyph glyph = mFont.GetGlyph(currentCharacter);
if (glyph != null)
{
glyphWidth += glyph.advance + ((followingGlyph == null) ? 0 : followingGlyph.GetKerning(currentCharacter));
followingGlyph = glyph;
}
else
{
followingGlyph = null;
continue;
}
}
// Remaining width after this glyph gets printed
remainingWidth -= glyphWidth;
}
if (remainingWidth < 0) ++currentCharacterIndex;
return text.Substring(currentCharacterIndex, textLength - currentCharacterIndex);
}
示例5: CalculatePrintedSize
/// <summary>
/// Get the printed size of the specified string. The returned value is in pixels.
/// </summary>
public Vector2 CalculatePrintedSize (string text, bool encoding, SymbolStyle symbolStyle)
{
if (mReplacement != null) return mReplacement.CalculatePrintedSize(text, encoding, symbolStyle);
Vector2 v = Vector2.zero;
bool dynamic = isDynamic;
#if DYNAMIC_FONT
if (dynamic || (mFont != null && mFont.isValid && !string.IsNullOrEmpty(text)))
#else
if (mFont != null && mFont.isValid && !string.IsNullOrEmpty(text))
#endif
{
if (encoding) text = NGUITools.StripSymbols(text);
#if DYNAMIC_FONT
if (mDynamicFont != null) mDynamicFont.RequestCharactersInTexture(text, mDynamicFontSize, mDynamicFontStyle);
#endif
int length = text.Length;
int maxX = 0;
int x = 0;
int y = 0;
int prev = 0;
int fs = size;
int lineHeight = (fs + mSpacingY);
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols;
for (int i = 0; i < length; ++i)
{
char c = text[i];
// Start a new line
if (c == '\n')
{
if (x > maxX) maxX = x;
x = 0;
y += lineHeight;
prev = 0;
continue;
}
// Skip invalid characters
if (c < ' ') { prev = 0; continue; }
if (!dynamic)
{
// See if there is a symbol matching this text
BMSymbol symbol = useSymbols ? MatchSymbol(text, i, length) : null;
if (symbol == null)
{
// Get the glyph for this character
BMGlyph glyph = mFont.GetGlyph(c);
if (glyph != null)
{
x += mSpacingX + ((prev != 0) ? glyph.advance + glyph.GetKerning(prev) : glyph.advance);
prev = c;
}
}
else
{
// Symbol found -- use it
x += mSpacingX + symbol.width;
i += symbol.length - 1;
prev = 0;
}
}
#if DYNAMIC_FONT
else
{
if (mDynamicFont.GetCharacterInfo(c, out mChar, mDynamicFontSize, mDynamicFontStyle))
x += (int)(mSpacingX + mChar.width);
}
#endif
}
// Convert from pixel coordinates to local coordinates
v.x = ((x > maxX) ? x : maxX);
v.y = (y + lineHeight);
}
return v;
}
示例6: GetEndOfLineThatFits
/// <summary>
/// Different line wrapping functionality -- contributed by MightyM.
/// http://www.tasharen.com/forum/index.php?topic=1049.0
/// </summary>
public string GetEndOfLineThatFits (string text, float maxWidth, bool encoding, SymbolStyle symbolStyle)
{
if (mReplacement != null) return mReplacement.GetEndOfLineThatFits(text, maxWidth, encoding, symbolStyle);
int lineWidth = Mathf.RoundToInt(maxWidth);
if (lineWidth < 1) return text;
#if DYNAMIC_FONT
if (mDynamicFont != null) mDynamicFont.RequestCharactersInTexture(text, mDynamicFontSize, mDynamicFontStyle);
#endif
int textLength = text.Length;
int remainingWidth = lineWidth;
BMGlyph followingGlyph = null;
int currentCharacterIndex = textLength;
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols;
bool dynamic = isDynamic;
while (currentCharacterIndex > 0 && remainingWidth > 0)
{
char currentCharacter = text[--currentCharacterIndex];
// See if there is a symbol matching this text
BMSymbol symbol = useSymbols ? MatchSymbol(text, currentCharacterIndex, textLength) : null;
// Calculate how wide this symbol or character is going to be
int glyphWidth = mSpacingX;
if (!dynamic)
{
if (symbol != null)
{
glyphWidth += symbol.advance;
}
else
{
// Find the glyph for this character
BMGlyph glyph = mFont.GetGlyph(currentCharacter);
if (glyph != null)
{
glyphWidth += glyph.advance + ((followingGlyph == null) ? 0 : followingGlyph.GetKerning(currentCharacter));
followingGlyph = glyph;
}
else
{
followingGlyph = null;
continue;
}
}
}
#if DYNAMIC_FONT
else
{
if (mDynamicFont.GetCharacterInfo(currentCharacter, out mChar, mDynamicFontSize, mDynamicFontStyle))
glyphWidth += (int)mChar.width;
}
#endif
// Remaining width after this glyph gets printed
remainingWidth -= glyphWidth;
}
if (remainingWidth < 0) ++currentCharacterIndex;
return text.Substring(currentCharacterIndex, textLength - currentCharacterIndex);
}
示例7: CalculateOffsetToFit
/// <summary>
/// Calculate the character index offset required to print the end of the specified text.
/// Originally contributed by MightyM: http://www.tasharen.com/forum/index.php?topic=1049.0
/// </summary>
public int CalculateOffsetToFit (string text, int size, int lineWidth, bool encoding, SymbolStyle symbolStyle)
{
if (lineWidth < 1) return 0;
if (mReplacement != null) return mReplacement.CalculateOffsetToFit(text, size, lineWidth, encoding, symbolStyle);
#if DYNAMIC_FONT
if (isDynamic) return NGUIText.CalculateOffsetToFit(text, mDynamicFont, size, mDynamicFontStyle, lineWidth);
#endif
int textLength = text.Length;
int remainingWidth = lineWidth;
BMGlyph followingGlyph = null;
int currentCharacterIndex = textLength;
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols;
while (currentCharacterIndex > 0 && remainingWidth > 0)
{
char currentCharacter = text[--currentCharacterIndex];
// See if there is a symbol matching this text
BMSymbol symbol = useSymbols ? MatchSymbol(text, currentCharacterIndex, textLength) : null;
// Calculate how wide this symbol or character is going to be
int glyphWidth = mSpacingX;
if (symbol != null)
{
glyphWidth += symbol.advance;
}
else
{
// Find the glyph for this character
BMGlyph glyph = mFont.GetGlyph(currentCharacter);
if (glyph != null)
{
glyphWidth += glyph.advance + ((followingGlyph == null) ? 0 : followingGlyph.GetKerning(currentCharacter));
followingGlyph = glyph;
}
else
{
followingGlyph = null;
continue;
}
}
// Remaining width after this glyph gets printed
remainingWidth -= glyphWidth;
}
if (remainingWidth < 0) ++currentCharacterIndex;
return currentCharacterIndex;
}
示例8: WrapText
/// <summary>
/// Text wrapping functionality. The 'width' and 'height' should be in pixels.
/// Returns 'true' if the specified text was able to fit into the provided dimensions, 'false' otherwise.
/// </summary>
public bool WrapText (string text, int size, out string finalText, int width, int height, int maxLines, bool encoding, SymbolStyle symbolStyle)
{
if (mReplacement != null)
{
return mReplacement.WrapText(text, size, out finalText, width, height, maxLines, encoding, symbolStyle);
}
#if DYNAMIC_FONT
if (isDynamic)
return NGUIText.WrapText(text, mDynamicFont, size, mDynamicFontStyle, width, height, maxLines, encoding, out finalText);
#endif
if (width < 1 || height < 1)
{
finalText = "";
return false;
}
if (maxLines > 0) height = Mathf.Min(height, size * maxLines);
int maxLineCount = (maxLines > 0) ? maxLines : 1000000;
maxLineCount = Mathf.Min(maxLineCount, height / size);
if (maxLineCount == 0)
{
finalText = "";
return false;
}
StringBuilder sb = new StringBuilder();
int textLength = text.Length;
int remainingWidth = width;
int previousChar = 0;
int start = 0;
int offset = 0;
int lineCount = 1;
bool lineIsEmpty = true;
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols;
// Run through all characters
for (; offset < textLength; ++offset)
{
char ch = text[offset];
// New line character -- start a new line
if (ch == '\n')
{
if (lineCount == maxLineCount) break;
remainingWidth = width;
// Add the previous word to the final string
if (start < offset) sb.Append(text.Substring(start, offset - start + 1));
else sb.Append(ch);
lineIsEmpty = true;
++lineCount;
start = offset + 1;
previousChar = 0;
continue;
}
// If this marks the end of a word, add it to the final string.
if (ch == ' ' && previousChar != ' ' && start < offset)
{
sb.Append(text.Substring(start, offset - start + 1));
lineIsEmpty = false;
start = offset + 1;
previousChar = ch;
}
// When encoded symbols such as [RrGgBb] or [-] are encountered, skip past them
if (NGUIText.ParseSymbol(text, ref offset)) { --offset; continue; }
// See if there is a symbol matching this text
BMSymbol symbol = useSymbols ? MatchSymbol(text, offset, textLength) : null;
// Calculate how wide this symbol or character is going to be
int glyphWidth = mSpacingX;
if (symbol != null)
{
glyphWidth += symbol.advance;
}
else
{
// Find the glyph for this character
BMGlyph glyph = (symbol == null) ? mFont.GetGlyph(ch) : null;
if (glyph != null) glyphWidth += (previousChar != 0) ?
glyph.advance + glyph.GetKerning(previousChar) : glyph.advance;
else continue;
}
// Remaining width after this glyph gets printed
remainingWidth -= glyphWidth;
//.........这里部分代码省略.........
示例9: GetEndOfLineThatFits
/// <summary>
/// Get the end of line that would fit into a field of given width.
/// </summary>
public string GetEndOfLineThatFits (string text, int size, int lineWidth, bool encoding, SymbolStyle symbolStyle)
{
int textLength = text.Length;
int offset = CalculateOffsetToFit(text, size, lineWidth, encoding, symbolStyle);
return text.Substring(offset, textLength - offset);
}
示例10: WrapText
/// <summary>
/// Text wrapping functionality. The 'maxWidth' should be in local coordinates (take pixels and divide them by transform's scale).
/// </summary>
public bool WrapText (string text, out string finalText, float width, float height, int lines, bool encoding, SymbolStyle symbolStyle)
{
if (mReplacement != null)
{
return mReplacement.WrapText(text, out finalText, width, height, lines, encoding, symbolStyle);
}
// Zero means unlimited
if (width == 0f) width = 100000f;
if (height == 0f) height = 100000f;
// Width and height of the line in pixels
int lineWidth = Mathf.FloorToInt(width * size);
int lineHeight = Mathf.FloorToInt(height * size);
if (lineWidth < 1 || lineHeight < 1)
{
finalText = "";
return false;
}
int maxLineCount = (lines > 0) ? lines : 999999;
if (height != 0f)
{
maxLineCount = Mathf.Min(maxLineCount, Mathf.FloorToInt(height));
if (maxLineCount == 0)
{
finalText = "";
return false;
}
}
#if DYNAMIC_FONT
if (mDynamicFont != null) mDynamicFont.RequestCharactersInTexture(text, mDynamicFontSize);
#endif
StringBuilder sb = new StringBuilder();
int textLength = text.Length;
int remainingWidth = lineWidth;
int previousChar = 0;
int start = 0;
int offset = 0;
bool lineIsEmpty = true;
bool multiline = (lines != 1);
int lineCount = 1;
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols;
bool dynamic = isDynamic;
// Run through all characters
for (; offset < textLength; ++offset)
{
char ch = text[offset];
// New line character -- start a new line
if (ch == '\n')
{
if (!multiline || lineCount == maxLineCount) break;
remainingWidth = lineWidth;
// Add the previous word to the final string
if (start < offset) sb.Append(text.Substring(start, offset - start + 1));
else sb.Append(ch);
lineIsEmpty = true;
++lineCount;
start = offset + 1;
previousChar = 0;
continue;
}
// If this marks the end of a word, add it to the final string.
if (ch == ' ' && previousChar != ' ' && start < offset)
{
sb.Append(text.Substring(start, offset - start + 1));
lineIsEmpty = false;
start = offset + 1;
previousChar = ch;
}
// When encoded symbols such as [RrGgBb] or [-] are encountered, skip past them
if (encoding && ch == '[')
{
if (offset + 2 < textLength)
{
if (text[offset + 1] == '-' && text[offset + 2] == ']')
{
offset += 2;
continue;
}
else if (offset + 7 < textLength && text[offset + 7] == ']')
{
if (NGUITools.EncodeColor(NGUITools.ParseColor(text, offset + 1)) == text.Substring(offset + 1, 6).ToUpper())
{
offset += 7;
continue;
//.........这里部分代码省略.........
示例11: CalculateSymbolStyle
private void CalculateSymbolStyle(SymbolStyle style, SymbolStyle min, SymbolStyle max, double value)
{
double dFrac = Fraction(value);
style.BitmapId = (dFrac > 0.5) ? min.BitmapId : max.BitmapId;
style.SymbolOffset = (dFrac > 0.5 ? min.SymbolOffset : max.SymbolOffset);
//We don't interpolate the offset but let it follow the symbol instead
style.SymbolScale = InterpolateDouble(min.SymbolScale, max.SymbolScale, value);
}
示例12: Equals
public bool Equals(SymbolStyle symbolStyle)
{
if (!base.Equals(symbolStyle))
{
return false;
}
if ((Symbol == null) ^ (symbolStyle.Symbol == null))
{
return false;
}
if (Symbol != null && !Symbol.Equals(symbolStyle.Symbol))
{
return false;
}
if (!SymbolScale.Equals(SymbolScale))
{
return false;
}
if ((SymbolOffset == null) ^ (symbolStyle.SymbolOffset == null))
{
return false;
}
if ((SymbolOffset != null) && (!SymbolOffset.Equals(symbolStyle.SymbolOffset)))
{
return false;
}
if (SymbolRotation != symbolStyle.SymbolRotation)
{
return false;
}
if (UnitType != symbolStyle.UnitType)
{
return false;
}
if (SymbolType != symbolStyle.SymbolType)
{
return false;
}
if (Opacity != symbolStyle.Opacity)
{
return false;
}
if (Width != symbolStyle.Width)
{
return false;
}
if (Height != symbolStyle.Height)
{
return false;
}
return true;
}
示例13: Print
/// <summary>
/// Print the specified text into the buffers.
/// Note: 'lineWidth' parameter should be in pixels.
/// </summary>
public void Print(string text, Color32 color, BetterList<Vector3> verts, BetterList<Vector2> uvs, BetterList<Color32> cols,
bool encoding, SymbolStyle symbolStyle, Alignment alignment, int lineWidth, bool premultiply)
{
if (mReplacement != null)
{
mReplacement.Print(text, color, verts, uvs, cols, encoding, symbolStyle, alignment, lineWidth, premultiply);
}
else if (text != null)
{
if (!isValid)
{
Debug.LogError("Attempting to print using an invalid font!");
return;
}
// Make sure the characters are present in the dynamic font before printing them
bool dynamic = isDynamic;
#if !UNITY_3_5
if (dynamic)
{
mDynamicFont.textureRebuildCallback = OnFontChanged;
mDynamicFont.RequestCharactersInTexture(text, mDynamicFontSize, mDynamicFontStyle);
mDynamicFont.textureRebuildCallback = null;
}
#endif
mColors.Clear();
mColors.Add(color);
int fs = size;
Vector2 invSize = fs > 0 ? new Vector2(1f / fs, 1f / fs) : Vector2.one;
int indexOffset = verts.size;
int maxX = 0;
int x = 0;
int y = 0;
int prev = 0;
int lineHeight = (fs + mSpacingY);
Vector3 v0 = Vector3.zero, v1 = Vector3.zero;
Vector2 u0 = Vector2.zero, u1 = Vector2.zero;
float invX = uvRect.width / mFont.texWidth;
float invY = mUVRect.height / mFont.texHeight;
int textLength = text.Length;
bool useSymbols = encoding && symbolStyle != SymbolStyle.None && hasSymbols && (dynamicSymbolsFont == null? sprite != null : dynamicSymbolsFont.sprite != null) ;
List<int> dynamicSymblosIndexs = new List<int>(); //need to record all dynamic symblo verts index.
List<Vector2> dynamicSymblosPosBase = new List<Vector2>();
List<string> dynamicSymblosKeyName = new List<string>();
for (int i = 0; i < textLength; ++i)
{
char c = text[i];
if (c == '\n')
{
if (x > maxX) maxX = x;
if (alignment != Alignment.Left)
{
Align(verts, indexOffset, alignment, x, lineWidth);
indexOffset = verts.size;
}
x = 0;
y += lineHeight;
prev = 0;
continue;
}
if (c < ' ')
{
prev = 0;
continue;
}
if (encoding && c == '[')
{
int retVal = NGUITools.ParseSymbol(text, i, mColors, premultiply);
if (retVal > 0)
{
color = mColors[mColors.Count - 1];
i += retVal - 1;
continue;
}
}
if (!dynamic)
{
// See if there is a symbol matching this text
BMSymbol symbol = useSymbols ? MatchSymbol(text, i, textLength) : null;
if (symbol == null)
{
BMGlyph glyph = mFont.GetGlyph(c);
if (glyph == null) continue;
if (prev != 0) x += glyph.GetKerning(prev);
//.........这里部分代码省略.........