Hello everybody!

For graphic button creation I used the PDF class for font width calculation which worked just fine and fast with ZF 1.0.3.

Now testing ZF 1.5 from trunk (as of 2. Feb. 08) I get huge performance problems executing the following lines:

protected function StringWidth($string)
        {
                $font = 
Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA);
                $fontSize = $this->_buttonFontSize * self::FONT_FACTOR;

                $drawingString = iconv('', 'UTF-16BE', $string);
            $characters = array();
            for ($i = 0; $i < strlen($drawingString); $i++)
            {
$characters[] = (ord($drawingString[$i++]) << 8) | ord($drawingString[$i]);
            }
            $glyphs = $font->glyphNumbersForCharacters($characters);
            $widths = $font->widthsForGlyphs($glyphs);
            $stringWidth = (array_sum($widths) / $font->getUnitsPerEm()) * 
$fontSize;
            return $stringWidth;
        }

I had to remove 'cmap' in '$glyphs = $font->cmap->glyphNumbersForCharacters($characters)' to get it working in 1.5.

Without it, page renders in 0.8 secs. With this code, it allways takes 20.0 secs! This is running on MAMP on an iMac (2Ghz, 2GB).

The original snippet is from http://framework.zend.com/issues/browse/ZF-313.

Any ideas whats causing this lack of performance?

Best Regards,
daniel

Reply via email to