title: Letter spacing with DrawString?
body: <p>In an answer to an older post at <a href="https://stackoverflow.com/questions/2969143/c-sharp-drawstring-letter-spacing">C# Drawstring Letter Spacing</a> regarding letter spacing, I saw:</p>
  
  <pre><code>[DllImport("gdi32.dll", CharSet=CharSet.Auto)] 
  public static extern int SetTextCharacterExtra( 
      IntPtr hdc,    // DC handle
      int nCharExtra // extra-space value 
  ); 
  
  public void Draw(Graphics g) 
  { 
      IntPtr hdc = g.GetHdc(); 
      SetTextCharacterExtra(hdc, 24); //set spacing between characters 
      g.ReleaseHdc(hdc); 
  
      e.Graphics.DrawString("str",this.Font,Brushes.Black,0,0); 
  }  
  </code></pre>
  
  <p>I tried it with both positive and negative numbers (converted to VB.NET) but it had no effect at all. Is it a valid code piece or is it incorrect?</p>
  
  <pre><code>  &lt;DllImport("gdi32.dll", CharSet:=CharSet.Auto)&gt; _
      Public Shared Function SetTextCharacterExtra(ByVal hdc As IntPtr, ByVal nCharExtra As Integer) As Integer
          ' extra-space value
      End Function
  </code></pre>
  
  <p>And in a function:</p>
  
  <pre><code> With gClsGraphics1
              'Drawstring
              .SmoothingMode = SmoothingMode.HighQuality
              .TextRenderingHint = Text.TextRenderingHint.ClearTypeGridFit
              .CompositingQuality = CompositingQuality.HighQuality
  
              Dim hdc As IntPtr = .GetHdc()
              SetTextCharacterExtra(hdc, 30)
             .ReleaseHdc(hdc)
  
          End With
  </code></pre>