|
6 | 6 | text = cloudText,
|
7 | 7 | font = cloudFont,
|
8 | 8 | fontSize = cloudFontSize,
|
| 9 | + fontStyle = cloudFontNormal, |
| 10 | + fontWeight = cloudFontNormal, |
9 | 11 | rotate = cloudRotate,
|
10 | 12 | padding = cloudPadding,
|
11 | 13 | spiral = archimedeanSpiral,
|
|
25 | 27 | return {
|
26 | 28 | text: text.call(this, d, i),
|
27 | 29 | font: font.call(this, d, i),
|
| 30 | + style: fontStyle.call(this, d, i), |
| 31 | + weight: fontWeight.call(this, d, i), |
28 | 32 | rotate: rotate.call(this, d, i),
|
29 | 33 | size: ~~fontSize.call(this, d, i),
|
30 | 34 | padding: cloudPadding.call(this, d, i)
|
|
144 | 148 | return cloud;
|
145 | 149 | };
|
146 | 150 |
|
| 151 | + cloud.fontStyle = function(x) { |
| 152 | + if (!arguments.length) return fontStyle; |
| 153 | + fontStyle = d3.functor(x); |
| 154 | + return cloud; |
| 155 | + }; |
| 156 | + |
| 157 | + cloud.fontWeight = function(x) { |
| 158 | + if (!arguments.length) return fontWeight; |
| 159 | + fontWeight = d3.functor(x); |
| 160 | + return cloud; |
| 161 | + }; |
| 162 | + |
147 | 163 | cloud.rotate = function(x) {
|
148 | 164 | if (!arguments.length) return rotate;
|
149 | 165 | rotate = d3.functor(x);
|
|
185 | 201 | return "serif";
|
186 | 202 | }
|
187 | 203 |
|
| 204 | + function cloudFontNormal() { |
| 205 | + return "normal"; |
| 206 | + } |
| 207 | + |
188 | 208 | function cloudFontSize(d) {
|
189 | 209 | return Math.sqrt(d.value);
|
190 | 210 | }
|
|
210 | 230 | while (++di < n) {
|
211 | 231 | d = data[di];
|
212 | 232 | c.save();
|
213 |
| - c.font = ~~((d.size + 1) / ratio) + "px " + d.font; |
| 233 | + c.font = d.style + " " + d.weight + " " + ~~((d.size + 1) / ratio) + "px " + d.font; |
214 | 234 | var w = c.measureText(d.text + "m").width * ratio,
|
215 | 235 | h = d.size << 1;
|
216 | 236 | if (d.rotate) {
|
|
0 commit comments