|
-
Jan 14th, 2003, 04:03 PM
#1
Thread Starter
Stuck in the 80s
Text Length
Is there a way to tell how many pixels certain text will take up?
-
Jan 14th, 2003, 06:08 PM
#2
Frenzied Member
how many pixels? well by depault it is 10px, but I take it that is not what you are after. if you want the same thing like an image on how many pixels it is then that is a good question.
why would you want to know this, for curiousity reasons?
-
Jan 14th, 2003, 06:14 PM
#3
I'm guessing he wants to know if there is a PHP equivelent function to VB .TextWidth's. I can see it would be usefull to know if, oh let's say, add text, just to use a nonspecific example, is going to take up more than 500pixels on someone's screen.
Then you could mak necessary adjustments to avoid a flood of backlash when the users of the site are suddenly subjected to the outrageous 72point sized text.
-
Jan 14th, 2003, 06:19 PM
#4
Frenzied Member
not that I am aware of. the only thing that would come close is strlen(), but that will noly tell you how many characters it has.
but how can it get to 75points if the webmaster doesn't set it that way? the pixel size is controlled by the browser unless you specificly state it in the css.
-
Jan 14th, 2003, 06:22 PM
#5
75points <> 75pixels.
If I set something to Size=5, I have no way of knowing if that's 100px, or 50px. Plus, what may look OK in one rez, looks completely whacko in another.
But then, I was just using it as an example.
-
Jan 14th, 2003, 06:46 PM
#6
Frenzied Member
well if you new your fonts then you should know what size is 5. it is expained at www.w3.org pretty well. but again the browser can only go so big.
I see where you are coming from and I do know that one size on one pc is different than another.
but again it is the webmaster not the user that sets the font size. os php would have no idea how big it is.
-
Jan 14th, 2003, 06:53 PM
#7
Thread Starter
Stuck in the 80s
I'll try to provide a specific example later...but I need a table cell's width to be a little more of the width of it's text.
I know that setting it to nothing would do that automatically...I'll try to provide an example later, but I'm busy now.
Thanks for your help so far.
-
Jan 14th, 2003, 06:56 PM
#8
Frenzied Member
actually that explains a lot and I hav eto tell you that php has little control, if none, over DOM so you would be better off with javascript.
-
Jan 15th, 2003, 08:14 AM
#9
Thread Starter
Stuck in the 80s
I really don't care what language does it. If you know how to do it in JS, then by all means, clue me in.
-
Jan 15th, 2003, 07:29 PM
#10
Thread Starter
Stuck in the 80s
Here is what I'm trying to do:
Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="10">
<table border="0" cellspacing="0" cellpadding="0" style="width: 100%;">
<tr>
<td height="5" bgcolor="#dba842"><img src="space.gif" height="5"></td>
</tr>
</table>
</td>
<td align="center" valign="middle" style="font-size: 9pt; width: 180px;"><b>' . $text . '</b></td>
<td>
<table border="0" cellspacing="0" cellpadding="0" style="width: 100%;">
<tr>
<td height="5" bgcolor="#dba842"><img src="space.gif" height="5"></td>
</tr>
</table>
</td>
</tr>
</table>
Is there any way I can do this? I never know what $text is going to be.
http://www.vbshelf.com/layout is an example of it. It's the orange line around "Compiler Companion v1.0"
Any ideas?
-
Jan 16th, 2003, 10:03 AM
#11
Frenzied Member
you know you could use strlen() on the $text and just add something to it for the width.
ex.
PHP Code:
$text_len = strlen("some text"); // 9
$width = $text_len +20;
<td align="center" valign="middle" style="font-size: 9pt; width: {$width}px;">
somethnig like that would work.
-
Jan 16th, 2003, 10:17 AM
#12
Oh, well, I get it now..... don't use width in the style.... try this instead....
Code:
PADDING-RIGHT: 5px; PADDING-LEFT: 5px
This will put 5pixels on the left and right of the TD cell.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|