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 9206805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:15:10+00:00 2026-06-18T00:15:10+00:00

Here is some C# code written in linqpad to reproduce the issue. var font

  • 0

Here is some C# code written in linqpad to reproduce the issue.

var font = new System.Drawing.Font("Arial", 8);
using (var g = System.Drawing.Graphics.FromHwnd(IntPtr.Zero))
{
    //65536 characters is fine
    g.DrawString("a".PadLeft(65535, 'a'), font, System.Drawing.Brushes.Black, new System.Drawing.RectangleF(0, 0, 1, 1));
    //65537 characters causes an error.
    g.DrawString("a".PadLeft(65536, 'a'), font, System.Drawing.Brushes.Black, new System.Drawing.RectangleF(0, 0, 1, 1));
    //65537 characters is however fine if the width is over 600581
    g.DrawString("a".PadLeft(65536, 'a'), font, System.Drawing.Brushes.Black, new System.Drawing.RectangleF(0, 0, 600582, 1));
}

Anyone know the exact relationship between the string’s length and the layout rectangle’s width? The number 600581 seems very arbitrary. Although 65536 makes more sense as that is 0x10000.

  • 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-06-18T00:15:11+00:00Added an answer on June 18, 2026 at 12:15 am

    Anyone know the exact relationship between the string’s length and the
    layout rectangle’s width? The number 600581 seems very arbitrary.

    The number 600581 is indeed arbitrary and in this case it reflects the fonts char widths (or the typeface’s glyphs).

    Take for example 600581 / 65536 which gives an average char-width of 9.16 pixels per char which is reasonable for a fairly squared font such as Arial when you include spacing. GDI+ also adds padding to the text’s bounding box in addition to this.

    If you try a wider (or a narrower font, but you wouldn’t notice unless reducing the number) as well as different letter combinations you should get different results. Try a mono-spaced font and you should be able to predict pretty accurately the needed boundaries (don’t forget the padding).

    If you really need to print long strings try to buffer the printing, however GDI+ isn’t your best friend in these cases. Try the TextRenderer class (a GDI wrapper) as already suggested:
    http://msdn.microsoft.com/en-us/library/system.windows.forms.textrenderer.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's some code, k.Bind<IGame>().To<Game>().Named(A) .WithConstructorArgument(ColorChoiceCount, 12); iGame = k.Get<IGame>(A); ((Game)iGame).SelectedColor = new GameColor(System.Drawing.Color.Red); iGame
So here's some code I've written in Javascript: var panRate = 120; //Max speed
Here's some code: DirectorySearcher searcher = new DirectorySearcher(); searcher.Filter = (&(objectClass=user)(sAMAccountName= + lstUsers.SelectedItem.Text +
Here is some code: var class = function(elem,div){ this.elem= elem; this.div = div; this.init
Here's some code: OdbcConnection connection = new OdbcConnection(@DRIVER={MySQL ODBC 5.1 Driver};SERVER= + ip +
Can someone tell me where I'm going wrong here? basically I've written some code
I'm experimenting with Application.AddMessageFilter , using some code written originally by Somebody Else, so
Quickie here, I'm sure... I am going through some code written by a former
I have some old code written in C for 16-bit using Borland C++ that
I'm trying to analyse some code here that's been designed using an MVP Approach.

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.