figenc

[RADIOACTIVE] rsa and symmetric key encryption scripts and executables
git clone git://git.figbert.com/figenc.git
Log | Files | Refs | README

fonts.tcl (5576B)


      1 #
      2 # Font specifications.
      3 #
      4 # This file, [source]d at initialization time, sets up the following
      5 # symbolic fonts based on the current platform:
      6 #
      7 # TkDefaultFont	-- default for GUI items not otherwise specified
      8 # TkTextFont	-- font for user text (entry, listbox, others)
      9 # TkFixedFont	-- standard fixed width font
     10 # TkHeadingFont	-- headings (column headings, etc)
     11 # TkCaptionFont -- dialog captions (primary text in alert dialogs, etc.)
     12 # TkTooltipFont	-- font to use for tooltip windows
     13 # TkIconFont	-- font to use for icon captions
     14 # TkMenuFont	-- used to use for menu items
     15 #
     16 # In Tk 8.5, some of these fonts may be provided by the TIP#145 implementation
     17 # (On Windows and Mac OS X as of Oct 2007).
     18 #
     19 # +++ Platform notes:
     20 #
     21 # Windows:
     22 #	The default system font changed from "MS Sans Serif" to "Tahoma"
     23 # 	in Windows XP/Windows 2000.
     24 #
     25 #	MS documentation says to use "Tahoma 8" in Windows 2000/XP,
     26 #	although many MS programs still use "MS Sans Serif 8"
     27 #
     28 #	Should use SystemParametersInfo() instead.
     29 #
     30 # Mac OSX / Aqua:
     31 #	Quoth the Apple HIG:
     32 #	The _system font_ (Lucida Grande Regular 13 pt) is used for text
     33 #	in menus, dialogs, and full-size controls.
     34 #	[...] Use the _view font_ (Lucida Grande Regular 12pt) as the default
     35 #	font of text in lists and tables.
     36 #	[...] Use the _emphasized system font_ (Lucida Grande Bold 13 pt)
     37 #	sparingly. It is used for the message text in alerts.
     38 #	[...] The _small system font_ (Lucida Grande Regular 11 pt) [...]
     39 #	is also the default font for column headings in lists, for help tags,
     40 #	and for small controls.
     41 #
     42 #	Note that the font for column headings (TkHeadingFont) is
     43 #	_smaller_ than the default font.
     44 #
     45 #	There does not appear to be any recommendations for fixed-width fonts.
     46 #
     47 # X11:
     48 #	Need a way to tell if Xft is enabled or not.
     49 #	For now, assume patch #971980 applied.
     50 #
     51 #	"Classic" look used Helvetica bold for everything except
     52 #	for entry widgets, which use Helvetica medium.
     53 #	Most other toolkits use medium weight for all UI elements,
     54 #	which is what we do now.
     55 #
     56 #	Font size specified in pixels on X11, not points.
     57 #	This is Theoretically Wrong, but in practice works better; using
     58 #	points leads to huge inconsistencies across different servers.
     59 #
     60 
     61 namespace eval ttk {
     62 
     63 variable tip145 [catch {font create TkDefaultFont}]
     64 catch {font create TkTextFont}
     65 catch {font create TkHeadingFont}
     66 catch {font create TkCaptionFont}
     67 catch {font create TkTooltipFont}
     68 catch {font create TkFixedFont}
     69 catch {font create TkIconFont}
     70 catch {font create TkMenuFont}
     71 catch {font create TkSmallCaptionFont}
     72 
     73 if {!$tip145} {
     74 variable F	;# miscellaneous platform-specific font parameters
     75 switch -- [tk windowingsystem] {
     76     win32 {
     77         # In safe interps there is no osVersion element.
     78 	if {[info exists tcl_platform(osVersion)]} {
     79             if {$tcl_platform(osVersion) >= 5.0} {
     80                 set F(family) "Tahoma"
     81             } else {
     82                 set F(family) "MS Sans Serif"
     83             }
     84         } else {
     85             if {[lsearch -exact [font families] Tahoma] != -1} {
     86                 set F(family) "Tahoma"
     87             } else {
     88                 set F(family) "MS Sans Serif"
     89             }
     90         }
     91 	set F(size) 8
     92 
     93 	font configure TkDefaultFont -family $F(family) -size $F(size)
     94 	font configure TkTextFont    -family $F(family) -size $F(size)
     95 	font configure TkHeadingFont -family $F(family) -size $F(size)
     96 	font configure TkCaptionFont -family $F(family) -size $F(size) \
     97 	    -weight bold
     98 	font configure TkTooltipFont -family $F(family) -size $F(size)
     99 	font configure TkFixedFont   -family Courier -size 10
    100 	font configure TkIconFont    -family $F(family) -size $F(size)
    101 	font configure TkMenuFont    -family $F(family) -size $F(size)
    102 	font configure TkSmallCaptionFont -family $F(family) -size $F(size)
    103     }
    104     aqua {
    105 	set F(family) "Lucida Grande"
    106 	set F(fixed) "Monaco"
    107 	set F(menusize) 14
    108 	set F(size) 13
    109 	set F(viewsize) 12
    110 	set F(smallsize) 11
    111 	set F(labelsize) 10
    112 	set F(fixedsize) 11
    113 
    114 	font configure TkDefaultFont -family $F(family) -size $F(size)
    115 	font configure TkTextFont    -family $F(family) -size $F(size)
    116 	font configure TkHeadingFont -family $F(family) -size $F(smallsize)
    117 	font configure TkCaptionFont -family $F(family) -size $F(size) \
    118 					-weight bold
    119 	font configure TkTooltipFont -family $F(family) -size $F(smallsize)
    120 	font configure TkFixedFont   -family $F(fixed)  -size $F(fixedsize)
    121 	font configure TkIconFont    -family $F(family) -size $F(size)
    122 	font configure TkMenuFont    -family $F(family) -size $F(menusize)
    123 	font configure TkSmallCaptionFont -family $F(family) -size $F(labelsize)
    124     }
    125     default -
    126     x11 {
    127 	if {![catch {tk::pkgconfig get fontsystem} F(fs)] && $F(fs) eq "xft"} {
    128 	    set F(family) "sans-serif"
    129 	    set F(fixed)  "monospace"
    130 	} else {
    131 	    set F(family) "Helvetica"
    132 	    set F(fixed)  "courier"
    133 	}
    134 	set F(size) -12
    135 	set F(ttsize) -10
    136 	set F(capsize) -14
    137 	set F(fixedsize) -12
    138 
    139 	font configure TkDefaultFont -family $F(family) -size $F(size)
    140 	font configure TkTextFont    -family $F(family) -size $F(size)
    141 	font configure TkHeadingFont -family $F(family) -size $F(size) \
    142 			-weight bold
    143 	font configure TkCaptionFont -family $F(family) -size $F(capsize) \
    144 			-weight bold
    145 	font configure TkTooltipFont -family $F(family) -size $F(ttsize)
    146 	font configure TkFixedFont   -family $F(fixed)  -size $F(fixedsize)
    147 	font configure TkIconFont    -family $F(family) -size $F(size)
    148 	font configure TkMenuFont    -family $F(family) -size $F(size)
    149 	font configure TkSmallCaptionFont -family $F(family) -size $F(ttsize)
    150     }
    151 }
    152 unset -nocomplain F
    153 }
    154 
    155 }
    156 
    157 #*EOF*