// Token: 0x06004679 RID: 18041 RVA: 0x001084CC File Offset: 0x001066CC public static global::dfFontRendererBase Obtain(global::dfDynamicFont font) { global::dfDynamicFont.DynamicFontRenderer dynamicFontRenderer = (global::dfDynamicFont.DynamicFontRenderer.objectPool.Count <= 0) ? new global::dfDynamicFont.DynamicFontRenderer() : global::dfDynamicFont.DynamicFontRenderer.objectPool.Dequeue(); dynamicFontRenderer.Reset(); dynamicFontRenderer.Font = font; return(dynamicFontRenderer); }
// Token: 0x0600467C RID: 18044 RVA: 0x0010858C File Offset: 0x0010678C public float[] GetCharacterWidths(string text, int startIndex, int endIndex, out float totalWidth) { totalWidth = 0f; global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)base.Font; int size = Mathf.CeilToInt((float)dfDynamicFont.FontSize * base.TextScale); CharacterInfo[] array = dfDynamicFont.RequestCharacters(text, size, 0); float[] array2 = new float[text.Length]; float num = 0f; float num2 = 0f; int i = startIndex; while (i <= endIndex) { CharacterInfo characterInfo = array[i]; if (text[i] == '\t') { num2 += (float)base.TabSize; } else if (text[i] == ' ') { num2 += characterInfo.width; } else { num2 += characterInfo.vert.x + characterInfo.vert.width; } array2[i] = (num2 - num) * base.PixelRatio; i++; num = num2; } return(array2); }
// Token: 0x060046CC RID: 18124 RVA: 0x0010B3D0 File Offset: 0x001095D0 internal void SetText(string text) { this.Text = text; if (this.Style.Font == null) { return; } this.isWhitespace = global::dfMarkupBoxText.whitespacePattern.IsMatch(this.Text); string text2 = (!this.Style.PreserveWhitespace && this.isWhitespace) ? " " : this.Text; CharacterInfo[] array = this.Style.Font.RequestCharacters(text2, this.Style.FontSize, this.Style.FontStyle); int fontSize = this.Style.FontSize; Vector2 size; size..ctor(0f, (float)this.Style.LineHeight); for (int i = 0; i < text2.Length; i++) { CharacterInfo characterInfo = array[i]; float num = characterInfo.vert.x + characterInfo.vert.width; if (text2[i] == ' ') { num = Mathf.Max(num, (float)fontSize * 0.33f); } else if (text2[i] == '\t') { num += (float)(fontSize * 3); } size.x += num; } this.Size = size; global::dfDynamicFont font = this.Style.Font; float num2 = (float)fontSize / (float)font.FontSize; this.Baseline = Mathf.CeilToInt((float)font.Baseline * num2); }
// Token: 0x06004687 RID: 18055 RVA: 0x00109298 File Offset: 0x00107498 private void calculateLineSize(global::dfDynamicFont.LineRenderInfo line) { global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)base.Font; line.lineHeight = (float)dfDynamicFont.Baseline * base.TextScale; int num = 0; for (int i = line.startOffset; i <= line.endOffset; i++) { num += this.tokens[i].Width; } line.lineWidth = (float)num; }
// Token: 0x06004689 RID: 18057 RVA: 0x001093D8 File Offset: 0x001075D8 private void calculateTokenRenderSize(global::dfMarkupToken token) { try { int num = 0; bool flag = token.TokenType == global::dfMarkupTokenType.Whitespace || token.TokenType == global::dfMarkupTokenType.Text; global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)base.Font; if (flag) { int size = Mathf.CeilToInt((float)dfDynamicFont.FontSize * base.TextScale); CharacterInfo[] array = dfDynamicFont.RequestCharacters(token.Value, size, 0); for (int i = 0; i < token.Length; i++) { char c = token[i]; if (c == '\t') { num += base.TabSize; } else { CharacterInfo characterInfo = array[i]; num += ((c == ' ') ? Mathf.CeilToInt(characterInfo.width) : Mathf.CeilToInt(characterInfo.vert.x + characterInfo.vert.width)); if (i > 0) { num += Mathf.CeilToInt((float)base.CharacterSpacing * base.TextScale); } } } token.Height = base.Font.LineHeight; token.Width = num; } else if (token.TokenType == global::dfMarkupTokenType.StartTag && token.Matches("sprite") && this.SpriteAtlas != null && token.AttributeCount == 1) { Texture2D texture = this.SpriteAtlas.Texture; float num2 = (float)dfDynamicFont.Baseline * base.TextScale; string value = token.GetAttribute(0).Value.Value; global::dfAtlas.ItemInfo itemInfo = this.SpriteAtlas[value]; if (itemInfo != null) { float num3 = itemInfo.region.width * (float)texture.width / (itemInfo.region.height * (float)texture.height); num = Mathf.CeilToInt(num2 * num3); } token.Height = Mathf.CeilToInt(num2); token.Width = num; } } finally { } }
// Token: 0x060046AE RID: 18094 RVA: 0x0010A304 File Offset: 0x00108504 private void addInline(global::dfMarkupBox box) { global::dfMarkupBorders margins = box.Margins; bool flag = !this.Style.Preformatted && this.currentLine != null && (float)this.currentLinePos + box.Size.x > this.currentLine.Size.x; if (this.currentLine == null || flag) { this.endCurrentLine(false); int verticalPosition = this.getVerticalPosition(margins.top); global::dfMarkupBox containingBlock = this.GetContainingBlock(); if (containingBlock == null) { Debug.LogError("Containing block not found"); return; } global::dfDynamicFont dfDynamicFont = this.Style.Font ?? this.Style.Host.Font; float num = (float)dfDynamicFont.FontSize / (float)dfDynamicFont.FontSize; float num2 = (float)dfDynamicFont.Baseline * num; this.currentLine = new global::dfMarkupBox(this.Element, global::dfMarkupDisplayType.block, this.Style) { Size = new Vector2(containingBlock.Size.x, (float)this.Style.LineHeight), Position = new Vector2(0f, (float)verticalPosition), Parent = this, Baseline = (int)num2 }; this.children.Add(this.currentLine); } if (this.currentLinePos == 0 && !box.Style.PreserveWhitespace && box is global::dfMarkupBoxText) { global::dfMarkupBoxText dfMarkupBoxText = box as global::dfMarkupBoxText; if (dfMarkupBoxText.IsWhitespace) { return; } } Vector2 position; position..ctor((float)(this.currentLinePos + margins.left), (float)margins.top); box.Position = position; box.Parent = this.currentLine; this.currentLine.children.Add(box); this.currentLinePos = (int)(position.x + box.Size.x + (float)box.Margins.right); float num3 = Mathf.Max(this.currentLine.Size.x, position.x + box.Size.x); float num4 = Mathf.Max(this.currentLine.Size.y, position.y + box.Size.y); this.currentLine.Size = new Vector2(num3, num4); }
// Token: 0x06004705 RID: 18181 RVA: 0x0010C640 File Offset: 0x0010A840 public dfMarkupStyle(global::dfDynamicFont Font, int FontSize, FontStyle FontStyle) { this.Host = null; this.Atlas = null; this.Font = Font; this.FontSize = FontSize; this.FontStyle = FontStyle; this.Align = global::dfMarkupTextAlign.Left; this.VerticalAlign = global::dfMarkupVerticalAlign.Baseline; this.Color = Color.white; this.BackgroundColor = Color.clear; this.TextDecoration = global::dfMarkupTextDecoration.None; this.PreserveWhitespace = false; this.Preformatted = false; this.WordSpacing = 0; this.CharacterSpacing = 0; this.lineHeight = 0; this.Opacity = 1f; }
// Token: 0x06003EDD RID: 16093 RVA: 0x000E4E14 File Offset: 0x000E3014 private global::dfRenderData renderText() { if (this.Font == null || !this.Font.IsValid || string.IsNullOrEmpty(this.Text)) { return(null); } global::dfRenderData renderData = this.renderData; if (this.font is global::dfDynamicFont) { global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)this.font; renderData = this.textRenderData; renderData.Clear(); renderData.Material = dfDynamicFont.Material; } using (global::dfFontRendererBase dfFontRendererBase = this.obtainTextRenderer()) { dfFontRendererBase.Render(this.text, renderData); } return(renderData); }
// Token: 0x0600466B RID: 18027 RVA: 0x0010806C File Offset: 0x0010626C public static global::dfDynamicFont FindByName(string name) { for (int i = 0; i < global::dfDynamicFont.loadedFonts.Count; i++) { if (string.Equals(global::dfDynamicFont.loadedFonts[i].name, name, StringComparison.InvariantCultureIgnoreCase)) { return(global::dfDynamicFont.loadedFonts[i]); } } GameObject gameObject = global::Resources.Load(name) as GameObject; if (gameObject == null) { return(null); } global::dfDynamicFont component = gameObject.GetComponent <global::dfDynamicFont>(); if (component == null) { return(null); } global::dfDynamicFont.loadedFonts.Add(component); return(component); }
// Token: 0x06004685 RID: 18053 RVA: 0x00108FE8 File Offset: 0x001071E8 private global::dfList <global::dfDynamicFont.LineRenderInfo> calculateLinebreaks() { global::dfList <global::dfDynamicFont.LineRenderInfo> result; try { if (this.lines != null) { result = this.lines; } else { this.lines = global::dfList <global::dfDynamicFont.LineRenderInfo> .Obtain(); global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)base.Font; int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; float num5 = (float)dfDynamicFont.Baseline * base.TextScale; while (num3 < this.tokens.Count && (float)this.lines.Count * num5 <= base.MaxSize.y + num5) { global::dfMarkupToken dfMarkupToken = this.tokens[num3]; global::dfMarkupTokenType tokenType = dfMarkupToken.TokenType; if (tokenType == global::dfMarkupTokenType.Newline) { this.lines.Add(global::dfDynamicFont.LineRenderInfo.Obtain(num2, num3)); num = (num2 = ++num3); num4 = 0; } else { int num6 = Mathf.CeilToInt((float)dfMarkupToken.Width); bool flag = base.WordWrap && num > num2 && (tokenType == global::dfMarkupTokenType.Text || (tokenType == global::dfMarkupTokenType.StartTag && dfMarkupToken.Matches("sprite"))); if (flag && (float)(num4 + num6) >= base.MaxSize.x) { if (num > num2) { this.lines.Add(global::dfDynamicFont.LineRenderInfo.Obtain(num2, num - 1)); num3 = (num2 = ++num); num4 = 0; } else { this.lines.Add(global::dfDynamicFont.LineRenderInfo.Obtain(num2, num - 1)); num = (num2 = ++num3); num4 = 0; } } else { if (tokenType == global::dfMarkupTokenType.Whitespace) { num = num3; } num4 += num6; num3++; } } } if (num2 < this.tokens.Count) { this.lines.Add(global::dfDynamicFont.LineRenderInfo.Obtain(num2, this.tokens.Count - 1)); } for (int i = 0; i < this.lines.Count; i++) { this.calculateLineSize(this.lines[i]); } result = this.lines; } } finally { } return(result); }
// Token: 0x06004680 RID: 18048 RVA: 0x00108988 File Offset: 0x00106B88 private void renderText(global::dfMarkupToken token, Color32 color, Vector3 position, global::dfRenderData renderData) { try { global::dfDynamicFont dfDynamicFont = (global::dfDynamicFont)base.Font; int num = Mathf.CeilToInt((float)dfDynamicFont.FontSize * base.TextScale); FontStyle style = 0; int descent = dfDynamicFont.Descent; global::dfList <Vector3> vertices = renderData.Vertices; global::dfList <int> triangles = renderData.Triangles; global::dfList <Vector2> uv = renderData.UV; global::dfList <Color32> colors = renderData.Colors; string value = token.Value; float num2 = position.x; float y = position.y; CharacterInfo[] array = dfDynamicFont.RequestCharacters(value, num, style); renderData.Material = dfDynamicFont.Material; Color32 color2 = this.applyOpacity(this.multiplyColors(color, base.DefaultColor)); Color32 item = color2; if (base.BottomColor != null) { item = this.applyOpacity(this.multiplyColors(color, base.BottomColor.Value)); } for (int i = 0; i < value.Length; i++) { if (i > 0) { num2 += (float)base.CharacterSpacing * base.TextScale; } CharacterInfo glyph = array[i]; float num3 = (float)dfDynamicFont.FontSize + glyph.vert.y - (float)num + (float)descent; float num4 = num2 + glyph.vert.x; float num5 = y + num3; float num6 = num4 + glyph.vert.width; float num7 = num5 + glyph.vert.height; Vector3 vector = new Vector3(num4, num5) * base.PixelRatio; Vector3 vector2 = new Vector3(num6, num5) * base.PixelRatio; Vector3 vector3 = new Vector3(num6, num7) * base.PixelRatio; Vector3 vector4 = new Vector3(num4, num7) * base.PixelRatio; if (base.Shadow) { global::dfDynamicFont.DynamicFontRenderer.addTriangleIndices(vertices, triangles); Vector3 vector5 = base.ShadowOffset * base.PixelRatio; vertices.Add(vector + vector5); vertices.Add(vector2 + vector5); vertices.Add(vector3 + vector5); vertices.Add(vector4 + vector5); Color32 item2 = this.applyOpacity(base.ShadowColor); colors.Add(item2); colors.Add(item2); colors.Add(item2); colors.Add(item2); global::dfDynamicFont.DynamicFontRenderer.addUVCoords(uv, glyph); } if (base.Outline) { for (int j = 0; j < global::dfDynamicFont.DynamicFontRenderer.OUTLINE_OFFSETS.Length; j++) { global::dfDynamicFont.DynamicFontRenderer.addTriangleIndices(vertices, triangles); Vector3 vector6 = global::dfDynamicFont.DynamicFontRenderer.OUTLINE_OFFSETS[j] * (float)base.OutlineSize * base.PixelRatio; vertices.Add(vector + vector6); vertices.Add(vector2 + vector6); vertices.Add(vector3 + vector6); vertices.Add(vector4 + vector6); Color32 item3 = this.applyOpacity(base.OutlineColor); colors.Add(item3); colors.Add(item3); colors.Add(item3); colors.Add(item3); global::dfDynamicFont.DynamicFontRenderer.addUVCoords(uv, glyph); } } global::dfDynamicFont.DynamicFontRenderer.addTriangleIndices(vertices, triangles); vertices.Add(vector); vertices.Add(vector2); vertices.Add(vector3); vertices.Add(vector4); colors.Add(color2); colors.Add(color2); colors.Add(item); colors.Add(item); global::dfDynamicFont.DynamicFontRenderer.addUVCoords(uv, glyph); num2 += (float)Mathf.CeilToInt(glyph.vert.x + glyph.vert.width); } } finally { } }
// Token: 0x060046CF RID: 18127 RVA: 0x0010B5B4 File Offset: 0x001097B4 private void renderText(string text) { global::dfDynamicFont font = this.Style.Font; int fontSize = this.Style.FontSize; FontStyle fontStyle = this.Style.FontStyle; global::dfList <Vector3> vertices = this.renderData.Vertices; global::dfList <int> triangles = this.renderData.Triangles; global::dfList <Vector2> uv = this.renderData.UV; global::dfList <Color32> colors = this.renderData.Colors; float num = (float)fontSize / (float)font.FontSize; float num2 = (float)font.Descent * num; float num3 = 0f; CharacterInfo[] array = font.RequestCharacters(text, fontSize, fontStyle); this.renderData.Material = font.Material; for (int i = 0; i < text.Length; i++) { CharacterInfo characterInfo = array[i]; global::dfMarkupBoxText.addTriangleIndices(vertices, triangles); float num4 = (float)font.FontSize + characterInfo.vert.y - (float)fontSize + num2; float num5 = num3 + characterInfo.vert.x; float num6 = num4; float num7 = num5 + characterInfo.vert.width; float num8 = num6 + characterInfo.vert.height; Vector3 item; item..ctor(num5, num6); Vector3 item2; item2..ctor(num7, num6); Vector3 item3; item3..ctor(num7, num8); Vector3 item4; item4..ctor(num5, num8); vertices.Add(item); vertices.Add(item2); vertices.Add(item3); vertices.Add(item4); Color color = this.Style.Color; colors.Add(color); colors.Add(color); colors.Add(color); colors.Add(color); Rect uv2 = characterInfo.uv; float x = uv2.x; float num9 = uv2.y + uv2.height; float num10 = x + uv2.width; float y = uv2.y; if (characterInfo.flipped) { uv.Add(new Vector2(num10, y)); uv.Add(new Vector2(num10, num9)); uv.Add(new Vector2(x, num9)); uv.Add(new Vector2(x, y)); } else { uv.Add(new Vector2(x, num9)); uv.Add(new Vector2(num10, num9)); uv.Add(new Vector2(num10, y)); uv.Add(new Vector2(x, y)); } num3 += (float)Mathf.CeilToInt(characterInfo.vert.x + characterInfo.vert.width); } }