Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6717247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:49:47+00:00 2026-05-26T08:49:47+00:00

Using System.Drawing.Font , is there a way to change the Letter Spacing, just like

  • 0

Using System.Drawing.Font, is there a way to change the Letter Spacing, just like you can change the Font Size?

I’m looking to increase the letter spacing to fit a specific width.

If this is not possible, are there alternatives to get the desired effect? For example, is there an easy way of having multiple graphics which will fit my specific width?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:49:48+00:00Added an answer on May 26, 2026 at 8:49 am

    I don’t think DrawString will allow you to specify anything as detailed as the spacing between characters, but I would create a helper function that calculates spacing based on a desired width and then draw each character to fit.

    Try this and see how you get on…

        public void DrawSpacedText(Graphics g, Font font, Brush brush, PointF point, string text, int desiredWidth)
        {
            //Calculate spacing
            float widthNeeded = 0;
            foreach (char c in text)
            {
                widthNeeded += g.MeasureString(c.ToString(), font).Width;
            }
            float spacing = (desiredWidth - widthNeeded) / (text.Length - 1);
    
            //draw text
            float indent = 0;
            foreach (char c in text)
            {
                g.DrawString(c.ToString(), font, brush, new PointF(point.X + indent, point.Y));
                indent += g.MeasureString(c.ToString(), font).Width + spacing;
            }
        }
    

    You could probably optimise this to make only one call to MeasureString per character. Or even use MeasureCharacterRanges to get an array (which I believe is more accurate anyway)

    Edit: Here is an example using MeasureCharacterRanges instead…

        public void DrawSpacedText(Graphics g, Font font, Brush brush, PointF point, string text, int desiredWidth)
        {
            //Calculate spacing
            float widthNeeded = 0;
            Region[] regions = g.MeasureCharacterRanges(text, font, new RectangleF(point, new SizeF(desiredWidth, font.Height + 10)), StringFormat.GenericDefault);
            float[] widths = new float[regions.Length];
            for(int i = 0; i < widths.Length; i++)
            {
                widths[i] = regions[i].GetBounds(g).Width;
                widthNeeded += widths[i];
            }
            float spacing = (desiredWidth - widthNeeded) / (text.Length - 1);
    
            //draw text
            float indent = 0;
            int index = 0;
            foreach (char c in text)
            {
                g.DrawString(c.ToString(), font, brush, new PointF(point.X + indent, point.Y));
                indent += widths[index] + spacing;
                index++;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use CodeDom to instantiate an instance of System.Drawing.Font but I can't
using System; using System.Drawing; using System.IO; using System.Security.Cryptography; using System.Text.RegularExpressions; using System.Windows.Forms; using System.Threading;
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Drawing.Imaging;
using System; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Runtime.InteropServices; using DirectShowLib;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Net;
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text;
I have the following MonoTouch program: using System.Drawing; using MonoTouch.Foundation; using MonoTouch.UIKit; using System;
My domain model is using System.Net.Uri to represent URLs, and System.Drawing.Color to represent colors.
I have a program that draws some vector graphics using System.Drawing and the Graphics
Using the System.Drawings System.Drawing.FontFamily.Families brings me up more families than the ones supported for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.