private static FontDescriptors[] DrawFonts(Graphics g, int width, int height, Font[] fonts) { float hborder = 4.0f; float safetyMargin = 2.0f * hborder; float y = 0; float LHS = safetyMargin; float x = LHS; var descriptors = new FontDescriptors[fonts.Length]; float lastHeight = -1.0f; float nextRowHeight = -1.0f; for (int i = 0; i < fonts.Length; i++) { Font f = fonts[i]; var metrics = FontMetrics.From(g, f); descriptors[i] = new FontDescriptors(f, metrics); IEnumerable <char> glyphs; glyphs = AnsiGlyphs; if (nextRowHeight < 0) { nextRowHeight = metrics.Height; } if (lastHeight >= metrics.Height) { } else { x = LHS; if (lastHeight > 0) { y += nextRowHeight + 1; nextRowHeight = metrics.Height; } } lastHeight = metrics.Height; var sf = StringFormat.GenericTypographic; foreach (char c in glyphs) { if (!metrics.IsGlyphAvailable(c)) { continue; } string s = new string(c, 1); int A = metrics.GetA(c) - (int)hborder; int B = metrics.GetB(c) + (int)safetyMargin; int C = metrics.GetC(c) - (int)hborder; float dx = (float)(B); if (x + dx >= width) { x = LHS; y += nextRowHeight + 1; nextRowHeight = metrics.Height; } float Tx = x - (float)A; descriptors[i].Add(c, A, B, C, (int)Tx, (int)y); if (metrics.Height > 22) { g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; } else { g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit; } TextRenderer.DrawText(g, s, f, new Point((int)Tx, (int)y), Color.White, TextFormatFlags.NoPadding); // g.DrawString(s, f, Brushes.White, new PointF(Tx, y), sf); x += dx + safetyMargin; } } return(descriptors); }