GDI + DrawString word spacing problem, gdidrawstring

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.