Hi!
Looking at bug report #5523, I saw the following:

>The script crashes reproducable when called with the standard settings.
>I have checked that the selected font is installed. The problems seems to
>be located in text_fontname_invoker (), so the problem migth be a bug in 
>the gimp core.

Having experimented the same problem with fit-text, I dived deep into the code.
I thus discovered that the subroutine growfont has an error in the syntax, albeit
the syntax is correct and gets accepted by perl:

sub growfont {
        ($fontname, $plussize) = @_;
        @fontdesc = split /-/, $fontname;
        $fontdesc[8] eq "*" ?  
                $fontdesc[7] += $plussize/72 : # if in pixels  
                $fontdesc[8] += $plussize;     # if in points
        $outname = join "-", @fontdesc;
        print ("!!!${fontdesc[8]}-${fondesc[9]}!!!\n");
        $calls ++;
        return $outname;
        }

This will never do what was intented by the author: $fontdesc[7] won't get the
correct value, if font size is in pixels. For example, with the default
helvetica@34 setting, $fontdesc[7] should be: 34 + (288/72) = 38.
But the first time the subroutine is called, the seventh fontdescriptor gets a
value of 326!!, and at the end of the script, at the crash moment,
get_text_fontname is called with a font size argument of -112, which of course
doesn't make sense, and causes the sigsegv.

Having corrected the subroutine as follows:

sub growfont {
        ($fontname, $plussize) = @_;
        @fontdesc = split /-/, $fontname;
        $fontdesc[8] eq "*" ?  ($fontdesc[7] += $plussize/72) : ($fontdesc[8]+= 
$plussize);
        $outname = join "-", @fontdesc; 
        print ("!!!${fontdesc[7]}-${fontdesc[8]}!!!\n");
        $calls ++;
        return $outname;
        }

everything worked fine!!, the fit-text didn't segfault anymore....
Any comments??
Mike

Reply via email to