// Token: 0x06000339 RID: 825 RVA: 0x00025A5C File Offset: 0x00023C5C public string WrapText(string text, float maxWidth, int maxLineCount, bool encoding, UIFont.SymbolStyle symbolStyle) { if (this.mReplacement != null) { return(this.mReplacement.WrapText(text, maxWidth, maxLineCount, encoding, symbolStyle)); } int num = Mathf.RoundToInt(maxWidth * (float)this.size); if (num < 1) { return(text); } StringBuilder stringBuilder = new StringBuilder(); int length = text.Length; int num2 = num; int num3 = 0; int num4 = 0; int i = 0; bool flag = true; bool flag2 = maxLineCount != 1; int num5 = 1; bool flag3 = encoding && symbolStyle != UIFont.SymbolStyle.None && this.hasSymbols; bool isDynamic = this.isDynamic; if (isDynamic) { this.mDynamicFont.textureRebuildCallback = new Font.FontTextureRebuildCallback(this.OnFontChanged); this.mDynamicFont.RequestCharactersInTexture(text, this.mDynamicFontSize, this.mDynamicFontStyle); this.mDynamicFont.textureRebuildCallback = null; } while (i < length) { char c = text[i]; if (c == '\n') { if (!flag2 || num5 == maxLineCount) { break; } num2 = num; if (num4 < i) { stringBuilder.Append(text.Substring(num4, i - num4 + 1)); } else { stringBuilder.Append(c); } flag = true; num5++; num4 = i + 1; num3 = 0; } else { if (c == ' ' && num3 != 32 && num4 < i) { stringBuilder.Append(text.Substring(num4, i - num4 + 1)); flag = false; num4 = i + 1; num3 = (int)c; } if (encoding && c == '[' && i + 2 < length) { if (text[i + 1] == '-' && text[i + 2] == ']') { i += 2; goto IL_3E7; } if (i + 7 < length && text[i + 7] == ']' && NGUITools.EncodeColor(NGUITools.ParseColor(text, i + 1)) == text.Substring(i + 1, 6).ToUpper()) { i += 7; goto IL_3E7; } } BMSymbol bmsymbol = (!flag3) ? null : this.MatchSymbol(text, i, length); int num6 = this.mSpacingX; if (!isDynamic) { if (bmsymbol != null) { num6 += bmsymbol.advance; } else { BMGlyph bmglyph = (bmsymbol != null) ? null : this.mFont.GetGlyph((int)c); if (bmglyph == null) { goto IL_3E7; } num6 += ((num3 == 0) ? bmglyph.advance : (bmglyph.advance + bmglyph.GetKerning(num3))); } } else if (this.mDynamicFont.GetCharacterInfo(c, out UIFont.mChar, this.mDynamicFontSize, this.mDynamicFontStyle)) { num6 += Mathf.RoundToInt(UIFont.mChar.width); } num2 -= num6; if (num2 < 0) { if (flag || !flag2 || num5 == maxLineCount) { stringBuilder.Append(text.Substring(num4, Mathf.Max(0, i - num4))); if (!flag2 || num5 == maxLineCount) { num4 = i; break; } UIFont.EndLine(ref stringBuilder); flag = true; num5++; if (c == ' ') { num4 = i + 1; num2 = num; } else { num4 = i; num2 = num - num6; } num3 = 0; } else { while (num4 < length && text[num4] == ' ') { num4++; } flag = true; num2 = num; i = num4 - 1; num3 = 0; if (!flag2 || num5 == maxLineCount) { break; } num5++; UIFont.EndLine(ref stringBuilder); goto IL_3E7; } } else { num3 = (int)c; } if (!isDynamic && bmsymbol != null) { i += bmsymbol.length - 1; num3 = 0; } } IL_3E7: i++; } if (num4 < i) { stringBuilder.Append(text.Substring(num4, i - num4)); } return(stringBuilder.ToString()); }