473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Calculating text pixels

Hi,

Just wondering if there is a way in ASP, to calculate with of a string of
text in pixels. The result is to be used to set table width so that texts
don't get wrapped to second line.

Thank you.
Conway
Jul 19 '05 #1
6 4783
Conax wrote:
Just wondering if there is a way in ASP, to calculate with of a
string of text in pixels. The result is to be used to set table width
so that texts don't get wrapped to second line.


set the table width in em units

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #2
Thanks William.
Conway

"William Tasso" <ne****@tbdata.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Conax wrote:
Just wondering if there is a way in ASP, to calculate with of a
string of text in pixels. The result is to be used to set table width
so that texts don't get wrapped to second line.


set the table width in em units

--
William Tasso - http://WilliamTasso.com

Jul 19 '05 #3
Hi William,

I tested with the em unit but it created a table width much more than
required. Here's my test code:

<HTML>
<TABLE border="1" style="width:50em">
<TR>
<TD>
<FONT face="arial">123 56 8 012 456 890 2 45 7 9 1 3 5 7890 234 678 0</FONT>
</TD>
</TR>
</TABLE>
</HTML>

The result is like this:
123 56 8 012 456 890 2 45 7 9 1 3 5 7890 234 678 0
Can you (or someone) show me where I'm doing it wrong please?

Thank you.
Conway
"William Tasso" <ne****@tbdata.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Conax wrote:
Just wondering if there is a way in ASP, to calculate with of a
string of text in pixels. The result is to be used to set table width
so that texts don't get wrapped to second line.


set the table width in em units

--
William Tasso - http://WilliamTasso.com

Jul 19 '05 #4
On Tue, 11 Nov 2003 10:29:08 +1300, "Conax" <Co******@hotmail.com>
wrote:
Hi William,

I tested with the em unit but it created a table width much more than
required. Here's my test code:

<HTML>
<TABLE border="1" style="width:50em">
<TR>
<TD>
<FONT face="arial">123 56 8 012 456 890 2 45 7 9 1 3 5 7890 234 678 0</FONT>
</TD>
</TR>
</TABLE>
</HTML>

The result is like this:
123 56 8 012 456 890 2 45 7 9 1 3 5 7890 234 678 0


Read up on the definition of an "em". 1em = the width of the character
"M" in the current font. Given the fact that the font you are using is
probably proportional, not many (if any at all) of you numbers are as
wide as a captital M. Therefore, a space that is as wide as 50 "M"'s
will difinitely be wider than the characters you chose to put into it.

Now, to give a possible answer for your spacing delema, you might try
using <NOBR> </NOBR> and do not give a width property to the TD, but
some would say this is a bad idea.
Jul 19 '05 #5
Conax wrote:
"William Tasso" <ne****@tbdata.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Conax wrote:
Just wondering if there is a way in ASP, to calculate with of a
string of text in pixels. The result is to be used to set table
width so that texts don't get wrapped to second line.

set the table width in em units

I tested with the em unit but it created a table width much more than
required...


ok - Dan has already pointed at why this happens
The result is like this:
123 56 8 012 456 890 2 45 7 9 1 3 5 7890 234 678 0
Can you (or someone) show me where I'm doing it wrong please?


This does not look like tabular data. Is it a real example? Do you have a
URL?

--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #6
Thanks William and Dan,

Sorry William I don't have a URL as I'm testing on my own PC that cannot be
accessed from outside.

When I posted the result it had a table border on my screen around the
numbers but somehow that border is gone after the message reached the news
server...
But it was looking something like this:

| 123 56 8 012 456 890 2 45 7 9 1 3 5 7890 234 678 0
|

When it comes to worse, I can just use rough estimate of : (average
character width) x (number of characters) to calculate the table width. :)

Thank you all.
Conway

"William Tasso" <ne****@tbdata.com> wrote in message
news:Of**************@TK2MSFTNGP11.phx.gbl...
Conax wrote:
"William Tasso" <ne****@tbdata.com> wrote in message
news:Oo**************@TK2MSFTNGP10.phx.gbl...
Conax wrote:
Just wondering if there is a way in ASP, to calculate with of a
string of text in pixels. The result is to be used to set table
width so that texts don't get wrapped to second line.
set the table width in em units
I tested with the em unit but it created a table width much more than
required...


ok - Dan has already pointed at why this happens
The result is like this:
123 56 8 012 456 890 2 45 7 9 1 3 5 7890 234 678 0
Can you (or someone) show me where I'm doing it wrong please?


This does not look like tabular data. Is it a real example? Do you have

a URL?

--
William Tasso - http://WilliamTasso.com

Jul 19 '05 #7

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

Similar topics

25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
2
by: grayFalcon | last post by:
Hello! I've got a small problem here. I'm trying to write some code that would generate a drop-down menue for me, where I'd just need to enter the menu- and submenu items into an array. The...
4
by: Philip K | last post by:
I write software that needs to draw simple engineering drawings for factory workers to read. A standard for drawings is to be able to read the text from the bottom right corner. The GDI...
1
by: Nathan Sokalski | last post by:
I want to make a table of links on my page. However, because different users will have different screen widths, I will need to calculate the number of columns based on the screen width and width of...
3
by: Nathan Sokalski | last post by:
I am using GDI+ to generate buttons in my application. Because I want the left and right edges of the buttons to be a certain number of pixels from the start and end of the text, I need to know (or...
7
by: Yeah | last post by:
Ever since I upgraded my Windows display to 120 DPI (kind of a necessary change), fonts have been clearer and graphics have been crisper. However, the 25% automatic increase in the text size on my...
6
by: kklickman | last post by:
I've got a page with two columns: one floats left, the other doesn't float. The page displays fine in Netscape no matter what. In IE (both 6 and 7), it looks fine as long as the browser window is...
3
by: =?Utf-8?B?SlIx?= | last post by:
I would like to add text to an image. I have tried to use DrawString and it works on some images but on others it is very very small. I am pretty sure it has something to do with the size of the...
1
by: Desser | last post by:
CSS Newbee. I need to have lesser space between the h1 and the paragraph text. My header is 28 pixels and the body text is 12 pixels. How do I do this? Here is my CSS:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.