Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

changing text size?

A topic by yeehaw created Aug 23, 2023 Views: 409 Replies: 2
Viewing posts 1 to 3
(+1)

sorry for the obvious question, i'm not good with coding (but trying to learn!) and have been trying to figure out how to change the size of text in a field.. and have yet to figure it out 馃槶 how do you change the text size? i've tried using the x.textsize[x] interface but my different attempts don't seem to be working :(

Developer

The font.textsize[] function is for measuring text; given a string it will calculate a rectangular bounding box for that string, when drawn using the source font.

Decker fonts are a collection of bitmap glyphs, with a single fixed size. A different text size requires a different font. The "fontedit.deck" example deck includes several fonts that are larger than the default three which you could try. You could also have a go at making one of your own. Once you've imported the appropriate fonts into your deck, you can set the font of an entire field by selecting it in Widgets mode and choosing "Widgets -> Font..." from the menu.

It is also possible to programmatically create new fonts with Lil scripts. A non-integral upscale will not produce very good results, but you could use an automatically upscaled font as a starting point and massage it manually to create something that looks nicer.

Here's an example you could try at the listener to create a 1.5x and 2x version of an existing font:

on make_scaled_font font scale name do
  dst:deck.add["font" font.size*scale name]
  each i in range 96
    glyph:font[i]
    scaled:image[glyph.size*scale]
    scaled.paste[glyph (0,0),glyph.size*scale]
    dst[i]:scaled
  end
end
make_scaled_font[deck.fonts.body 1.5 "body_med"]
make_scaled_font[deck.fonts.body 2   "body_big"]

And here's what they each look like:

Keep in mind that this process makes a new font entirely, and only needs to be done once per size; the created fonts are automatically saved as part of the deck.

(+1)

thank you for the in-depth answer! this is really helpful- making my own font sounds super fun !!