I previously mentioned using vector-based fonts, e.g. for deep sky object and star labels. These labels used line-primitives, as shown in Figures 1 and 2.
Figure 1. Line-primitive Roman vector font
Figure 2. Line-primitive Greek vector font
I also wanted to use vector-based fonts with "thick" lines, so needed to expand each line by a given thickness. The steps I used for a basic approach to achieving this are illustrated in Figure 3, using a '>' symbol as an example.
Figure 3. Expanding line-primitives to triangle-primitives
The first step is to expand each line-primitive into a pair of triangles of a given thickness. Next, each line is given a semi-circular "cap", with the number of slices defined by a "smoothing" parameter. Rather than using a cap for both the start and end of each line, only a single cap is used at the join between lines. Finally, the number slices drawn for a given cap can be limited by the angle between each line-join, further reducing the vertex and index counts.
Text can now be scaled smoothly, as shown in Figure 4, without the artefacts produced by scaling SpriteBatch raster fonts. One limitation of this approach however, is that text cannot be drawn with transparency since triangles in each character generally overlap.
Figure 4. Smooth scaling of vector fonts
Figure 5. Triangle-primitive Roman vector font
Comments
Add Comment