public override int GetTextWidth(string text, PKFont font) { var f = new Font(font.Name, font.Size, font.Bold ? FontStyle.Bold : FontStyle.Regular); var s = graphics.MeasureString(text, f); return((int)s.Width); }
public override void WriteText( string text, PKBrush brush, PKFont font, PKHAlign align, int x, int y, int w, int h) { if (h > 0 & w > 0) { using (Brush b = FromBrush(brush, x, y, w, h)) { var f = new Font(font.Name, font.Size, font.Bold ? FontStyle.Bold : FontStyle.Regular); var s = graphics.MeasureString(text, f, w); if (align == PKHAlign.Left) { graphics.DrawString(text, f, b, x, y + (h - s.Height) / 2); } else if (align == PKHAlign.Right) { graphics.DrawString(text, f, b, x + w - s.Width, y + (h - s.Height) / 2); } else if (align == PKHAlign.Center) { graphics.DrawString(text, f, b, x + (w - s.Width) / 2, y + (h - s.Height) / 2); } } } }