2 # $Id: fonts.tcl,v 1.11 2007/12/13 15:27:08 dgp Exp $
6 # This file, [source]d at initialization time, sets up the following
7 # symbolic fonts based on the current platform:
9 # TkDefaultFont -- default for GUI items not otherwise specified
10 # TkTextFont -- font for user text (entry, listbox, others)
11 # TkFixedFont -- standard fixed width font
12 # TkHeadingFont -- headings (column headings, etc)
13 # TkCaptionFont -- dialog captions (primary text in alert dialogs, etc.)
14 # TkTooltipFont -- font to use for tooltip windows
15 # TkIconFont -- font to use for icon captions
16 # TkMenuFont -- used to use for menu items
18 # In Tk 8.5, some of these fonts may be provided by the TIP#145 implementation
19 # (On Windows and Mac OS X as of Oct 2007).
24 # The default system font changed from "MS Sans Serif" to "Tahoma"
25 # in Windows XP/Windows 2000.
27 # MS documentation says to use "Tahoma 8" in Windows 2000/XP,
28 # although many MS programs still use "MS Sans Serif 8"
30 # Should use SystemParametersInfo() instead.
33 # Quoth the Apple HIG:
34 # The _system font_ (Lucida Grande Regular 13 pt) is used for text
35 # in menus, dialogs, and full-size controls.
36 # [...] Use the _view font_ (Lucida Grande Regular 12pt) as the default
37 # font of text in lists and tables.
38 # [...] Use the _emphasized system font_ (Lucida Grande Bold 13 pt)
39 # sparingly. It is used for the message text in alerts.
40 # [...] The _small system font_ (Lucida Grande Regular 11 pt) [...]
41 # is also the default font for column headings in lists, for help tags,
42 # and for small controls.
44 # Note that the font for column headings (TkHeadingFont) is
45 # _smaller_ than the default font.
47 # There does not appear to be any recommendations for fixed-width fonts.
50 # Need a way to tell if Xft is enabled or not.
51 # For now, assume patch #971980 applied.
53 # "Classic" look used Helvetica bold for everything except
54 # for entry widgets, which use Helvetica medium.
55 # Most other toolkits use medium weight for all UI elements,
56 # which is what we do now.
58 # Font size specified in pixels on X11, not points.
59 # This is Theoretically Wrong, but in practice works better; using
60 # points leads to huge inconsistencies across different servers.
65 set tip145
[catch {font create TkDefaultFont
}]
66 catch {font create TkTextFont
}
67 catch {font create TkHeadingFont
}
68 catch {font create TkCaptionFont
}
69 catch {font create TkTooltipFont
}
70 catch {font create TkFixedFont
}
71 catch {font create TkIconFont
}
72 catch {font create TkMenuFont
}
73 catch {font create TkSmallCaptionFont
}
76 variable F
;# miscellaneous platform-specific font parameters
77 switch -- [tk windowingsystem
] {
79 # In safe interps there is no osVersion element.
80 if {[info exists tcl_platform
(osVersion
)]} {
81 if {$tcl_platform(osVersion
) >= 5.0} {
82 set F
(family
) "Tahoma"
84 set F
(family
) "MS Sans Serif"
87 if {[lsearch -exact [font families
] Tahoma
] != -1} {
88 set F
(family
) "Tahoma"
90 set F
(family
) "MS Sans Serif"
95 font configure TkDefaultFont
-family $F(family
) -size $F(size
)
96 font configure TkTextFont
-family $F(family
) -size $F(size
)
97 font configure TkHeadingFont
-family $F(family
) -size $F(size
)
98 font configure TkCaptionFont
-family $F(family
) -size $F(size
) \
100 font configure TkTooltipFont
-family $F(family
) -size $F(size
)
101 font configure TkFixedFont
-family Courier
-size 10
102 font configure TkIconFont
-family $F(family
) -size $F(size
)
103 font configure TkMenuFont
-family $F(family
) -size $F(size
)
104 font configure TkSmallCaptionFont
-family $F(family
) -size $F(size
)
107 set F
(family
) "Lucida Grande"
108 set F
(fixed
) "Monaco"
116 font configure TkDefaultFont
-family $F(family
) -size $F(size
)
117 font configure TkTextFont
-family $F(family
) -size $F(size
)
118 font configure TkHeadingFont
-family $F(family
) -size $F(smallsize
)
119 font configure TkCaptionFont
-family $F(family
) -size $F(size
) \
121 font configure TkTooltipFont
-family $F(family
) -size $F(smallsize
)
122 font configure TkFixedFont
-family $F(fixed
) -size $F(fixedsize
)
123 font configure TkIconFont
-family $F(family
) -size $F(size
)
124 font configure TkMenuFont
-family $F(family
) -size $F(menusize
)
125 font configure TkSmallCaptionFont
-family $F(family
) -size $F(labelsize
)
129 if {![catch {tk::pkgconfig get fontsystem
} F
(fs
)] && $F(fs
) eq
"xft"} {
130 set F
(family
) "sans-serif"
131 set F
(fixed
) "monospace"
133 set F
(family
) "Helvetica"
134 set F
(fixed
) "courier"
141 font configure TkDefaultFont
-family $F(family
) -size $F(size
)
142 font configure TkTextFont
-family $F(family
) -size $F(size
)
143 font configure TkHeadingFont
-family $F(family
) -size $F(size
) \
145 font configure TkCaptionFont
-family $F(family
) -size $F(capsize
) \
147 font configure TkTooltipFont
-family $F(family
) -size $F(ttsize
)
148 font configure TkFixedFont
-family $F(fixed
) -size $F(fixedsize
)
149 font configure TkIconFont
-family $F(family
) -size $F(size
)
150 font configure TkMenuFont
-family $F(family
) -size $F(size
)
151 font configure TkSmallCaptionFont
-family $F(family
) -size $F(ttsize
)