# What is the pixel width of text compared to 'size'?

(This is a template, feel free to delete it.)

huh

I had to figure this out myself in my write with wrapping block, the calculation is:

to calculate the width the text is going to take up in pixels.
A character written onscreen with size 12 takes up 7 pixels.
Sorry if this doesn't answer your question, it wasn't very well worded.

No, I understand perfectly! Thanks!

so... like

? (text costumes library)

Clever. I like the recursion.

The text costumes library requires you to clear and re-stamp the pen trails every time you make a text costume, which could lead to lag and other problems.

Also I found out from experimentation that every character is about a maximum of 11 pixels tall, so you could use (my formula) times 11 to get the area in pixels.

This is why the WRITE block leaves the sprite at the end of the text; you find out the width by subtracting the sprite's old position from its new one. There isn't a constant width/height because we aren't using a monospace font.

@helicoptur Did you check parentheses and braces? Those are typically the tallest characters in a font. Also, typically when you typeset more than one line, there's at least one pixel of space added between lines (this is called the leading, with "lead" pronounced like the metal, not like the verb). To my eye, it's more like two pixels of leading in these forum messages.

well, the font that snap uses for the write block is dependent on the browser settings (so you can have custom fonts if you want). Just change the Fixed-width font in your browser.

Ah, I didn't know that, thank you.

Oh! I guess I was wrong; we are using a monospace font in WRITE. Pretty sure that wasn't always the case, because we had a long discussion about whether to move the sprite to the end of the text and the non-monospace argument won the day.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.