public unsafe void Append(TextAnalyzer analyzer, FontFace font, string text) { var layout = new TextLayout(); var format = new TextFormat { Font = font, Size = 8.0f }; analyzer.AppendText(text, format); analyzer.PerformLayout(32, 64, 1000, 1000, layout); var memBlock = new MemoryBlock(text.Length * 6 * PosColorTexture.Layout.Stride); var mem = (PosColorTexture *)memBlock.Data; foreach (var thing in layout.Stuff) { var width = thing.Width; var height = thing.Height; var region = new Vector4(thing.SourceX, thing.SourceY, width, height) / 4096; var origin = new Vector2(thing.DestX, thing.DestY); * mem++ = new PosColorTexture(origin + new Vector2(0, height), new Vector2(region.X, region.Y + region.W), unchecked ((int)0xff000000)); * mem++ = new PosColorTexture(origin + new Vector2(width, height), new Vector2(region.X + region.Z, region.Y + region.W), unchecked ((int)0xff000000)); * mem++ = new PosColorTexture(origin + new Vector2(width, 0), new Vector2(region.X + region.Z, region.Y), unchecked ((int)0xff000000)); * mem++ = new PosColorTexture(origin, new Vector2(region.X, region.Y), unchecked ((int)0xff000000)); count++; } vertexBuffer = new DynamicVertexBuffer(memBlock, PosColorTexture.Layout); }
public unsafe void Append(TextAnalyzer analyzer, FontFace font, string text) { var layout = new TextLayout(); var format = new TextFormat { Font = font, Size = 32.0f }; analyzer.AppendText(text, format); analyzer.PerformLayout(0, 32, 1000, 1000, layout); var memBlock = new MemoryBlock(text.Length * 6 * PosColorTexture.Layout.Stride); var mem = (PosColorTexture*)memBlock.Data; foreach (var thing in layout.Stuff) { var width = thing.Width; var height = thing.Height; var region = new Vector4(thing.SourceX, thing.SourceY, width, height) / 4096; var origin = new Vector2(thing.DestX, thing.DestY); *mem++ = new PosColorTexture(origin + new Vector2(0, height), new Vector2(region.X, region.Y + region.W), unchecked((int)0xff000000)); *mem++ = new PosColorTexture(origin + new Vector2(width, height), new Vector2(region.X + region.Z, region.Y + region.W), unchecked((int)0xff000000)); *mem++ = new PosColorTexture(origin + new Vector2(width, 0), new Vector2(region.X + region.Z, region.Y), unchecked((int)0xff000000)); *mem++ = new PosColorTexture(origin, new Vector2(region.X, region.Y), unchecked((int)0xff000000)); count++; } vertexBuffer = new DynamicVertexBuffer(memBlock, PosColorTexture.Layout); }
public unsafe void Append(TextAnalyzer analyzer, FontFace font, CharBuffer charBuffer, float fontSize, int atlasWidth, RectangleF drawRect, RgbaByte color) { if (charBuffer.Count == 0) { return; } _textLayout.Stuff.Clear(); _textFormat.Font = font; _textFormat.Size = fontSize; analyzer.AppendText(charBuffer.Buffer, 0, (int)charBuffer.Count, _textFormat); analyzer.PerformLayout(drawRect.X, drawRect.Y, drawRect.Width, drawRect.Height, _textLayout); PerformLayoutAndUpdateDeviceBuffers(atlasWidth, color); }
public unsafe void Append(TextAnalyzer analyzer, FontFace font, string text, float fontSize, int atlasWidth, RectangleF drawRect, RgbaByte color) { if (string.IsNullOrEmpty(text)) { return; } _textLayout.Stuff.Clear(); _textFormat.Font = font; _textFormat.Size = fontSize; analyzer.AppendText(text, _textFormat); analyzer.PerformLayout(drawRect.X, drawRect.Y, drawRect.Width, drawRect.Height, _textLayout); PerformLayoutAndUpdateDeviceBuffers(atlasWidth, color); }