private void Align(BetterList <Vector3> verts, int indexOffset, UIFont.Alignment alignment, int x, int lineWidth) { if (alignment != UIFont.Alignment.Left) { int size = this.size; if (size > 0) { float num; if (alignment == UIFont.Alignment.Right) { num = (float)Mathf.RoundToInt((float)(lineWidth - x)); if (num < 0f) { num = 0f; } num /= (float)this.size; } else { num = (float)Mathf.RoundToInt((float)(lineWidth - x) * 0.5f); if (num < 0f) { num = 0f; } num /= (float)this.size; if ((lineWidth & 1) == 1) { num += 0.5f / (float)size; } } for (int i = indexOffset; i < verts.size; i++) { Vector3 vector = verts.buffer[i]; vector.x += num; verts.buffer[i] = vector; } } } }
// Token: 0x0600033E RID: 830 RVA: 0x00025F34 File Offset: 0x00024134 public void Print(string text, Color32 color, BetterList <Vector3> verts, BetterList <Vector2> uvs, BetterList <Color32> cols, bool encoding, UIFont.SymbolStyle symbolStyle, UIFont.Alignment alignment, int lineWidth, bool premultiply) { if (this.mReplacement != null) { this.mReplacement.Print(text, color, verts, uvs, cols, encoding, symbolStyle, alignment, lineWidth, premultiply); } else if (text != null) { if (!this.isValid) { Debug.LogError("Attempting to print using an invalid font!"); return; } 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; } this.mColors.Clear(); this.mColors.Add(color); int size = this.size; Vector2 vector = (size <= 0) ? Vector2.one : new Vector2(1f / (float)size, 1f / (float)size); int size2 = verts.size; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = size + this.mSpacingY; Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; Vector2 zero3 = Vector2.zero; Vector2 zero4 = Vector2.zero; float num6 = this.uvRect.width / (float)this.mFont.texWidth; float num7 = this.mUVRect.height / (float)this.mFont.texHeight; int length = text.Length; bool flag = encoding && symbolStyle != UIFont.SymbolStyle.None && this.hasSymbols && this.sprite != null; for (int i = 0; i < length; i++) { char c = text[i]; if (c == '\n') { if (num2 > num) { num = num2; } if (alignment != UIFont.Alignment.Left) { this.Align(verts, size2, alignment, num2, lineWidth); size2 = verts.size; } num2 = 0; num3 += num5; num4 = 0; } else if (c < ' ') { num4 = 0; } else { if (encoding && c == '[') { int num8 = NGUITools.ParseSymbol(text, i, this.mColors, premultiply); if (num8 > 0) { color = this.mColors[this.mColors.Count - 1]; i += num8 - 1; goto IL_96C; } } if (!isDynamic) { BMSymbol bmsymbol = (!flag) ? null : this.MatchSymbol(text, i, length); if (bmsymbol == null) { BMGlyph glyph = this.mFont.GetGlyph((int)c); if (glyph == null) { goto IL_96C; } if (num4 != 0) { num2 += glyph.GetKerning(num4); } if (c == ' ') { num2 += this.mSpacingX + glyph.advance; num4 = (int)c; goto IL_96C; } zero.x = vector.x * (float)(num2 + glyph.offsetX); zero.y = -vector.y * (float)(num3 + glyph.offsetY); zero2.x = zero.x + vector.x * (float)glyph.width; zero2.y = zero.y - vector.y * (float)glyph.height; zero3.x = this.mUVRect.xMin + num6 * (float)glyph.x; zero3.y = this.mUVRect.yMax - num7 * (float)glyph.y; zero4.x = zero3.x + num6 * (float)glyph.width; zero4.y = zero3.y - num7 * (float)glyph.height; num2 += this.mSpacingX + glyph.advance; num4 = (int)c; if (glyph.channel == 0 || glyph.channel == 15) { for (int j = 0; j < 4; j++) { cols.Add(color); } } else { Color color2 = color; color2 *= 0.49f; switch (glyph.channel) { case 1: color2.b += 0.51f; break; case 2: color2.g += 0.51f; break; case 4: color2.r += 0.51f; break; case 8: color2.a += 0.51f; break; } for (int k = 0; k < 4; k++) { cols.Add(color2); } } } else { zero.x = vector.x * (float)(num2 + bmsymbol.offsetX); zero.y = -vector.y * (float)(num3 + bmsymbol.offsetY); zero2.x = zero.x + vector.x * (float)bmsymbol.width; zero2.y = zero.y - vector.y * (float)bmsymbol.height; Rect uvRect = bmsymbol.uvRect; zero3.x = uvRect.xMin; zero3.y = uvRect.yMax; zero4.x = uvRect.xMax; zero4.y = uvRect.yMin; num2 += this.mSpacingX + bmsymbol.advance; i += bmsymbol.length - 1; num4 = 0; if (symbolStyle == UIFont.SymbolStyle.Colored) { for (int l = 0; l < 4; l++) { cols.Add(color); } } else { Color32 item = Color.white; item.a = color.a; for (int m = 0; m < 4; m++) { cols.Add(item); } } } verts.Add(new Vector3(zero2.x, zero.y)); verts.Add(new Vector3(zero2.x, zero2.y)); verts.Add(new Vector3(zero.x, zero2.y)); verts.Add(new Vector3(zero.x, zero.y)); uvs.Add(new Vector2(zero4.x, zero3.y)); uvs.Add(new Vector2(zero4.x, zero4.y)); uvs.Add(new Vector2(zero3.x, zero4.y)); uvs.Add(new Vector2(zero3.x, zero3.y)); } else if (this.mDynamicFont.GetCharacterInfo(c, out UIFont.mChar, this.mDynamicFontSize, this.mDynamicFontStyle)) { zero.x = vector.x * ((float)num2 + UIFont.mChar.vert.xMin); zero.y = -vector.y * ((float)num3 - UIFont.mChar.vert.yMax + this.mDynamicFontOffset); zero2.x = zero.x + vector.x * UIFont.mChar.vert.width; zero2.y = zero.y - vector.y * UIFont.mChar.vert.height; zero3.x = UIFont.mChar.uv.xMin; zero3.y = UIFont.mChar.uv.yMin; zero4.x = UIFont.mChar.uv.xMax; zero4.y = UIFont.mChar.uv.yMax; num2 += this.mSpacingX + (int)UIFont.mChar.width; for (int n = 0; n < 4; n++) { cols.Add(color); } if (UIFont.mChar.flipped) { uvs.Add(new Vector2(zero3.x, zero4.y)); uvs.Add(new Vector2(zero3.x, zero3.y)); uvs.Add(new Vector2(zero4.x, zero3.y)); uvs.Add(new Vector2(zero4.x, zero4.y)); } else { uvs.Add(new Vector2(zero4.x, zero3.y)); uvs.Add(new Vector2(zero3.x, zero3.y)); uvs.Add(new Vector2(zero3.x, zero4.y)); uvs.Add(new Vector2(zero4.x, zero4.y)); } verts.Add(new Vector3(zero2.x, zero.y)); verts.Add(new Vector3(zero.x, zero.y)); verts.Add(new Vector3(zero.x, zero2.y)); verts.Add(new Vector3(zero2.x, zero2.y)); } } IL_96C :; } if (alignment != UIFont.Alignment.Left && size2 < verts.size) { this.Align(verts, size2, alignment, num2, lineWidth); size2 = verts.size; } } }