#region CPL License /* Nuclex Framework Copyright (C) 2002-2008 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #endregion using System; using System.Collections.Generic; using Microsoft.Xna.Framework; namespace Nuclex.Fonts { /// Stores the data of a character in a vector font /// /// /// Each character in a vector font has an array of vertices that store the /// outline points for the font and in some cases contains additional /// supporting vertices required to draw filled text with triangles. /// /// /// You can either access this data any make use of it for your own purposes, /// or use one of the vector font's provided methods for constructing an /// outline font, a flat font or an extruded font. /// /// public class VectorFontCharacter { #region struct Outline /// Stores the starting index and the vertex count of a character outline public struct Outline { /// Initializes a new character outline /// Index of the vertex with which the outline starts /// Number of vertices in this outline public Outline(int startVertexIndex, int vertexCount) { this.StartVertexIndex = startVertexIndex; this.VertexCount = vertexCount; } /// Index of the vertex with which the outline begins public int StartVertexIndex; /// Total number of vertices the outline consists of public int VertexCount; } #endregion // struct Outline #region struct Face /// Stores three vertex indices forming a triangle public struct Face { /// Initializes a new character face triangle /// Index of the triangle's first vertex /// Index of the triangle's second vertex /// Index of the triangle's third vertex public Face(int firstVertexIndex, int secondVertexIndex, int thirdVertexIndex) { this.FirstVertexIndex = firstVertexIndex; this.SecondVertexIndex = secondVertexIndex; this.ThirdVertexIndex = thirdVertexIndex; } /// Index of the first vertex of the triangle public int FirstVertexIndex; /// Index of the second vertex of the triangle public int SecondVertexIndex; /// Index of the third vertex of the triangle public int ThirdVertexIndex; } #endregion // struct Face /// Initializes new vector font character /// /// By what to advance the pen after the character was drawn /// /// Vertices used by this character /// Vertex indices for drawing the character's outline /// Vertex indices for filling the character internal VectorFontCharacter( Vector2 advancement, List vertices, List outlines, List faces ) { this.advancement = advancement; this.vertices = vertices; this.outlines = outlines; this.faces = faces; } /// By how much to advance the cursor after drawing this character public Vector2 Advancement { get { return this.advancement; } } /// Vertices for this character /// /// This contains the vertices required to draw the outline of the character /// as well as supporting vertices required to draw the character's face as /// a series of triangles. If you're only interested in a character's outlines, /// you can ignore any vertices with an index above the EndVertex of /// the lastmost outline contained in the Outlines list. /// public List Vertices { get { return this.vertices; } } /// /// Specifies which vertices have to be connected to draw the outlines /// of the character. /// /// /// /// A character can have more than one outline. For example, the equals sign ('=') /// has two unconnected shapes that require two outlines to be drawn. In this /// case, you'd find two outlines, the first one specifying the starting and ending /// vertex for the first stroke and the second one specifying the starting and /// ending vertex for the second stroke. /// /// /// The vertex range specified by each outline should be handled as a single /// line strip (draw a line from the first to the second vertex, then from the /// second to the third, and so on). The final vertex needs to be connected /// to the first vertex again to close the outline. /// /// public List Outlines { get { return this.outlines; } } /// /// Specifies between which vertices triangles have to be drawn to draw a /// polygon-filled character. /// public List Faces { get { return this.faces; } } /// How far to advance the cursor after this character is rendered private Vector2 advancement; /// Vertices used by this character private List vertices; /// Vertex index ranges to use for drawing the character's outlines private List outlines; /// Vertex indices to use for filling the character with triangles private List faces; } } // namespace Nuclex.Fonts