3 summary:: A font object
4 categories:: GUI>Accessories
7 This is the object you pass to other gui objects to set their font name or size.
16 note:: The strong::bold::, strong::italic:: and strong::isPointSize:: arguments are only available in Qt GUI.
20 An instance of link::Classes/String::. Must coincide with the name of a font on the system. See link::#*availableFonts::.
23 An instance of link::Classes/Float::.
31 argument:: usePointSize
32 A Boolean. Whether to regard the strong::size:: argument as point-size - adapting to the screen resolution.
37 g = Font("Helvetica", 12);
40 method:: availableFonts
42 link::Classes/Array:: of the available fonts.
46 An instance of link::Classes/Boolean::. Default value is code::false::.
50 An instance of link::Classes/Boolean::. Default value is code::false::.
52 method:: defaultSansFace
54 The default sans serif face Font.
56 method:: defaultSerifFace
58 The default serif face Font.
60 method:: defaultMonoFace
62 The default monospace face Font.
65 Gets/sets the default Font.
68 Create a new sans serif face Font.
71 Create a new monospace face Font.
74 Create a new serif face Font.
79 Gets/sets the name of the font.
81 An instance of link::Classes/String::.
84 Gets/sets the size of the font.
85 note:: In Qt GUI, setting this variable is always considered as setting the link::#-pixelSize::, while getting it will return any size set. In other GUI kits, size is always considered as pixel-size anyway. See link::#-hasPointSize:: for distinction.::
91 note::Only in Qt GUI::
92 A Boolean variable indicating whether the link::#-size:: is regarded as pixel-size (precise amount of pixels), or point-size (adapting to screen resolution).
93 To change this, you need to set the size via link::#-pixelSize:: or link::#-pointSize::.
96 note::Only in Qt GUI::
97 Gets or sets the pixel-size of the font. When getting, returns nil if the font has point-size instead. See link::#-hasPointSize:: for distinction.
99 Any number, but note that floats will be rounded to integer values when setting pixel-size.
103 note::Only in Qt GUI::
104 Gets or sets the point-size of the font. When getting, returns nil if the font has pixel-size instead. See link::#-hasPointSize:: for distinction.
109 Makes the current instance of Font the default.
113 Returns:: an link::Classes/Array::, code:: [ name, size ] ::.
117 note:: On the Cocoa GUI it appendes teletype::"-Bold":: to the name. This is only useful for fonts that have bold
121 Bold variant of the Font.
128 w = Window.new.front;
129 t = StaticText(w, w.view.bounds).align_(\center);
130 t.string=" SUPERCOLLIDER";
132 t.font = Font("Monaco", 24);
137 w = Window("Fonts", Rect(150, Window.screenBounds.height - 500, 400, 400)).front;
138 w.view.decorator = FlowLayout(w.view.bounds);
139 StaticText.new(w, Rect(5, 0, 30, 20)).string_("Font").align_(\rght);
140 m = PopUpMenu(w, Rect(40, 0, 250, 20));
141 m.items = Font.availableFonts;
143 StaticText.new(w, Rect(290, 0, 28, 20)).string_("Size").align_(\right);
144 y = PopUpMenu(w, Rect(322, 0, 50, 20));
145 y.items = ["6","7","8","9","10","12","13","14","18","24","36","48","60","72","96"];
147 t = TextView(w, Rect(10, 40, 380, 150));
148 t.string = "\nThe quick drowned fox jumped over the lazy blog. \n\n 0 1 2 3 4 5 6 7 8 9 ";
150 a = StaticText(w, 200@20).string_("The quick drowned fox").background_(Color.rand).align_(\center);
151 b = Button(w, 200@20).states_([["The quick drowned fox"]]).background_(Color.rand);
152 c = PopUpMenu(w, 200@20).items_(["The quick drowned fox"]).background_(Color.rand);
156 font = Font(m.items[m.value],y.items[y.value].asInteger);
157 a.font_(font).refresh;
158 b.font_(font).refresh;
159 c.font_(font).refresh;
160 t.font_(font).refresh;
173 w = Window("Fonts", Rect(128, 64, 340, 360));
174 w.view.decorator = f = FlowLayout(w.view.bounds,Point(4, 4),Point(4, 2));
184 var v, s, n, spec, p, height = 16;
186 v = StaticText(w, Rect(0, 0, 56, height + 2));
187 v.font = Font(name, 13);
190 s = Button(w, Rect(0, 0, 140, height + 2));
191 s.font = Font(name, 13);
194 n = NumberBox(w, Rect(0, 0, 56, height + 2));
195 n.font = Font(name, 13);
208 w = Window("Fonts", Rect(128, 64, 820, 760));
209 b = ScrollView(w, w.view.bounds);
211 b.decorator = f = FlowLayout(b.bounds, Point(4,4), Point(4,2));
213 Font.availableFonts.do({ arg name;
214 var v, s, n, spec, p, height = 16, font;
215 font = Font(name,13);
217 v = StaticText(b, Rect(0, 0, 56, height + 2));
221 s = Button(b, Rect(0, 0, 140, height + 2));
224 s.action = { font.asCompileString.postln; };
226 n = NumberBox(b, Rect(0, 0, 56, height + 2));
229 if( (i = i + 1) % 3 == 0,{