You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
you can define the style of your text through BlTextAttributesStyler
204
-
205
-
````smalltalk
206
-
text := 'Hi John' asRopedText.
207
-
208
-
styler := BlTextAttributesStyler on: (text from: 3 to: 7).
209
-
styler
210
-
bold;
211
-
italic;
212
-
fontSize: 30;
213
-
fontName: 'Roboto';
214
-
monospace;
215
-
foreground: Color green.
216
-
styler style.
217
-
```
218
-
219
-
or using a fluent API
220
-
221
-
````smalltalk
222
-
text := 'Hi John' asRopedText.
223
-
(text from: 3 to: 7) stylerDo: [ :aStyler | aStyler bold italic foreground: Color red ].
224
-
````
225
-
226
-
As you may have noticed, this gives you a very fine-grained control over the style of your text.
227
-
You also need to re-specify attributes when your text changes.
228
-
If you want all your text to use the same attribute, you can then use `BlAttributedTextElement`.
229
-
You can then change your text, `BlAttributedTextElement` will reuse its attributes.
230
-
231
-
232
-
```smalltalk
233
-
text := 'Hi John' asRopedText.
234
-
235
-
element := BlAttributedTextElement new.
236
-
attributes := element attributesBuilder
237
-
foreground: Color green;
238
-
monospace;
239
-
bold;
240
-
italic;
241
-
fontSize: 30;
242
-
fontName: 'Roboto';
243
-
monospace.
244
-
245
-
label := (element text: text)
246
-
position: 50 @ 10;
247
-
background: Color yellow;
248
-
margin: (BlInsets all: 2);
249
-
padding: (BlInsets all: 2);
250
-
outskirts: BlOutskirts centered;
251
-
border: (BlBorder paint: Color red width: 2).
252
-
253
-
element text: 'hello world' asRopedText.
254
-
label.
255
-
```
256
277
257
278
### upload a font to bloc
258
279
@@ -391,4 +412,4 @@ label transformDo: [ :t |
391
412
label size: label transformedBounds extent.
392
413
```
393
414
394
-
In this snippet we rotate the element containing the text (but not the textElement) using `TBlTransformable>>tranformDo:` but for that we need to force its layout and just like in the earlier example, the transformation didn't change the position nor the bounds hence the last line.
415
+
In this snippet we rotate the element containing the text (but not the textElement) using `TBlTransformable>>tranformDo:` but for that we need to force its layout and just like in the earlier example, the transformation didn't change the position nor the bounds hence the last line.
0 commit comments