Re: Labels and optimising font size



Hi Peter,

sorry about the formatting thing. I didn't write those characters so
I'll go and practice where it doesn't matter until I understand what
I'm doing wrong.

Back to the questions. Padding is sort-of what I'm looking for. But
even with Padding = 0 there is still quite a large space around the
displayed text in a label. Increasing the padding increases the space
but, of course, one cannot decrease Padding from 0!

I will take a look at Graphics.MeasureString() and
extRenderer.MeasureText() to see how I can use them to predict the text
size to use. Thank you for the advice.

Mike


Peter Duniho wrote:

First suggestion: don't put the characters "-- " in your post except
for the actual purpose of separating a signature from the rest of
your post. Many newsreaders (including my own) format the signature
differently, and also strip signatures out from quotes by default.
The way you wrote you post, the entire message appeared to be a
signature and thus was difficult to read and needed special handling
just to quote it.

Please don't do that. :)

As far as the question goes:

On Sun, 15 Jun 2008 10:25:53 -0700, Mike Borrowdale
<mike@xxxxxxxxxxxxxxxx> wrote:

my application simulates a panel of scientific instruments. Digital
readouts are provided by label components embedded in a
TableLayoutPanel with the rows and columns set to percentages of
size, so the labels expane and contract when the application is
resized. So far so good. My customer wants the maximum text size
possible for easy readability, but the labels seem to require a lot
of 'white space' around any text they are given. Seems to be about
20% of height and possibly more of width is empty space. Is there
any way to reduce that unused area?

It's hard to know exactly what part of the formatting you're asking
about, but you may want to look at the Margin and Padding
proeprties. These control external and internal whitespace for the
control.

Second problem occurs on resize of the application - is there a way
to determine the maximum size of font that will fit in the
available label size without clipping the text?

There's not any direct way, but you can measure the text with the
Graphics.MeasureString() or TextRenderer.MeasureText() methods and
compare that to the size of the control.

Fonts don't scale in a perfectly linear fashion, so the only 100%
accurate way to do that is to iteratively check larger and larger
font sizes until you find one that doesn't fit. However, you can
use a ratio-based calculation to get pretty close using just one
measurement (measure the text at a specific size, then calculate the
ratio of the resulting size to the size of the control...then apply
the ratio to the size you measured to get the maximum size
possible). If you can live with the text occasionally not fitting
perfectly, or you can provide a little extra white space to account
for the times it's a little off, that would be fine.

Pete



--

.



Relevant Pages

  • Re: missing print forms
    ... As you know, I'm not a willing apologist for Microsoft, but on a quick overview of your concerns, I have a feeling this isn't a problem caused by the OS, but instead is due to charges in design elements on the two printers or perhaps changes in the paper path. ... I've also found that WP is much more convienent for formatting documents as the format follows the document for printer setup, whereas MS Word can sometimes present printer formatting difficulties with two places to deal with such formats. ... One is that one of the Avery label formats that worked fine with the HP 5p printer I just replaced prints out with a different left margin and screws up this one label set. ... I'm sure that having both paper guides move toward the center simplifies the paper feed mechanism and probably would prevent skewing in some cases. ...
    (comp.periphs.printers)
  • Re: missing print forms
    ... formatting documents as the format follows the document for printer setup, ... prints out with a different left margin and screws up this one label set. ... I could have adjusted the margin in the Avery ... The other problem has to do with the paper guides. ...
    (comp.periphs.printers)
  • Re: Oh, Canada! Mailing address issues.
    ... Canadian postal code ... 9-Digit US StrZip code ... > I guess what I really have is a formatting issue. ... >> problem than a label problem. ...
    (microsoft.public.access.forms)
  • Re: How can I report a bug to Microsoft , regarding Windows XP ?
    ... I am not talking about me, I am talking about every simple user who doesn't know that - I recommend to block the user from entering more than 11 characters for Volume label *before* formatting. ... "Lior Bobrov" wrote in message ...
    (microsoft.public.windowsxp.general)
  • Re: Labels-single spacing - how to make default Word 2007
    ... the Label Options dialog box when used with Mail Merge. ... dialog box to create the label definition then the padding will not be ... If you follow the commands on the Mailings tab for mail merge from ... Regarding adding the "Main Document Setup" command to the QAT, ...
    (microsoft.public.word.pagelayout)