Closed cshapeshifter closed 11 years ago
The problem here is that the font library I'm using doesn't report the bounding box of text correctly. For instance, using your theme, the title bar size is 16 pixels and the height of the font rendered is also 16 pixels, even though we can clearly see that it is less than that. These extra pixels are a result of a fixed amount of padding added to the text extents to derive the bounding box.
This is a known bug. I think I could patch freetype to report the appropriate info, but I don't have the time at the moment.
Someone else had a similar problem as you, and I added an extra theme option that may or may not help in your case: title_top_margin
. Of course, if the alignment looks OK in regular windows but not maximized windows, this option probably won't help since it always applies.
I'll leave this open until freetype-go reports proper font metrics. Updating Wingo to use them will be easy.
I've submitted a patch to freetype-go. I'll give them a little time to see if it's accepted upstream, otherwise I'll fork freetype-go and adapt xgbutil/wingo to use that until functionality is added upstream.
In light of the fix, I've removed the title_top_margin
option. A warning will be logged if it is used.
Thanks, it's looking pretty good. I only notice one very minor problem with the OSD when changing workspaces (I have them numbered 1 to 8): The height of the small box containing the number changes height depending on the number. With 3, 5, 6 and 8 it's 1px taller. I don't think this needs fixing but I guess this is one implication to keep in mind, that the height of the bounding box is not the same for a given font size, but depends on the content of the string, i.e. if the text contains ascending or descending glyphs, it will be larger (e.g. the h vs. the S below). I did some research but I couldn't actually find guidelines on how to center lines of text vertically, i.e. which line to use as a center. Maybe the mean between baseline and median...
I see. You're probably right that it still isn't quite right. However, I do consider the issue of centering text solved for now.
We may want to revisit font rendering if Wingo gets more sophisticated with text rendering, but I suspect that it won't.
As seen on the screenshots, the window titles are not centered in the title bars, unless the window is not maximized and the font size fits the title bar size perfectly (i.e. font size=14 in this case). In all other cases, the text sits too high. It's also impossible to have the title fit properly for both maximized and regular windows, mostly because in maximized windows, the text really sits on the edge of the title bar.
It would be best if the text would simply be centered vertically no matter what size the text has.