-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
(Py)Qt bug resulting in variable spacing between adjacent text boxes, scaling with string length #708
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I have a script for automating italicising binomial nomenclature while leaving accession numbers, strain names, etc, as regular font. This means the italicised and regular objects have to go as separate text boxes side-by-side. All's fine except... there is ugly spacing between the two pieces of text, which scales proportionately to string length -- that latter "feature" being particularly annoying. I spent a long time trying to dig to the bottom of this and came across this unresolved bug in Qt: https://bugreports.qt.io/browse/QTBUG-49892 This matches my problem almost exactly, so I made a workaround using a "fudge_factor" determined empirically by trial and error...which ended up being font size, font type, and machine specific. I'm now working on a more general solution for this problem, but I first wanted to check if someone else has already sorted this out, or maybe I missed some obvious fix?
Unfortunately, since Qt is written in C++, I can't trace this issue deeper and am stuck with somewhat silly "fudge factor" type fixes :-/
PS:
I think part of this issue can be seen here: if I divide
QFontMetrics(font),boundingRect(text).width()
bylen(text)
(for any text), I get a consistent 11.3333 for size 12 Arial, 9.55555 for size 10 Arial. I'm surprised it's smaller, because the bounding box appears to be over-estimated in the actual rendering step. I was also expecting slight variation as Arial is not a fixed width font. Something's off.Minimal example, without even bothering with italics:
Produces the following under ete version 3.1.2:
The text was updated successfully, but these errors were encountered: