vidstige / NRasterizer

OpenType parser in pure c#
Apache License 2.0
38 stars 11 forks source link

Add the ability to measure a string without rendering it #42

Closed tocsoft closed 7 years ago

tocsoft commented 7 years ago

Add a option to Renderer to measure a string.

   var options = new RendererOptions()
   {
        Size = 30
    };
    var renderer = new Renderer(typeface, raterizer, options)
    var stringSize = renderer.Measure("Hello\nWorld");

string size would expose and Height and Width.

I imagine it would just run the same code as Render(...) except just skipping the RenderGlyph(...) call and spitting out the final yy and xx as height and widths (+/- a line height addition)