472,971 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,971 software developers and data experts.

Labels and optimising font size



--

Hi,

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?

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?

Mike B
Jun 27 '08 #1
2 2427
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
<mi**@borrowdale.me.ukwrote:
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
Jun 27 '08 #2
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
<mi**@borrowdale.me.ukwrote:
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


--

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Chris Coho, Jr. | last post by:
Ok, I'll explain the whole problem because there may be several ways to solve this and hopefully someone knows one. What I'm doing is creating a specialty template editor, similar to say a corel...
2
by: qumpus | last post by:
My program right now generates USPS style shipping label using System.Drawing.Graphics. It works fine except that the printer prints really slowly. I want to make my program take advantage of true...
1
by: Kyle Blaney | last post by:
When labels are vertically stacked on top of one another and have their TextAlign property set to MiddleRight, the text is not properly right-aligned. You can reproduce this problem by creating...
2
by: Woody Splawn | last post by:
When placing labels and text boxes on winforms they are coming up by default in a size that is just a little too small. How do I change this so that in the future they will come up with a bigger...
1
by: ken | last post by:
Hi, How do you change the font for the data labels on your bar graph report/chart? I have 24 series, and when I change the font of the data label for one series that does not change them all......
3
by: mikeyatsony | last post by:
hi all... what is the easy way to have users print results from a query to avery labels using a web app through internet explorer. thoughts? thanks
3
by: Allen Maki | last post by:
Hi Everybody, I am new to Famework Programming and I need your help. In Visual C++ .NET
29
by: FredBear | last post by:
I am just coming to grips with php, Dreamweaver and MySQL and I want to make a facility available for the members of the group I am creating my web site for. I want them to be able to print-out a...
5
by: Mel | last post by:
I created a header that adjusts with the size of the browser windows. How do I place labels in the header section so they also maintain their position when the window is resized? One of the labels...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.