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

Use ink rectangle when calculating Pango text width #4475

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

mahkoh
Copy link

@mahkoh mahkoh commented Aug 11, 2021

Before: pango-before

After: pango-after

@psychon
Copy link
Contributor

psychon commented Aug 12, 2021

Which of your two changes fixes the problem? Only both of them? Or is e.g. the x + width change already enough?

You add a comment linking to a 20 years old bug report. Are you saying this bug was still not fixed after 20 years or what is that linked supposed to mean?

Also, I briefly looked at the code, but I did not find anything that would explain the clipping. Is the right part of the simply overdrawn by later code, or what? If so, what exactly draws over part of the glyphs? I'm confused about what is going on...

@mahkoh
Copy link
Author

mahkoh commented Aug 12, 2021

Which of your two changes fixes the problem? Only both of them? Or is e.g. the x + width change already enough?

I use the font pango:DejaVu Sans Mono 8. With this font ink_rect.x is always 1 whereas logical_rect.x is always 0. If I remember correctly, logical_rect.width and ink_rect.width are always identical.

The fix therefore requires both changes.

You add a comment linking to a 20 years old bug report. Are you saying this bug was still not fixed after 20 years or what is that linked supposed to mean?

The linked mail is the only source I've found that describes the difference between logical_rect and ink_rect. I do not know if the current behavior of Pango is a bug or not.

Also, I briefly looked at the code, but I did not find anything that would explain the clipping. Is the right part of the simply overdrawn by later code, or what?

No. In

i3/i3bar/src/xcb.c

Lines 307 to 310 in d65a7ed

draw_util_text(text, &output->statusline_buffer, fg_color, bg_color,
x + render->x_offset + has_border * logical_px(block->border_left),
bar_height / 2 - font.height / 2,
render->width - has_border * logical_px(block->border_left + block->border_right));
the width of the surface that we draw to is explicitly set to the expected width of the text (render->width). I tried simply setting this width to the width of the entire statusline_buffer, but then the last piece of text (the time in my screenshot) will still be cut off because its x offset is one pixel too far to the right.

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

Successfully merging this pull request may close these issues.

None yet

2 participants