473,738 Members | 10,643 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Labels and optimising font size



--

Hi,

my application simulates a panel of scientific instruments. Digital
readouts are provided by label components embedded in a
TableLayoutPane l 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 2480
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**@borrowdal e.me.ukwrote:
my application simulates a panel of scientific instruments. Digital
readouts are provided by label components embedded in a
TableLayoutPane l 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.Measur eString() or TextRenderer.Me asureText() 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.Measur eString() and
extRenderer.Mea sureText() 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**@borrowdal e.me.ukwrote:
my application simulates a panel of scientific instruments. Digital
readouts are provided by label components embedded in a
TableLayoutPane l 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.Measur eString() or TextRenderer.Me asureText() 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
9506
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 draw (but for specific uses). What I need to be able to do is import graphics and text and then move them around the background until they are where I want them and then export it out as an image file. The problem is that I need to be able to...
2
3467
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 type fonts. So I assume it's possible to send Font Type and the text to the printer, and the printer should digest and print faster. Still, barcode info needs to be sent as an image. When I print fifty copies of the same label it prints really...
1
7491
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 a blank form with three private members (label1, label2, and label3) and adding the following code to the form's constructor: // BEGIN CODE
2
15036
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 font size?
1
7853
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... Also in design view I only have 3 series displayed...so I need a way to change all of them at once... If anyone knows how to do this I would really appreciate a hint. Thanks
3
3677
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
1414
by: Allen Maki | last post by:
Hi Everybody, I am new to Famework Programming and I need your help. In Visual C++ .NET
29
15448
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 list of address labels, using standard Avery labels, on their home PC's using the data from my MySQL tables. I am not yet sufficiently au fait with php to manage to code it myself so I wondered if anybody knew of any Dreamweaver extensions, add-ins...
5
2385
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 is constant but the rest will be entered programmatically, for example, the users name, their company, city, state and zip. My example code: <body> <form id="form1" runat="server">
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9476
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9335
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.