How to put a font awesome icon into a block's name

130 views
Skip to first unread message

George

unread,
Apr 8, 2021, 11:26:35 AM4/8/21
to Blockly
In a block's label text, msg0, how do I put a fontawesome icon there?

The font the style uses for blocks is "Monaco", "Menlo", "Ubuntu Mono", "Consolas", "source-code-pro", monospace

Which doesn't render fontawesome icons

Beka Westberg

unread,
Apr 8, 2021, 4:21:54 PM4/8/21
to blo...@googlegroups.com
Hello,

I have two ideas that might work for you, but they're just based on modifying blockly's css. From what you're saying it sounds like that's what you need? But I don't know how font awesome works, so these suggestions may not be helpful :/

1) Override the font of the .blocklyText css class. This is the class used by all text on the workspace, including blocks, the toolbox, etc.
2) Use a label field instead of the msg0 property, and pass a custom css class to it. If the class supports fontawesome icons, then the label should as well (I think).

```
{
  "type": "example_label",
  "message0": "%1 %2 %3",
  "args0": [
    {
      "type": "field_label",
      "text": "a label",
      "class": "awesome-font-class"
    },
    {
      "type": "input_dummy"
    },
    "and another label"
  ]
}
```

I hope those suggestions give you some place to start!

Best,
Beka

--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/blockly/6b2b64eb-ced8-4045-ab95-ade89da1c75fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages