|
From: Russ A. <rus...@gm...> - 2009-03-20 03:12:55
|
Hello,
I'm using PHP with libming 0.4.2 to import a font from one swf into another
and use it in the second. In the process of working on this, I discovered a
potential bug. Here's the PHP:
$swf_font = new SWFMovie(8);
$swf_font->setDimension(100, 100);
$swf_font->setRate(30);
$f = new SWFFont("arial.ttf");
$fc = $swf_font->addFont($f);
$fc->addChars("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
$swf_font->addExport($fc,"arial");
$swf_font->save("arial_font.swf", 0);
$swf_impt = new SWFMovie(8);
$swf_impt->setDimension(11000, 8000);
$swf_impt->setRate(30);
$fc = $swf_impt->importFont("arial_font.swf","arial");
$swf_impt->add($fc);
$txtfield = new SWFTextField(SWFTEXTFIELD_NOEDIT);
$txtfield->setHeight(14);
$txtfield->setColor(0xff, 0x33, 0x33);
$txtfield->setFont($fc);
$txtfield->addString("ABC");
$swf_impt->add($txtfield);
$swf_impt->save("arial_import.swf", 0);
As you can see, in the first block I'm creating the font swf file. In the
second block I'm importing a font, which returns a SWFFontCharacter. Later
I try to SWFTextField::setFont() with SWFFontCharacter. If I'm reading
php_ming.c correctly, I should be able to SWFTextField::setFont() on a
SWFFontCharacter or a SWFFont. However, I'm getting a segfault on the
setFont method instead. I dug around a bit, and I think I know why.
In movie.c::SWFMovie_importFont, you see that it returns a dummy
SWFFontCharacter. In specific the SWFFontCharacter returned does not have
the "font" member specified. The segfault happens a little later in
blocks/font.c::SWFFont_getFlags().
I found that returning NULL from blocks/font.c::SWFFont_getFlags() at least
prevents the segfault, but this probably not the desired behavior.
Thanks,
Russ
|