cadin / panels

Build interactive comics for the Playdate console.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add text stylization options

zachspears opened this issue · comments

It would be really neat/helpful to be able to include some basic text stylization such as sizing, bolding, and italics. Thanks!

Can you say more about what you're trying to do?

You should be able to set *bold* and _italic_ using asterisks and underscores in your strings as detailed in the Playdate SDK docs. Or you can set the layer's font to a bold or italic variant if you want the entire string to have that formatting.

You can set a custom font in Panels for individual text layers or for all layers in a panel. That's how you would change size since pixel fonts are only designed for a single size.

It would look something like this:

{ text = "Hello world!", font="fonts/font-Cuberick-Bold" }

I may need to add the ability to set an entire font family to enable multiple formats (bold and italic) within a layer with a custom font. I'll look into that.
But currently you can for sure do a single custom font per layer, or multiple formats within a layer using the default font.

@zachspears
I added support for a fontFamily property (ae08c03).

You can add this to a single text layer, or specify the family to use for the entire panel or sequence, just like when specifying a font.

You can specify a family very similar to how you would create a font family using the SDK.

Send the fontFamily property a table with the appropriate path to mapped to the constant for each variant.

Example text layer:

{ text = "Normal *Bold*, _Italic_", x = 16, y = 180,
    fontFamily = {
        [Panels.Font.NORMAL] = "fonts/SasserSlab/Sasser-Slab",
        [Panels.Font.BOLD] = "fonts/SasserSlab/Sasser-Slab-Bold",
        [Panels.Font.ITALIC] = "fonts/SasserSlab/Sasser-Slab-Italic"
    },
},

This change will be included in the next release (and added to the docs). For now you can grab it from the develop branch.

This change is now merged into main and released as v1.1