GDI + DrawString word spacing problem, gdidrawstring
/// <Summary> /// draw any spacing text /// </summary> /// <param name = "text"> text </param> /// <param name = "g"> Drawing Object </param> /// <param name = "startPoint"> Start position </param> /// <param name = "font"> font </param> /// <param name = "brush"> image painter </param> /// <param name = "sepDist"> spacing </param> private void drawStringEx (string text, graphics g, PointF startPoint, Font font, Brush brush, float sepDist) {PointF pf = startPoint; SizeF charSize; char [] ch = text. toCharArray (); foreach (char c in ch) {charSize = g. measureString (c. toString (), font); g. drawString (c. toString (), font, brush, pf); pf. X + = (charSize. width + sepDist );}}
When the size of GDI + Drawstring is 4, there is a large gap between the front and the back of the text.
M_GDIPlusFont = new Font (dc. m_hDC, m_Font); void DrawString (CDCHandle dc, CString strText, CRectHelper rc) {Graphics g (dc); SolidBrush (Color (255,255,255,255); StringFormat stringFormat; stringFormat. setAlignment (StringAlignmentNear); stringFormat. setLineAlignment (StringAlignmentNear); g. drawString (strText, strText. getLength (), m_GDIPlusFont, rc, & stringFormat, & solidBrush);} Have you set the font format ??? I usually use GDI + to draw text.
GDI + drawstring font
If this font is not available, the font file must be installed on the machine. If you drag the font file into the system, the system will automatically install the file, instead of putting it under the program directory.