public SizeF MeasureText(string text, FontInfo font) { var state = Graphics.TextRenderingHint; try { Graphics.TextRenderingHint = TextRenderingHint.AntiAlias; return(Graphics.MeasureString(text, FontResolver.Resolve(font), new SizeF(int.MaxValue, int.MaxValue), StringFormat.GenericTypographic)); } finally { Graphics.TextRenderingHint = state; } }
private float CalculateSpaceSize(FontInfo font) { var xfont = FontResolver.Resolve(font); return(Graphics.MeasureString("x x", xfont).Width - Graphics.MeasureString("xx", xfont).Width); }