Re: Calculate string width using some font.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, February 5, 2007 11:22 am, Juan Felipe Alvarez Saldarriaga wrote:
> 1. Create a dummy image.
> 2. Set the text there using font X and the font size Y (it seems that
> when I create the image it renders it at 72dpi so I need to reduce it
> at
> 300dpi)

When I did a 300-dpi PDF thingie, I defined a variable $resolution
which was 304.8, and multiplied it by the inches I wanted to get 300
dpi out...

I don't know *how* I got the 304.8 number...

> I'm  not sure what the imagettftext() function returns, are those
> values
> measured in pixels ?

I believe those are in raw pixels, yes.

> I read in some page that the proportion to reduce
> the image at 300dpi  is reduce the size to 24% of its original size.

You'd want to make it 300/72 times as large as you would think?

Only I obviously didn't do that, so I dunno...

> http://www.printingforless.com/resolution.html
>
> That's the code:
>
> ***
>
> // Create dummy image.
> $rsc_image = imagecreate( 1, 1 );
>
> // Set image.
> $arr_ftx = imagettftext( $rsc_image, $int_font_size, 0, 0, 0, -1,
> "./fonts/{$str_font_file}", $str_variable_value );
> // Destroy dummy image.
>  imagedestroy( $rsc_image );
>
> // Set structure of widths.
> // TODO: Magik numbers.
> $arr_variable_pixels[$str_variable_index] = ( ( $arr_ftx[2] * 24 ) /
> 100 );

I think you've got the percentage backwards here, as it's 24% to go
from 300 to 72...  You want to force a 72 DPI thing to end up being
scalable down by 24% to end up at 300.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux