public IEnumerable <VertexData> Vertices() { if (text != null && text.Length > 0) { Vector2 currentOffset = new Vector2(0, 0); currentOffset = GetBaseline(currentOffset); string[] lines = text.Split('\n'); foreach (string line in lines) { currentOffset = GetXPositionForLineBasedOnJustification(currentOffset, line); for (int currentChar = 0; currentChar < line.Length; currentChar++) { IVertexSource currentGlyph = TypeFaceStyle.GetGlyphForCharacter(line[currentChar]); if (currentGlyph != null) { foreach (VertexData vertexData in currentGlyph.Vertices()) { if (vertexData.command != ShapePath.FlagsAndCommand.CommandStop) { VertexData offsetVertex = new VertexData(vertexData.command, vertexData.position + currentOffset + Origin); yield return(offsetVertex); } } } // get the advance for the next character if (currentChar < line.Length - 1) { // pass the next char so the typeFaceStyle can do kerning if it needs to. currentOffset.x += TypeFaceStyle.GetAdvanceForCharacter(line[currentChar], line[currentChar + 1]); } else { currentOffset.x += TypeFaceStyle.GetAdvanceForCharacter(line[currentChar]); } } // before we go onto the next line we need to move down a line currentOffset.x = 0; currentOffset.y -= TypeFaceStyle.EmSizeInPixels; } } VertexData endVertex = new VertexData(ShapePath.FlagsAndCommand.CommandStop, Vector2.Zero); yield return(endVertex); }
public override IEnumerable <VertexData> Vertices() { if (text != null && text.Length > 0) { var currentOffset = new Vector2(0, 0); currentOffset = GetBaseline(currentOffset); string[] lines = text.Split('\n'); foreach (string line in lines) { currentOffset = GetXPositionForLineBasedOnJustification(currentOffset, line); for (int currentChar = 0; currentChar < line.Length; currentChar++) { IVertexSource currentGlyph = TypeFaceStyle.GetGlyphForCharacter(line[currentChar], ResolutionScale); if (currentGlyph != null) { foreach (VertexData vertexData in currentGlyph.Vertices()) { if (vertexData.command != ShapePath.FlagsAndCommand.Stop) { var offsetVertex = new VertexData(vertexData.command, vertexData.position + currentOffset + Origin); yield return(offsetVertex); } } } // get the advance for the next character currentOffset.X += TypeFaceStyle.GetAdvanceForCharacter(line, currentChar); } // before we go onto the next line we need to move down a line currentOffset.X = 0; currentOffset.Y -= TypeFaceStyle.EmSizeInPixels; } } var endVertex = new VertexData(ShapePath.FlagsAndCommand.Stop, Vector2.Zero); yield return(endVertex); }