I wanted to use characters from fonts such as Wingdings. To do this I used chr(n) where n is the character number.
To help identify the number for the character I wanted I adapted the font viewer from Mastering Perl TK.
The Perl for this is below in case anyone else wanted a similar thing.
You will find that there is a commented out line for an ‘Entry’ definition near the Mainloop command.
If this comment is removed and one added to the previous line you can see the characters in Entry boxes rather than as labels. I did alter the check box for weight to a pull down that has all the possible options for font weight. These are normal, bold, medium, book, light, demi and demibold.
Not all of these seem to change the characters appearance for all of the fonts.
use Tk; use strict; my (%char_num, $jc, %wg, %wg_res, $jrow, $jcol, $cou); require Tk::BrowseEntry; my $mw = MainWindow->new(-title => 'Font Viewer'); my $f = $mw->Frame->grid(-row => 0, -column => 0); my $family = 'Courier'; $jcol = 0; my $be = $f->BrowseEntry( -label => "Family:", -variable => \$family, -browsecmd => \&apply_font, )->grid(-row => 0, -column => $jcol); $be->insert('end', sort $mw->fontFamilies); $jcol += 1; my $size = 14; my $bentry = $f->BrowseEntry( -label => 'Size', -variable => \$size, -browsecmd => \&apply_font, )->grid(-row => 0, -column => $jcol); $bentry->insert('end', (3 .. 32)); $jcol += 1; my @weight_options = qw (normal bold medium book light demi demibold); my $weight = "normal"; $f->Optionmenu( -variable => \$weight, -options => [@weight_options], -command => \&apply_font, )->grid(-row => 0, -column => $jcol); $jcol += 1; my $slant = "roman"; $f->Checkbutton( -onvalue => "italic", -offvalue => "roman", -text => "Slant", -variable => \$slant, -command => \&apply_font, )->grid(-row => 0, -column => $jcol); $jcol += 1; my $underline = 0; $f->Checkbutton( -text => "Underline", -variable => \$underline, -command => \&apply_font, )->grid(-row => 0, -column => $jcol); $jcol += 1; my $overstrike = 0; $f->Checkbutton( -text => "Overstrike", -variable => \$overstrike, -command => \&apply_font, )->grid(-row => 0, -column => $jcol); #my $stext = "Sample Text"; # set up all characters my $stext = ''; for($jc = 1; $jc <= 255; $jc ++) { $stext .= chr($jc); } # add the lables and entries $jcol = -1; $jrow = 0; my $f2 = $mw->Frame->grid(-row => 1, -column => 0); for($cou = 1; $cou <= 255; $cou ++) { $jcol += 1; if($jcol >= 25) { $jcol = 0; $jrow += 2; } $f2->Label(-text => $cou, -justify => 'center')->grid(-row => $jro +w, -column => $jcol); $wg_res{$cou} = chr($cou); $wg{$cou}= $f2->Label(-text => $wg_res{$cou}, -justify => 'center' +, -bg => 'white')->grid(-row => $jrow+1, -column => $jcol, -padx => 1 +); # $wg{$cou} = $f2->Entry(-textvariable => \$wg_res{$cou}, -width => +3, -justify => 'center')->grid(-row => $jrow + 1, -column => $jcol); } my $sample; &apply_font; MainLoop; sub apply_font { my $jwg; foreach $jwg (sort {$a <=> $b} keys %wg) { $wg{$jwg}->configure(-font => [-family => $family, -size => $size, -weight => $weight, -slant => $slant, -underline => $underline, -overstrike => $overstrike ], ); } }

In reply to Font Character Number Viewer by merrymonk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.