tags:

views:

52

answers:

0

Hi, i'm currently trying to create an image with some text, the whole text and some options being dynamic. I've got it working to the point that the font used and the font size is dependent on input from the users, but when i tried changing the font style... well.. that's when it all got downhill.The code that generates the image is this :

    $draw->setFontStyle( Imagick:: STYLE_ITALIC );
 foreach ($tmp['values'] AS $k => $v){

    if (key_exists($k,$BC_LAYOUT[$templateNo])) {
        if (!is_array($v)){
            if (isset($tmp['values']['font_size'][$k]))
                $draw->setFontSize($tmp['values']['font_size'][$k]);
            $draw->setFont($fontRoot.$BC_FONTS[$tmp['values']['font'][$k]]['file']);
            $draw->annotation($BC_LAYOUT[$templateNo][$k]['x'],$BC_LAYOUT[$templateNo][$k]['y'],$v);
        }
        else {
            if (isset($tmp['values']['font_size'][$k]))
                $draw->setFontSize($tmp['values']['font_size'][$k]);
            $draw->setFont($fontRoot.$BC_FONTS[$tmp['values']['font'][$k]]['file']);
            $draw->annotation($BC_LAYOUT[$templateNo][$k]['x'],$BC_LAYOUT[$templateNo][$k]['y'],$v['label'].': '.$v['val']);
        }
    }
    else { /*

to do */} } the image is generated via ajax calls to this script that changes the text and such. the issue is that the first time i load the page, the font style is indeed italic, but after that, any change i do to the image, resets it to 0 {at least the visual, because calling getFontStyle returns the correct value}. also tried setFontStyle(2) but got the same results. Anyone know why this is happening, the documentation on imagick is quite lacking so i might do something really stupid there but dunno what...

also, if it matters, i'm using imagick on xampp for windows (sigh).