// Token: 0x0600467F RID: 18047 RVA: 0x0010886C File Offset: 0x00106A6C private void renderLine(global::dfDynamicFont.LineRenderInfo line, Stack <Color32> colors, Vector3 position, global::dfRenderData destination) { position.x += (float)this.calculateLineAlignment(line); for (int i = line.startOffset; i <= line.endOffset; i++) { global::dfMarkupToken dfMarkupToken = this.tokens[i]; global::dfMarkupTokenType tokenType = dfMarkupToken.TokenType; if (tokenType == global::dfMarkupTokenType.Text) { this.renderText(dfMarkupToken, colors.Peek(), position, destination); } else if (tokenType == global::dfMarkupTokenType.StartTag) { if (dfMarkupToken.Matches("sprite") && this.SpriteAtlas != null && this.SpriteBuffer != null) { this.renderSprite(dfMarkupToken, colors.Peek(), position, this.SpriteBuffer); } else if (dfMarkupToken.Matches("color")) { colors.Push(this.parseColor(dfMarkupToken)); } } else if (tokenType == global::dfMarkupTokenType.EndTag && dfMarkupToken.Matches("color") && colors.Count > 1) { colors.Pop(); } position.x += (float)dfMarkupToken.Width; } }
// Token: 0x060040E0 RID: 16608 RVA: 0x000EE198 File Offset: 0x000EC398 private void calculateTokenRenderSize(global::dfMarkupToken token) { try { global::dfFont dfFont = (global::dfFont)base.Font; int num = 0; char previousChar = '\0'; bool flag = token.TokenType == global::dfMarkupTokenType.Whitespace || token.TokenType == global::dfMarkupTokenType.Text; if (flag) { int i = 0; while (i < token.Length) { char c = token[i]; if (c == '\t') { num += base.TabSize; } else { global::dfFont.GlyphDefinition glyph = dfFont.GetGlyph(c); if (glyph != null) { if (i > 0) { num += dfFont.GetKerning(previousChar, c); num += base.CharacterSpacing; } num += glyph.xadvance; } } i++; previousChar = c; } } else if (token.TokenType == global::dfMarkupTokenType.StartTag && token.Matches("sprite")) { if (token.AttributeCount < 1) { throw new Exception("Missing sprite name in markup"); } Texture texture = dfFont.Texture; int lineHeight = dfFont.LineHeight; string value = token.GetAttribute(0).Value.Value; global::dfAtlas.ItemInfo itemInfo = dfFont.atlas[value]; if (itemInfo != null) { float num2 = itemInfo.region.width * (float)texture.width / (itemInfo.region.height * (float)texture.height); num = Mathf.CeilToInt((float)lineHeight * num2); } } token.Height = base.Font.LineHeight; token.Width = num; } finally { } }
// 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: 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); }