// Token: 0x060040D6 RID: 16598 RVA: 0x000ED390 File Offset: 0x000EB590 public override void Render(string text, global::dfRenderData destination) { global::dfFont.BitmappedFontRenderer.textColors.Clear(); global::dfFont.BitmappedFontRenderer.textColors.Push(Color.white); this.tokenize(text); global::dfList <global::dfFont.LineRenderInfo> dfList = this.calculateLinebreaks(); int num = 0; int num2 = 0; Vector3 vectorOffset = base.VectorOffset; float num3 = base.TextScale * base.PixelRatio; for (int i = 0; i < dfList.Count; i++) { global::dfFont.LineRenderInfo lineRenderInfo = dfList[i]; int count = destination.Vertices.Count; this.renderLine(dfList[i], global::dfFont.BitmappedFontRenderer.textColors, vectorOffset, destination); vectorOffset.y -= (float)base.Font.LineHeight * num3; num = Mathf.Max((int)lineRenderInfo.lineWidth, num); num2 += (int)lineRenderInfo.lineHeight; if (lineRenderInfo.lineWidth * base.TextScale > base.MaxSize.x) { this.clipRight(destination, count); } if ((float)num2 * base.TextScale > base.MaxSize.y) { this.clipBottom(destination, count); } } base.RenderedSize = new Vector2(Mathf.Min(base.MaxSize.x, (float)num), Mathf.Min(base.MaxSize.y, (float)num2)) * base.TextScale; }
// Token: 0x060040D7 RID: 16599 RVA: 0x000ED4F8 File Offset: 0x000EB6F8 private void renderLine(global::dfFont.LineRenderInfo line, Stack <Color32> colors, Vector3 position, global::dfRenderData destination) { float num = base.TextScale * base.PixelRatio; position.x += (float)this.calculateLineAlignment(line) * num; 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.renderSprite(dfMarkupToken, colors.Peek(), position, destination); } 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 * num; } }
// Token: 0x060040DE RID: 16606 RVA: 0x000EE064 File Offset: 0x000EC264 private void calculateLineSize(global::dfFont.LineRenderInfo line) { line.lineHeight = (float)base.Font.LineHeight; int num = 0; for (int i = line.startOffset; i <= line.endOffset; i++) { num += this.tokens[i].Width; } line.lineWidth = (float)num; }
// Token: 0x060040EC RID: 16620 RVA: 0x000EE8FC File Offset: 0x000ECAFC public static global::dfFont.LineRenderInfo Obtain(int start, int end) { if (global::dfFont.LineRenderInfo.poolIndex >= global::dfFont.LineRenderInfo.pool.Count - 1) { global::dfFont.LineRenderInfo.pool.Add(new global::dfFont.LineRenderInfo()); } global::dfFont.LineRenderInfo lineRenderInfo = global::dfFont.LineRenderInfo.pool[global::dfFont.LineRenderInfo.poolIndex++]; lineRenderInfo.startOffset = start; lineRenderInfo.endOffset = end; lineRenderInfo.lineHeight = 0f; return(lineRenderInfo); }
// Token: 0x060040DD RID: 16605 RVA: 0x000EDFDC File Offset: 0x000EC1DC private int calculateLineAlignment(global::dfFont.LineRenderInfo line) { float lineWidth = line.lineWidth; if (base.TextAlign == null || lineWidth == 0f) { return(0); } int num; if (base.TextAlign == 2) { num = Mathf.FloorToInt(base.MaxSize.x / base.TextScale - lineWidth); } else { num = Mathf.FloorToInt((base.MaxSize.x / base.TextScale - lineWidth) * 0.5f); } return(Mathf.Max(0, num)); }