This commit is contained in:
2025-05-13 03:10:33 +03:00
parent 5f03062f42
commit e5e3172b0f
80 changed files with 9655 additions and 0 deletions
@@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LineFontMeshWriter : ProceduralMeshFilter {
public LineFontMeshWriter(IProceduralMeshFilter next):base(next)
{ }
public LineFontMeshWriter WriteText(string text)
{
float tabLength = 4 * LineFont.Chars[0].Width;
float lineSize = 32 + 2;
float x = 0.0f;
float y = 0.0f;
char firstChar = (char)32;
char lastChar = (char)(firstChar + LineFont.Chars.Count - 1);
for (int i = 0; i < text.Length; ++i)
{
char charID = text[i];
if (charID >= firstChar && charID <= lastChar) {
int p = charID - firstChar;
var vChar = LineFont.Chars[p];
for (int j = 0; j < vChar.Vertices.Count; j++) {
Next.Vertex(vChar.Vertices[j] + new Vector2(x, y));
//appendVertex(position, lineFont[p].vertices[i] + ScreenOffsetType(x, y));
}
x += vChar.Width;
continue;
}
if (charID == '\n') {
x = 0;
y -= lineSize;
continue;
}
if (charID == '\t') {
x += tabLength;
continue;
}
}
return this;
}
}