.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Tk::FontDialog 3pm" .TH Tk::FontDialog 3pm "2017-07-14" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Tk::FontDialog \- a font dialog widget for perl/Tk .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Tk::FontDialog; \& $font = $top\->FontDialog\->Show; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Tk::FontDialog implements a font dialog widget. .PP The dialog is displayed by calling the \fBShow\fR method. The returned value is either the selected font (if the dialog was closed with the Ok button) or undef (otherwise). The exact type of the return value is either a Tk::Font object (in Tk800) or a font name string (usually something like \f(CW\*(C`font1\*(C'\fR). Both can be used as values in Tk \f(CW\*(C`\-font\*(C'\fR options. See \*(L"GetDescriptiveFontName\*(R" .PP In the Family and Size listboxes, the font family and font size can be specified. The checkbuttons on the right turn on bold, italic, underlined and overstriked variants of the chosen font. A sample of the font is shown in the middle area. .PP With the \*(L"Alt sample\*(R" checkbutton, it is possible to show all characters in the charset instead of the default text. \*(L"Fixed only\*(R" restricts the font family list to fixed fonts only. If the \*(L"Nicefonts\*(R" checkbutton is set, then the font names in the listbox are displayed in the corresponding font. Note that this option can be slow if a lot of fonts are installed or for 16 bit fonts. .PP A click with the right button in the font size listbox pops up a window to enter arbitrary font sizes. .SH "WIDGET-SPECIFIC OPTIONS" .IX Header "WIDGET-SPECIFIC OPTIONS" .IP "\-font" 4 .IX Item "-font" The dialog font. .IP "\-initfont" 4 .IX Item "-initfont" The initial font. .IP "\-fontsizes" 4 .IX Item "-fontsizes" A list of font sizes. The default contains sizes from 0 to 72 points (\s-1XXX\s0 or pixels?). .IP "\-nicefont" 4 .IX Item "-nicefont" If set, font names are displayed in its font style. This may be slow, especially if you have many fonts or 16 bit fonts (e.g. Asian fonts). .IP "\-nicefontsbutton" 4 .IX Item "-nicefontsbutton" If set to false, then the \*(L"Nice fonts\*(R" button is not displayed. .IP "\-fixedfont" 4 .IX Item "-fixedfont" If set, proportional font families are not listed, leaving only the fixed fonts. This is slow, as each font must be checked to see if it is fixed or proportional. .IP "\-fixedfontsbutton" 4 .IX Item "-fixedfontsbutton" If set to false, then the \*(L"Fixed fonts\*(R" button is not displayed. .IP "\-sampletext" 4 .IX Item "-sampletext" The sample text which should contain all letters. The default is \*(L"The Quick Brown Fox Jumps Over The Lazy Dog\*(R" German readers may probably use \*(L"Franz jagt im komplett verwahrlosten Taxi quer durch Bayern\*(R". .SH "INTERNATIONALIZATION" .IX Header "INTERNATIONALIZATION" There are a couple of options to change the labels of the dialog. Note that you can prepend a tilde (\f(CW\*(C`~\*(C'\fR) to get an accelerator key with \&\f(CW\*(C`Alt\*(C'\fR. Here is a list of these options with the default (English) setting: .IP "\-familylabel (Family:)" 4 .IX Item "-familylabel (Family:)" .PD 0 .IP "\-sizelabel (Size:)" 4 .IX Item "-sizelabel (Size:)" .IP "\-weightlabel (Bold)" 4 .IX Item "-weightlabel (Bold)" .IP "\-slantlabel (Italic)" 4 .IX Item "-slantlabel (Italic)" .IP "\-underlinelabel (Underline)" 4 .IX Item "-underlinelabel (Underline)" .IP "\-overstrikelabel (Overstrike)" 4 .IX Item "-overstrikelabel (Overstrike)" .IP "\-oklabel (\s-1OK\s0)" 4 .IX Item "-oklabel (OK)" .IP "\-applylabel (Apply)" 4 .IX Item "-applylabel (Apply)" .IP "\-cancellabel (Cancel)" 4 .IX Item "-cancellabel (Cancel)" .IP "\-altsamplelabel (Alt sample)" 4 .IX Item "-altsamplelabel (Alt sample)" .IP "\-nicefontslabel (Nicefonts)" 4 .IX Item "-nicefontslabel (Nicefonts)" .IP "\-fixedfontslabel (Fixed Only)" 4 .IX Item "-fixedfontslabel (Fixed Only)" .IP "\-title (Choose font)" 4 .IX Item "-title (Choose font)" .IP "\-customsizetitle (Choose font size)" 4 .IX Item "-customsizetitle (Choose font size)" .PD .SH "METHODS IN Tk::Widget" .IX Header "METHODS IN Tk::Widget" .IP "\fBRefontTree\fR(\-font => \fI\f(CI$font\fI\fR)" 4 .IX Item "RefontTree(-font => $font)" Additionally, the convenience method \fBRefontTree\fR is defined in the Tk::Widget namespace. Using this method a font definition could be applied to a complete subtree of a widget. This is similar to the method \fBRecolorTree\fR. Calling \fBRefontTree\fR looks like this: .Sp .Vb 2 \& $font = $mw\->FontDialog\->Show; \& $mainwindow\->RefontTree(\-font => $font) if defined $font; .Ve .Sp By default RefontTree does not change the font of canvas elements. This can be done by specifying \f(CW\*(C`\-canvas => 1\*(C'\fR. .IP "\fBGetDescriptiveFontName\fR(\fI\f(CI$fontname\fI\fR)" 4 .IX Item "GetDescriptiveFontName($fontname)" Return a \*(L"descriptive\*(R" font name (just like form [3] as described in Tk::Font). The return value from the \fIShow()\fR method has the disadvantage that it is only valid for the current Tk session. A \&\*(L"descriptive\*(R" font name may be stored and reused later. .SH "CAVEAT" .IX Header "CAVEAT" Note that font names with whitespace like \*(L"New century schoolbook\*(R" or \&\*(L"\s-1MS\s0 Sans Serif\*(R" can cause problems when using in a \-font option. The solution is to put the names in Tcl-like braces, like .PP .Vb 1 \& \-font => "{New century schoolbook} 10" .Ve .SH "EXAMPLES" .IX Header "EXAMPLES" To apply a selected font to a specific widget, use the following snippet: .PP .Vb 4 \& $font = $mw\->FontDialog\->Show; \& if (defined $font) { \& $button\->configure(\-font => $font); \& } .Ve .PP This example uses the convenience method \fBRefontTree\fR to apply the new font to the whole application: .PP .Vb 10 \& use Tk; \& use Tk::FontDialog; \& $mw = tkinit; \& $mw\->Label(\-text => "Test")\->pack; \& $mw\->Button(\-text => "Another test")\->pack; \& $mw\->Button(\-text => "Use Tk::FontDialog", \& \-command => sub { \& my $font = $mw\->FontDialog\->Show; \& if (defined $font) { \& $mw\->RefontTree(\-font => $font); \& } \& })\->pack; \& MainLoop; .Ve .PP To get the \*(L"descriptive\*(R" font name: .PP .Vb 5 \& $font = $mw\->FontDialog\->Show; \& if (defined $font) { \& $font_descriptive = $mw\->GetDescriptiveFontName($font); \& print $font_descriptive, "\en"; \& } .Ve .SH "AVAILABILITY" .IX Header "AVAILABILITY" The latest released version is available from cpan (e.g. ). The latest development version is available from github (). .SH "BUGS/TODO" .IX Header "BUGS/TODO" .Vb 6 \& \- ConfigSpecs handling is poor \& put at least \-font into configspecs \& \- run test, call dialog for 2nd time: immediate change of font? \& \- better name for nicefont \& \- restrict on charsets and encodings (xlsfonts? X11::Protocol::ListFonts?) \& difficult because core Tk font handling ignores charsets and encodings .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" Tk::Font .SH "AUTHOR" .IX Header "AUTHOR" Slaven Rezic .PP Suggestions by Michael Houghton, Martin Thurn, Jack, Justin Kozlowitz and others. .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 1998,1999,2003,2004,2005,2010 Slaven Rezic. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.