Tk::Error: font "bold14c" already exists at C:/Perl/site/lib/Tk/Submet +hods.pm line 19.
The message is referring to font(s) I created via:
$TOP->fontCreate(qw/bold14c -family courier -size 14 -weight b +old/); $TOP->fontCreate(qw/bold18h -family helvetica -size 18 -weight b +old/);
I'd like to embed a test for their existence (for those second-time-through-invocations) with something like
unless ( grep { $_->actual('-Name') =~ /bold14c/ } $TOP->fontNames ) { $TOP->fontCreate(qw/bold14c -family courier -size 14 -weight b +old/); $TOP->fontCreate(qw/bold18h -family helvetica -size 18 -weight b +old/); }
(assumes finding one font means don't need to check for the other font) but this doesn't seem to be the right way to extract the name of the font out of the object(s) that the fontNames method is kicking out for me. So the question is: how to know what the names of the fonts are since fontNames only kicks out objects?
Something that redisplays the Help screen with proper fonts is to do:
$TOP->fontDelete('bold18h', 'bold14c');
at the bottom of my sub that displays the Help (after it has succeeded) and just let the Help button do another fontCreate when reinvoked, but create/delete/create/delete/etc seems messy.
In reply to Tk fontCreate, fontNames errors (and fontDelete seems messy) by ff
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |