예제 #1
0
        public IEnumerable <float> BufferText(string text, float adjustment, Matrix4 transform)
        {
            float textWidth  = measureWidth(text);
            float charOffset = textWidth * adjustment;

            foreach (char c in text)
            {
                if (!char.IsWhiteSpace(c))
                {
                    var charInfo = this.characterInfos[c];

                    for (int v = 0; v < 6; v++)
                    {
                        var charPos = Vector4.Transform(
                            new Vector4(unitQuadTriangles[v].X * charInfo.Aspect + charOffset, unitQuadTriangles[v].Y, 0, 1),
                            transform
                            );
                        foreach (var dataBit in SpriteHelpers.TexturedVertexData(charPos.X, charPos.Y, charInfo.TextureCoords[v].X, charInfo.TextureCoords[v].Y))
                        {
                            yield return(dataBit);
                        }
                    }
                    charOffset += charInfo.Aspect;
                }
                else if (c == ' ')
                {
                    charOffset += SpaceUnitWidth;
                }
            }
        }