novelWriter icon indicating copy to clipboard operation
novelWriter copied to clipboard

Setting text width in number of characters instead of pixels

Open xahodo opened this issue 8 months ago • 4 comments

Currently, the text width for both "normal" and "focus" modes are in number of pixels. To me this seems unpractical.

How about setting them in number of characters? This would make it much easier to keep things the same, even when changing fonts.

For sane defaults use a default text width of ~66 characters. This is what newspapers use to prevent reading confusion, along with a very readable font. Magazines often use multiple columns as well, but they often aren't as smart regarding this as newspapers in this regard.

This wouldn't really matter when writing, as the text is just added, but it does matter when editing because of - again - reading confusion.

What do I mean with "reading confusion"? It's basically the idea of reading a line and discovering that you're all of a sudden reading another line, or needing to go to the next line with your eyes and finding you've skipped a line or started reading the same line over again.

A default line width of ~66 symbols helps prevent reading confusion. However, not every font is made equal; some are wider, some are narrower. On top of that, not every character has an equal width. Capitals are bigger than normal letters; the "i" and "m" aren't exactly of equal width either. So it's hard to get things right using pixels as a measurement.

Would it be possible to change these settings to be measured in number of characters, as opposed to number of pixels?

xahodo avatar Apr 11 '25 11:04 xahodo

The GUI library uses pixels as units, so yes, I can convert characters to pixels under the hood, but there isn't any way to ensure that the width in characters is obeyed by the layout engine. As you say, characters are not all the same width.

So in my view it is confusing to have a unit that cannot be obeyed.

A lot of people don't necessarily know what pixels mean either, but at the very least there is a default number that people can scale up or down.

vkbo avatar Apr 11 '25 15:04 vkbo

How about generating a random string of text in the configured spell checking language using the currently selected font and then measuring how many pixels wide that string is?

This way the number of characters in a line can be used, in a matter of speaking.

xahodo avatar Apr 18 '25 19:04 xahodo

This is way over-complicated just to define the width of the editor, and also very confusing. This would require sample text for every language!

Most people would be used to fixed width from office type software, because paper has standard sizes. Relative units are common on web and in typography, but that's not something writers generally deal with.

The only unit relative to font size worth considering here is em. It's the standard relative unit. It's either that, or fixed units like pixels or points. I would consider switching to em or points, but not this.

vkbo avatar Apr 18 '25 20:04 vkbo

I will not implement a setting using character count. A better solution would be pt or em units, but I'm not sure that is more understandable to the average non-technical user than px. Many do know that the pt unit is related to the font size though, so that may be an option.

I'm inclined to keep the settings as they are.

vkbo avatar Jun 01 '25 13:06 vkbo