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:: isPointSize
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.
70 An instance of link::Classes/Float::.
73 Create a new monospace face Font.
75 An instance of link::Classes/Float::.
78 Create a new serif face Font.
80 An instance of link::Classes/Float::.
85 Gets/sets the name of the font.
87 An instance of link::Classes/String::.
90 Gets/sets the size of the font.
91 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.::
97 note::Only in Qt GUI::
98 A Boolean variable indicating whether the link::#-size:: is regarded as pixel-size (precise amount of pixels), or point-size (adapting to screen resolution).
99 To change this, you need to set the size via link::#-pixelSize:: or link::#-pointSize::.
102 note::Only in Qt GUI::
103 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.
105 Any number, but note that floats will be rounded to integer values when setting pixel-size.
109 note::Only in Qt GUI::
110 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.
115 Makes the current instance of Font the default.
119 Returns:: an link::Classes/Array::, code:: [ name, size ] ::.
123 note:: On the Cocoa GUI it appendes teletype::"-Bold":: to the name. This is only useful for fonts that have bold
127 Bold variant of the Font.
134 w = Window.new.front;
135 t = StaticText(w, w.view.bounds).align_(\center);
136 t.string=" SUPERCOLLIDER";
138 t.font = Font("Monaco", 24);
143 w = Window("Fonts", Rect(150, Window.screenBounds.height - 500, 400, 400)).front;
144 w.view.decorator = FlowLayout(w.view.bounds);
145 StaticText.new(w, Rect(5, 0, 30, 20)).string_("Font").align_(\rght);
146 m = PopUpMenu(w, Rect(40, 0, 250, 20));
147 m.items = Font.availableFonts;
149 StaticText.new(w, Rect(290, 0, 28, 20)).string_("Size").align_(\right);
150 y = PopUpMenu(w, Rect(322, 0, 50, 20));
151 y.items = ["6","7","8","9","10","12","13","14","18","24","36","48","60","72","96"];
153 t = TextView(w, Rect(10, 40, 380, 150));
154 t.string = "\nThe quick drowned fox jumped over the lazy blog. \n\n 0 1 2 3 4 5 6 7 8 9 ";
156 a = StaticText(w, 200@20).string_("The quick drowned fox").background_(Color.rand).align_(\center);
157 b = Button(w, 200@20).states_([["The quick drowned fox"]]).background_(Color.rand);
158 c = PopUpMenu(w, 200@20).items_(["The quick drowned fox"]).background_(Color.rand);
162 font = Font(m.items[m.value],y.items[y.value].asInteger);
163 a.font_(font).refresh;
164 b.font_(font).refresh;
165 c.font_(font).refresh;
166 t.font_(font).refresh;
179 w = Window("Fonts", Rect(128, 64, 340, 360));
180 w.view.decorator = f = FlowLayout(w.view.bounds,Point(4, 4),Point(4, 2));
190 var v, s, n, spec, p, height = 16;
192 v = StaticText(w, Rect(0, 0, 56, height + 2));
193 v.font = Font(name, 13);
196 s = Button(w, Rect(0, 0, 140, height + 2));
197 s.font = Font(name, 13);
200 n = NumberBox(w, Rect(0, 0, 56, height + 2));
201 n.font = Font(name, 13);
214 w = Window("Fonts", Rect(128, 64, 820, 760));
215 b = ScrollView(w, w.view.bounds);
217 b.decorator = f = FlowLayout(b.bounds, Point(4,4), Point(4,2));
219 Font.availableFonts.do({ arg name;
220 var v, s, n, spec, p, height = 16, font;
221 font = Font(name,13);
223 v = StaticText(b, Rect(0, 0, 56, height + 2));
227 s = Button(b, Rect(0, 0, 140, height + 2));
230 s.action = { font.asCompileString.postln; };
232 n = NumberBox(b, Rect(0, 0, 56, height + 2));
235 if( (i = i + 1) % 3 == 0,{