RE: https://mastodon.gamedev.place/@eniko/116279471062633993

ok this might be a zany ass idea but... what if... 320x200 but with 2 pixel tall dither as a stylistic choice? eh? eh? eh? :D

wake up babe new font just dropped

look ma, no text jumping*!

*in my wordwrapped typewriter text

i have 3 iterative functions here:

1. gets the next word (spaces/newlines count as a 1 character "word")
2. wraps words iteratively, recording width, max width, and height
3. uses the wrapping function to get the next word, then draws it 1 character at a time

it's quite a clean implementation

btw my font format for this project is *incredibly* sophisticated
at least i've made things easy for @foone
@eniko I'm always grateful for simple font formats!
@foone @eniko
How do you feel about vector font formats?
@eniko If only A was made of As, B of Bs and so on
@sobkas you could do that and it would still work :D
@eniko we heard you like ASCII so we put ASCII art inside your font so you can make ASCII art out of other ASCII art
@eniko I'm having flashbacks to Pixmap files when learning X11 programming in the mid-90s...
https://en.wikipedia.org/wiki/X_PixMap
@eniko games it's a pet hate of mine when games write out text a character at a time but only wrap once a word has gotten too long, making it jump from one line to the next. This is so much cleaner!
@Lacey it's impressive how many games do that, even those which are highly refined in other aspects. @eniko
@RedGlow @eniko exactly, it always feels lazy
@eniko bacon ipsum > lorem ipsum. imho. =)

@eniko Perfect! How are you managing wrapping?

EDIT: Wait, I suppose you're just not showing the text, right? It's formatted once and you just unroll it?

@Ronflaix i made an iterative wrapText function that goes word by word (spaces/newlines count as words) and which detects when a word goes over the wrap width, and bumps it to the next line

and then i made an iterative typewriter function that draws the text one character of a word at a time and which advances the wrapText iterator when it's done rendering the word

@eniko Ooh, clever! Thanks for the info!

@Ronflaix yeah i actually did the "lay it out once" thing in C# way back when but this seemed cleaner

that way i can also use wrapText to measure the full width+height of text by just iterating until it's done and reading the max width and height properties of the iterator

@Ronflaix oh right i also have an iterative function that gets the next word, which the wrapText function uses

so really its 3 iterators deep but that makes it sound more complex than it really is >_>

@eniko Yeah, it's generic but I see the design and if it makes the actual code flow easier, why not?

I suppose you also select glyphs variants on the fly? Positional variants, ligatures and all the bells & whistles too? :D

@Ronflaix oh god no :'D this is just a simple ascii font and so each character just has its pixel width, and the advance is width + the font's char spacing
@eniko I love text jumping as an example of one of those tricky little implementation details that game players take for granted.
@eniko holy shit, computing the wid
width of a word before you sta
start drawing it? Inconceivab
Inconceivable!
@eniko Thank you for saving my sanity by implementing this but also for giving me a name for the phenomenon so I don’t have to say “the thing where the text moves to the next line when it doesn’t fit”
@eniko Yeah, that's much more readable 👍