edbee-lib icon indicating copy to clipboard operation
edbee-lib copied to clipboard

Font size forced to 10 in margin causes display problems

Open dicene opened this issue 7 years ago • 10 comments

The editor is forcing the line numbers to be drawn at 10 point in whatever font the editor is using, causing abnormalities when you use other font sizes.

Here's what the issue looks like using Consolas 7pt: image

And here's a different consequence of the forced font size with Consolas 20pt:

image

dicene avatar Jul 02 '17 00:07 dicene

Seems like the line numbers should be whatever font size the editor is using. Doing this would also eliminate the need for the blank space offset above the line number in each line.

The code related to forcing the font size can be found at lines 139 and 141 of: https://github.com/edbee/edbee-lib/blob/bc402fa67dd124290bf1e0c7e067b915a1ec927f/edbee-lib/edbee/views/components/textmargincomponent.cpp

dicene avatar Jul 02 '17 00:07 dicene

It might be stupid to suggest this but will setting the same font size for the line numbers as for the main text always be appropriate? I guess that the editor text content could contain letters/glyphs with ascending and descending features but normal (in the West) numbers do not so I suppose that should be a safe choice...

SlySven avatar Jul 02 '17 22:07 SlySven

I agree! I Will change it so it uses the font-size from the selected theme.

gamecreature avatar Jul 03 '17 06:07 gamecreature

I can't really say I like the rendering when I use the same font-size as the editor itself:

schermafbeelding 2017-07-03 om 08 14 32

I'm considering scaling down the font-size with a factor will improve the situation (for example 80%)

gamecreature avatar Jul 03 '17 06:07 gamecreature

Sublime uses the same font-size but greys out the line number so it doesn't jump out as much - that seems to work well.

vadi2 avatar Jul 03 '17 06:07 vadi2

I'm working on it. Currently having an issue that the font/theme isn't known at the moment the margin-component is constructed.

I think graying out the margin color of the number on the sidebar is good options. (Guess I will implement that with opacity so it works for all colors)

gamecreature avatar Jul 03 '17 06:07 gamecreature

Yeah, this can be theme-neutral, but I'd recommend taking the luminosity taking into account - from our experience you want to use 2 colours, one for a light background and one for a dark background. We use the formula from W3 for this, here's a Lua implementation.

vadi2 avatar Jul 03 '17 06:07 vadi2

That is to say if the opacity trick works, then that'll be just fine - we don't have that option.

vadi2 avatar Jul 03 '17 06:07 vadi2

It seems while the highlighting area takes effect on a font size change right away, re-rendering the line numbers with the new font size only happens when you visually bring up edbee again. It's noticeable when you go from 20pt to 7pt.

vadi2 avatar Jul 09 '17 03:07 vadi2

How doe you set the font-size? Currently the margin only updates the font size if the config is changed.. (And the config emits a signal TextEditorConfig::configChanged)

gamecreature avatar Jul 09 '17 09:07 gamecreature