-
Notifications
You must be signed in to change notification settings - Fork 170
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
Itallic fonts are clipped #154
Comments
It would seem I was wrong here. Source Code Pro reports positive left and right bearings. |
I retract my previous statement, other fonts do report negative bearings, maybe there is something to be done here e.g. index a02a1f3..9d24084 100644
--- a/src/gui/shellwidget/shellwidget.cpp
+++ b/src/gui/shellwidget/shellwidget.cpp
@@ -153,6 +153,18 @@ void ShellWidget::paintEvent(QPaintEvent *ev)
// Draw chars at the baseline
QPoint pos(r.left(), r.top()+m_ascent+m_lineSpace);
+
+ // Adjust according to font bearing
+ int rBearing = p.fontMetrics().rightBearing(cell.c);
+ int lBearing = p.fontMetrics().leftBearing(cell.c);
+ if (lBearing + rBearing < 0) {
+ // Not much we can do, the font does not
+ // fit the cell
+ } else if (lBearing < 0) {
+ pos.setX(pos.x()-lBearing);
+ } else if (rBearing < 0 ) {
+ pos.setX(pos.x()+rBearing);
+ }
p.drawText(pos, QString(cell.c));
}
~
~
~ ping @khalidchawtany |
I will try it in a moment. Thanks for investigating. |
Wait I am mistaken!!! just a second |
Depends very much on the font. Which ones are you using? For me it completely failed with Source Code Pro, but worked with Courier. |
However, this makes some chars look a little displaced. |
In linux the debug builds should be printing all the offending chars and font info into the terminal, not sure about OS X. |
In OSX it launches an app without a terminal. However, I can set a |
Nope, no offending char is written in to the log. |
@equalsraf how would you go about displaying chars that do not fit the cell? I just like to know any ideas you may have about tackling this issue. |
How do I build a |
Default is debug, and there are entries in the log so it should be working
Strange, then they should fit or the font metrics are weird. I've pushed a new branch tb-italics it already has the patch I posted above. It also has a modified version of fontinfo. Can you grab that branch and then
|
Here is the result fontinfo.txt |
Wait I think I made a mistake in the font name :) |
Sorry copy paste :) |
Clearly text layout is not my thing Pushed a commit too, but it doesn't seem correct. |
The pushed commits are better than previous ones. However, now the left bottom side of letter Update: |
DejaVu Sans Mono for Powerline |
Can confirm the issue with Inconsolata https://fontlibrary.org/en/font/inconsolata-lgc-markup |
FYI can confirm with Iosevka https://github.com/be5invis/Iosevka |
Hello, the year 2020 finally comes to an end and we still don't seem to have a fix for this. I wanted to ask politely if there are any plans to fix this issue somehow? I mean, this was reported in 2016... |
@equalsraf as long as the characters are drawn individually this problem cannot be completely solved.
|
Good point...
I'm somewhat hesitant to fix this for Perhaps fixing this for |
any update? |
Reported by @khalidchawtany, italic text in some fonts is clipped
Presumably this is expected behavior from Qt (from SO) a result of left/right bearing. This is a problem because we can't change the font metrics between italics and non italics (they must be the same width).
We can adjust the drawing function, but its still unclear if this would fix the issue or cause a similar issue on the right side.
The text was updated successfully, but these errors were encountered: