LayoutFarm / Typography

C# Font Reader (TrueType / OpenType / OpenFont / CFF / woff / woff2) , Glyphs Layout and Rendering
Other
404 stars 83 forks source link

Typography.MsdfGen lacks convenient shape generator from glyph #182

Open BreyerW opened 4 years ago

BreyerW commented 4 years ago

Basically title. Without helper that would take glyph directly or just endpoints and glyph points and return shape Typography.MsdfGen is unusable at least for me.

Tacodiva commented 1 year ago

Hey, In case anyone else is interested, I've been working on a game engine and wanted to be able to generate SDFs at runtime and I managed to hook up the font loader and MsdfGen without any PixelFarm stuff. You can see my fork here on how it's done, but essentially I've created some wrappers around this libraries objects for my specific usecase.

TypefaceWrapper typeface = TypefaceWrapper.Load(new FileStream(...));
GlyphWrapper glyph = typeface.GetGlyph('&');
MsdfgenResult result = glyph.RenderMSDF(glyphSizePixels: 40, range: 10, paddingPixels: 3);
// Result contains the FloatRGBBmp object and a vector containing how much the glyph has been translated in pixels