[PHP] Re: All-in-one PHP Classes

2007-02-06 Thread setcookie
there are special design patterns for autoloading  classes and subclasses to
use only we needed at runtime! this together with singeltons pattern will
prevent any memory overflows. problem is that almost nobody implements these
patterns when designing standalone classes

fra*

Hello folks,

Have been reading posts daily for two months now on the list, and am very
pleased at how informative these can be.
I have noticed, many examples where one is pointed to using classes
downloadable on the internet.

Not a very big user of these classes my self (maybe a bit naïf in this
sense, but i just can't have unnecessary code loaded on an include() i like
to keep things clean and to a minimal)I decided to go through and look at
how they are built and what kind of code load we are talking about.
This is when i realized how often these classes that do everything are
very BIG. Now I realize how many functions this type of class can have and
how handy it can be for someone who does not want to code his own, and yes I
hear all the reinventing the wheel comments comming forth as well as
security etc, BUT (yes THE but) are general classes like this pushing to
using bigger, more bloated web application which require more and more
bandwidth/processor/ram, server-side?

Here, it's the programmer who is confronted with loading huge files into
memory to use just one perhaps two function in a 300+ functionality class..

At what moment does one decide to use an all-in-one bloated with out of
context functionality, php class, knowing how powerfull only several
functions in this class can be to him?

Shouldn't these classes be perhaps broken down into usefull parts.

Thanks for any input.

Regards,

Tim

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



Re: [PHP] Calculate string width using some font.

2007-02-05 Thread setcookie
pdf_stringwidth() may help you

regards fra*


  Hey list! :)
 
 
  my name's not list but what the heck:
 
  take a look at these function, they should light the way:
 
  http://php.net/manual/en/function.imageftbbox.php
  http://php.net/manual/en/function.imagepsbbox.php
  http://php.net/manual/en/function.imagettfbbox.php
  http://php.net/imageloadfont
 
  everything is pixels.
 
  there is no dpi - your screen  printer has a certain dpi and that
determine
  how big the image displays on either.
 
  okay not much help - I had brain freeze half thru.
 
 

 K, np, Ill try use imagettfbbox() function instead.

 Thx.
  I've got a problem trying to calculate a string width using an X font
  with some Y font size to use in an svg-to-pdf conversion.
 
  This is what I try to do:
  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)
 
  I'm  not sure what the imagettftext() function returns, are those
values
  measured in 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.
 
  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 );
 
  ***
 
  Thx for any help.
 
 
 
 
 

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