1#
2# $Id$
3#
4# Font specifications.
5#
6# This file, [source]d at initialization time, sets up the following
7# symbolic fonts based on the current platform:
8#
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
17#
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).
20#
21# +++ Platform notes:
22#
23# Windows:
24#	The default system font changed from "MS Sans Serif" to "Tahoma"
25# 	in Windows XP/Windows 2000.
26#
27#	MS documentation says to use "Tahoma 8" in Windows 2000/XP,
28#	although many MS programs still use "MS Sans Serif 8"
29#
30#	Should use SystemParametersInfo() instead.
31#
32# Mac OSX / Aqua:
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.
43#
44#	Note that the font for column headings (TkHeadingFont) is
45#	_smaller_ than the default font.
46#
47#	There does not appear to be any recommendations for fixed-width fonts.
48#
49# X11:
50#	Need a way to tell if Xft is enabled or not.
51#	For now, assume patch #971980 applied.
52#
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.
57#
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.
61#
62
63namespace eval ttk {
64
65set tip145 [catch {font create TkDefaultFont}]
66catch {font create TkTextFont}
67catch {font create TkHeadingFont}
68catch {font create TkCaptionFont}
69catch {font create TkTooltipFont}
70catch {font create TkFixedFont}
71catch {font create TkIconFont}
72catch {font create TkMenuFont}
73catch {font create TkSmallCaptionFont}
74
75if {!$tip145} {
76variable F	;# miscellaneous platform-specific font parameters
77switch -- [tk windowingsystem] {
78    win32 {
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"
83            } else {
84                set F(family) "MS Sans Serif"
85            }
86        } else {
87            if {[lsearch -exact [font families] Tahoma] != -1} {
88                set F(family) "Tahoma"
89            } else {
90                set F(family) "MS Sans Serif"
91            }
92        }
93	set F(size) 8
94
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) \
99	    -weight bold
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)
105    }
106    aqua {
107	set F(family) "Lucida Grande"
108	set F(fixed) "Monaco"
109	set F(menusize) 14
110	set F(size) 13
111	set F(viewsize) 12
112	set F(smallsize) 11
113	set F(labelsize) 10
114	set F(fixedsize) 11
115
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) \
120					-weight bold
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)
126    }
127    default -
128    x11 {
129	if {![catch {tk::pkgconfig get fontsystem} F(fs)] && $F(fs) eq "xft"} {
130	    set F(family) "sans-serif"
131	    set F(fixed)  "monospace"
132	} else {
133	    set F(family) "Helvetica"
134	    set F(fixed)  "courier"
135	}
136	set F(size) -12
137	set F(ttsize) -10
138	set F(capsize) -14
139	set F(fixedsize) -12
140
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) \
144			-weight bold
145	font configure TkCaptionFont -family $F(family) -size $F(capsize) \
146			-weight bold
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)
152    }
153}
154unset -nocomplain F
155}
156
157}
158
159#*EOF*
160