Search code examples
c#rectanglessharpdxglyph

Sharp dx smallest rectangle that encloses a glyph


I'm trying to compute the smallest rectangle that can enclose a glyph, using SharpDX. The method GetGdiCompatibleGlyphMetrics doesn't seem to return the right values as each of my characters seem to have a width and height of 1000+, whereas I specified a font size of 16.

fontFace = new FontFace(factory, FontFaceType.Truetype, fontFileArray, 0, FontSimulations.None);    
var glyphMetrics = fontFace.GetGdiCompatibleGlyphMetrics(16, 1, null, false, glyphIndices, false);

If someone has an idea, I'd be really thankful.


Solution

  • I found the solution. I'll post it here for future questions.

    The FontFace class has a children class called FontFace1 which itself has a method GetKerningPairAdjustments. This kerning parameter solves everything.