-
Hi everybody, We are currently working on integrating SixLabors/Fonts into tooll.io. Our goal is to generate procedural 3D meshes from any given TrueType font, regardless of whether it's installed or not. To achieve this, I believe we need to undertake the following steps:
I envision something along the lines of the following (with mock code provided): /** A Point on the outline that can be used to generate front and side mesh */
class Point {
Vector3 Position;
Vector3 Normal; // For bevelling
Vector3 TangentA; // For generating normals
Vector3 TangentB; // For generating normals
}
/** A closed shape that requires triangulation */
class Shape {
List<Point> Points;
List<Shape> Holes;
bool IsClosed;
bool IsHole;
}
/** Information for a character */
class Glyph {
List<Shape> Shapes;
Glyph OriginalGlyph; // Original glyph definition
Rectangle Bounds;
}
/** Representation of the original string. Contains everything to generate mesh */
class GlyphSet {
List<Glyph> Glyphs;
float ExtrusionDepth;
float Bevel; // Just a naive offset along Point.Normal
Mesh ConvertToMesh() {...};
} After examining the source code, I have a strong intuition that achieving something of this nature should be feasible with SixLabors/Fonts. However, I've been unable to locate either documentation (link) or examples (link) on where or how to begin. Any guidance or advice on this matter would be greatly appreciated. Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
You need to implement a custom I would suggest you take a look at the PathGlyphBuilder in The |
Beta Was this translation helpful? Give feedback.
-
Thanks! That helps a lot. |
Beta Was this translation helpful? Give feedback.
-
Hello : ) I'm working on the implementation of the package in Tooll3. I've followed the suggestions and it's working great, it's simple and effective to render text with all the options, thanks for your hard work! Thanks |
Beta Was this translation helpful? Give feedback.
You need to implement a custom
IGlyphRenderer
which will end up describing the final shaped and layed out vectors (with all the kerning/hinting/rich text handling completed).I would suggest you take a look at the PathGlyphBuilder in
ImageSharp.Drawing
with an example of it being called in the TextBuilder class.The
PathGlyphBuilder
handles converting the output of this library and converts it into more simple set of vectors.