1 # fonts.tcl --
2 #
3 # Searches for, initializes, and adds some common fonts to the options
4 # database.
5 #
6 # Copyright (c) 1998-2002 The Regents of the University of California.
7 # All rights reserved.
8 #
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions are met:
11 #
12 # A. Redistributions of source code must retain the above copyright notice,
13 # this list of conditions and the following disclaimer.
14 # B. Redistributions in binary form must reproduce the above copyright notice,
15 # this list of conditions and the following disclaimer in the documentation
16 # and/or other materials provided with the distribution.
17 # C. Neither the names of the copyright holders nor the names of its
18 # contributors may be used to endorse or promote products derived from this
19 # software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
22 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
25 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #
32 # @(#) $Header: /usr/mash/src/repository/mash/mash-1/tcl/common/fonts.tcl,v 1.8 2002/08/27 02:48:50 weitsang Exp $
33
34
35 #
36 # Searches for, initializes, and adds some common fonts to the options database.
37 #
38 Class FontInitializer
39
40 #
41 # Search for some good fonts for the user interface and intial
42 # the configuration <i>options</i> accordingly.
43 #
44 FontInitializer public init {options} {
45 $options add_default foundry adobe
46
47 set foundry [$options get_option foundry]
48
49 set b b
50 set o o
51 foreach i {8 10 12 14 18 24 36 48} {
52 $options add_default helv$i [$self search_font $foundry helvetica medium $i r]
53 $options add_default helv$i$b [$self search_font $foundry helvetica bold $i r]
54 $options add_default helv$i$o [$self search_font $foundry helvetica bold $i o]
55 $options add_default times$i [$self search_font $foundry times medium $i r]
56 $options add_default times$i$b [$self search_font $foundry times bold $i r]
57 $options add_default times$i$o [$self search_font $foundry times bold $i o]
58 $options add_default courier$i [$self search_font $foundry courier medium $i r]
59 }
60
61 $options add_default tinyfont [$self get_option helv8]
62 $options add_default smallfont [$self get_option helv10b]
63 $options add_default medfont [$self get_option helv12b]
64 $options add_default helpFont [$self get_option times14]
65 $options add_default entryFont [$self get_option helv10]
66 $options add_default logofont [$self get_option times12o]
67 }
68
69 #
70 # Return the font specification for the provided font attributes: <br>
71 # <dd> <i>foundry</i>: adobe xerox linotype misc ...
72 # <dd> <i>style</i>: times helvetica lucida courier symbol ...
73 # <dd> <i>weight</i>: bold medium demibold demi normal book light ...
74 # <dd> <i>points</i>: 8 10 12 14 18 24 36 48 72 144 ...
75 # <dd> <i>slant</i>: i r o (meaning italic, roman/normal, oblique)
76 #
77 FontInitializer public search_font { foundry style weight points slant } {
78 global font tcl_version tcl_platform
79
80 if {$tcl_version >= 8} {
81 if {$slant == "r"} {
82 set slant ""
83 } elseif {$slant == "o"} {
84 set slant "italic"
85 }
86 if {$weight == "medium"} {
87 set weight ""
88 }
89 # make points negative since we use pixel size
90 return "$style -$points $weight $slant"
91 }
92
93 foreach f $font($style$points) {
94 set fname -$foundry-$style-$weight-$slant-$f
95 if [havefont $fname] {
96 return $fname
97 }
98 }
99
100 puts stderr "can't find $weight $fname font (using fixed)"
101 if ![havefont fixed] {
102 puts stderr "can't find fixed font"
103 exit 1
104 }
105 return fixed
106 }
107
108
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.