Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotted underlining in gtksourceview is very large with Red Hat Mono #67

Open
juhp opened this issue Nov 20, 2024 · 3 comments
Open

dotted underlining in gtksourceview is very large with Red Hat Mono #67

juhp opened this issue Nov 20, 2024 · 3 comments

Comments

@juhp
Copy link

juhp commented Nov 20, 2024

words

This was brought to my attention by @chergert and it is easily reproduced in current c10s Workstation for example.

Christian wrote:

The issue with the underline dots is that the size of them comes from some underline-height value in the font itself. Pango uses that to determine the size of the error dots to draw.
Adobe Source Code Pro looks fine but Red Hat Mono looks quite large in comparison to the font size.
Pango will call pango_renderer_draw_error_underline() with a height of 3 * rect->height where the rect height is the size of an underline. So presumably, slimming down the underline height would fix the issue.

Though from my simple testing standard underlining seems to be fine in other contexts: eg in vte (Gnome Terminal)?
Correct me if I am wrong there.

@allanday
Copy link

Though from my simple testing standard underlining seems to be fine in other contexts: eg in vte (Gnome Terminal)?

I don't think I'd expect to see dotted underlines in a terminal...

@chergert
Copy link

chergert commented Nov 20, 2024

I don't think VTE has anything that can render PANGO_UNDERLINE_ERROR_LINE so terminals should not be a problem.

Another option we have, would be to use a single red underline instead of the dots. It's a pretty small patch to do that in Text Editor.

Here are two pictures, one with Red Hat Mono and one with Source Code Pro both at 11pt. This uses the PANGO_UNDERLINE_SINGLE option above. It does have some side effects in that it will show up over any styling that would otherwise cause underlines to be shown. That is fairly rare though in GtkSourceView language specs. Mostly related to URLs and/or markdown-type styling.

The difference in thickness below is why the dots are so large in Pango rendering.

/cc @matthiasclasen just in case we want to address this differently in Pango.

Source Code Pro 11

Screenshot From 2024-11-20 11-27-15

Red Hat Mono 11

Screenshot From 2024-11-20 11-27-31

@matthiasclasen
Copy link

matthiasclasen commented Nov 20, 2024

So what pango does is it uses the same amount of space for error underlines that we use for double underlines, which is 3 times the underline thickness. That was appropriate for the traditional zigzag pattern.

Since we changed what we draw in GTK's pango renderer implementation, a simple fix would be to make that implementation not use the full height of the rectangle we are given, but draw the dots with the same height as a single underline.

One thing I'm not quite clear on is whether this needs to font-specific, or can be done for every font.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants