vidstige/NRasterizer

Expose font name & provided variants/features on the Typeface class

tocsoft opened this issue · 1 comments

Typeface doesn't expose any information about whats inside the font.

Typeface should be extended to expose the font name, and any/all capabilities the font provides.

I'm thinking an API a bit like this could work nicely.

var typeface = reader.Read(stream);
var raterizer = new GlyphRasterizer(target);

if(typeface.KerningAvalible)
{
    var options = new RendererOptions(){
        Size = 30,
        Resolution = 72  // possibly should just be a sensible default inside the renderer???
        ApplyKerning = true // should this be opt-in or out?
    };
    var renderer = new Renderer(typeface, raterizer, options)
    renderer.Render(10, 20, "Hello\nWorld"); // render across 2 lines with kerning applied
}

if(typeface.Weights.Contains(FontWeights.Bold))
{
    var options = new RendererOptions(){
        Size = 30,
        Resolution = 72  // possibly should just be a sensible default inside the renderer???
        Weight = FontWeights.Bold
    };
    var renderer = new Renderer(typeface, raterizer, options)
    renderer.Render(10, 20, "Hello World"); //will render in Bold if availible otherwise Regular
}

Great idea 👍