Fix for blurry sky labels

Bug #521134 reported by faluco
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stellarium
Fix Released
Medium
Unassigned

Bug Description

We all have noticed that sky labels are hard to read in version 0.10.3 (stars, planets, meridian/equator, etc). Depending on the zoom or how you move through the sky, labels will turn dimmer or brighter and they blink when they're moving through the sky.

I think there's a bug with how Qt is rendering fonts, so im proposing a workaround until the Qt dev team fixes (if it ever does) :)
Basically what i've noticed is that Qt will only render fonts correctly when they're aligned to the nearest integer, StelPainter::drawText gets label coordinates via floats so they need to get rounded to get back the sharp fonts. An additional huge improvement is gained by removing alpha blending inside this function.

Here's the code ive changed, all comes from StelPainter::drawText in StelPainter.cpp:

REMOVE:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

CHANGE:
qPainter->translate(x+xshift, prj->viewportXywh[3]-y-yshift);
TO:
qPainter->translate(round(x+xshift), round(prj->viewportXywh[3]-y-yshift));

CHANGE:
qPainter->translate(x+xshift, y+yshift);
TO:
qPainter->translate(round(x+xshift), round(y+yshift));

Only with this changes we get back sharp and clear fonts. I hope these changes help, maybe there's a better fix you can think of with this hints, but this one works great.
I'm looking if i can make the horizontal menu fonts look a bit better, if i found a fix i'll notify it.

Attaching a comparison screenshot.

Revision history for this message
faluco (borja-ferav) wrote :
Revision history for this message
faluco (borja-ferav) wrote :

after patch

Revision history for this message
faluco (borja-ferav) wrote :

Closeup comparison with better quality.

Revision history for this message
faluco (borja-ferav) wrote :

meridian/equator

Revision history for this message
faluco (borja-ferav) wrote :

As mentioned in my first post after finding a fix for the menus i've reported it here https://bugs.launchpad.net/stellarium/+bug/521462

Revision history for this message
Fabien Chéreau (xalioth) wrote :

Dear all,
Could you please try the release candidate for 0.10.4?
http://chereau.free.fr/stellarium_files/stellarium-0.10.4-win32-RC1.exe

Before installing, please uninstall previous versions and suppress
your previous config.ini.
The RC1 uses gl shaders by default for stars and atmosphere rendering.
It also uses the Qt OpenGL2 paint engine

The feedback I expect is:
 - Do you see proper sky labels (no blinking)?
 - Do you still experience random crashes?

Please also try with use_glshaders = false in the [main] section of
the config.ini file.

Thanks!
Fabien

Revision history for this message
faluco (borja-ferav) wrote :

Hello Fabien, with this RC i can confirm sky labels and menu fonts are sharp again. Could you tell me what fixed this issue or what was the problem? It took me some time to figure out a fix so i'm interested in knowing about it.

One thing that is not fixed yet and that i've mentioned in https://bugs.launchpad.net/stellarium/+bug/521462 are distored icons. This version distorts vertical menu icons more than the previous, i've posted a fix in that report that could help you fixing it.

Attaching a screenshot to show the problem.

Revision history for this message
faluco (borja-ferav) wrote :

Just tested adding use_glshaders = false to the config.ini file and it brings back sky label blinking and blurness and makes menu fonts sort of cut out.

Revision history for this message
GordieJ (gordiejones) wrote :

I tried the updated 0.01.4 but it didn't fix anything on my computer.

Before that I, I was going to try the code changes in StelPainter.cpp but couldn't find that file anywhere on my system.

Changed in stellarium:
milestone: none → 0.10.4
status: New → Fix Released
Revision history for this message
faluco (borja-ferav) wrote :

Hello Fabien, i think you should apply this patch because setting use_glshaders=false in the config.ini file brings back the blurry fonts as happened in version 0.10.3. I've been able to reproduce this in my laptop since it's unable to use the opengl2 renderer and stellarium automatically sets opengl1 as the default render engine. So users with older computers may suffer still this bug.
Thanks

Revision history for this message
Fabien Chéreau (xalioth) wrote :

Hi,
I did apply the patch already on the SVN version!
Fab

Changed in stellarium:
status: Fix Released → Fix Committed
importance: Undecided → Medium
Revision history for this message
GordieJ (gordiejones) wrote :

All I've been able to d is download. I tried 10.3 & 10.4 both giving me blurry labels. I don't know how to change stelpainter or even what it is. So I've gone back to 9.1.

Revision history for this message
faluco (borja-ferav) wrote :

@GordieJ: what you need to change is the source code, not a config setting. Then after doing this you have to recompile the program to convert the source code to executable code. If you want i could attach for you a patched version for 0.10.3 until it gets officially fixed in a future version, if Fabien doesnt have any issues with this of course.

@Fabien: hrmm there has been a little confussion here :) The patch you applied in revision 5919 was for another bug report concerning blurry text in menus and corrupted menu icons (sadly it didnt make it into 0.10.4 but nevermind). This patch is a different one that fixes blurry sky labels as shown in the printscreens. I hope it makes it clear now.

Revision history for this message
GordieJ (gordiejones) wrote : Re: [Bug 521134] Re: Fix for blurry sky labels

ATTACH AWAY! And thanks!

On Tue, Mar 2, 2010 at 3:10 PM, faluco <email address hidden> wrote:

> @GordieJ: what you need to change is the source code, not a config
> setting. Then after doing this you have to recompile the program to
> convert the source code to executable code. If you want i could attach
> for you a patched version for 0.10.3 until it gets officially fixed in a
> future version, if Fabien doesnt have any issues with this of course.
>
> @Fabien: hrmm there has been a little confussion here :) The patch you
> applied in revision 5919 was for another bug report concerning blurry
> text in menus and corrupted menu icons (sadly it didnt make it into
> 0.10.4 but nevermind). This patch is a different one that fixes blurry
> sky labels as shown in the printscreens. I hope it makes it clear now.
>
> --
> Fix for blurry sky labels
> https://bugs.launchpad.net/bugs/521134
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in Stellarium: Fix Committed
>
> Bug description:
> We all have noticed that sky labels are hard to read in version 0.10.3
> (stars, planets, meridian/equator, etc). Depending on the zoom or how you
> move through the sky, labels will turn dimmer or brighter and they blink
> when they're moving through the sky.
>
> I think there's a bug with how Qt is rendering fonts, so im proposing a
> workaround until the Qt dev team fixes (if it ever does) :)
> Basically what i've noticed is that Qt will only render fonts correctly
> when they're aligned to the nearest integer, StelPainter::drawText gets
> label coordinates via floats so they need to get rounded to get back the
> sharp fonts. An additional huge improvement is gained by removing alpha
> blending inside this function.
>
> Here's the code ive changed, all comes from StelPainter::drawText in
> StelPainter.cpp:
>
> REMOVE:
> glEnable(GL_BLEND);
> glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
>
> CHANGE:
> qPainter->translate(x+xshift, prj->viewportXywh[3]-y-yshift);
> TO:
> qPainter->translate(round(x+xshift), round(prj->viewportXywh[3]-y-yshift));
>
> CHANGE:
> qPainter->translate(x+xshift, y+yshift);
> TO:
> qPainter->translate(round(x+xshift), round(y+yshift));
>
> Only with this changes we get back sharp and clear fonts. I hope these
> changes help, maybe there's a better fix you can think of with this hints,
> but this one works great.
> I'm looking if i can make the horizontal menu fonts look a bit better, if i
> found a fix i'll notify it.
>
> Attaching a comparison screenshot.
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/stellarium/+bug/521134/+subscribe
>

Revision history for this message
Fabien Chéreau (xalioth) wrote :

faluco, thanks for the precision, I was slightly confused indeed :)

Are you sure that the second replacement is needed?
qPainter->translate(x+xshift, prj->viewportXywh[3]-y-yshift);
TO:
qPainter->translate(round(x+xshift), round(prj->viewportXywh[3]-y-yshift));

 Normally this should not be needed because this part concerns only the OpenGL2 painter, which doesn't suffer the bug as far as I understand the problem.

Fabien

Revision history for this message
faluco (borja-ferav) wrote :

You're absolutely right Fabien. With Qt 4.6.2 there's no need anymore to apply that change you mentioned for opengl2, only for the opengl1 case will be enough. I think you can drop away the alpha blending patch aswell, i cant notice any difference at all.
So the important change is:
CHANGE:
qPainter->translate(x+xshift, y+yshift);
TO:
qPainter->translate(round(x+xshift), round(y+yshift));

@GordieJ: Replace both files inside the rar file in the stellarium folder. Im unsure if you have the same problem as me like shown in the screenshots but if that's the case then this should fix your issues.

Revision history for this message
Fabien Chéreau (xalioth) wrote :

OK Faluco,
Thanks a lot, I committed that then (rev. 5966)
Fabien

Changed in stellarium:
milestone: 0.10.4 → 0.10.5
Revision history for this message
faluco (borja-ferav) wrote :

Fabien, i wanted to point out that rev.6103 brought back blurry text labels caused by qPainter->translate(xshift, -yshift);, again the input args needs to be rounded. I know you may change all this code again until the official release, but i wanted to point it out just to inform you.

Revision history for this message
Fabien Chéreau (xalioth) wrote :

Yes thanks for the reminder.
I would still like to find a workaround for the ugly rotated text for grid labels, but I am not so optimistic...
Fabien

Revision history for this message
faluco (borja-ferav) wrote :

Ah yes i see what you mean, i've just compiled latest revision to see what was going on with the grid. I noticed something similar some time ago with gravity labels, they look really bad aswell. Something i've noticed is that the fonts dont look the same as in the previous version, looks as if a different font type is being used. Anyways, if i find something i'll post it.

Revision history for this message
faluco (borja-ferav) wrote :

I've been trying several ways of rotating fonts, including matrix rotation transforms, and they all behave the same way, bad. By the way, as mentioned in my previous post it looks as if the font type used is not DejaVuSans, i managed to fix it by removing from main.cpp:

QFont tmpFont("DejaVuSans");
tmpFont.setPixelSize(13);
QApplication::setFont(tmpFont);

i have no idea why this works, because in theoy you're setting DejaVuSans as the default font, but it's causing the opposite effect. Applying this change produces a weird thing, if for example you add in the InfoPanel constructor (the text about star and planet info) this:
QFont font;
font.setPixelSize(13);
setFont(font);

font object is constructed using the default program font type, which isnt set anywhere, however it uses DejaVuSans and prints the text using this font. So there has to be two places which is setting font types.

Revision history for this message
Fabien Chéreau (xalioth) wrote :

Hi,
I committed a fix for the standard blurry font problem (r 6106). For rotated fonts, it is a confirmed Qt bug (http://bugreports.qt.nokia.com/browse/QTBUG-9706). Hopefully a fix will come by next release.

For the other problem, it could be that the style sheet defines the DejaVuSans as the application font as well. Try commenting the line 521 in StelGui.cpp (qApp->setStyleSheet(style.qtStyleSheet);) to avoid that.

Fabien

Revision history for this message
faluco (borja-ferav) wrote :

Removing that line doesn't fix it. It's still using some other font type, i've checked the stylesheet files and they dont define any font types, just font sizes but i think only for the windows, not for sky labels or menus. However removing that line caused all windows to look white because the stylesheet wasnt being loaded, so that was expected to happen.

Removing QApplication::setFont(tmpFont); from main.cpp results in using DejaVuSans but font sizes arent preserved throughout the program, all fonts look pretty small, this is probably caused because you removed the font.setPixelSize calls expecting that the stylesheets set them in each specific case, but as i said before, where in the stylesheets is this defined?

Revision history for this message
faluco (borja-ferav) wrote :

Fabien i managed to find a fix for this :). After several tests I tried adding this code to see if the font name used everywhere was valid:

const QString& fName = StelFileMgr::findFile("data/DejaVuSans.ttf");
                if (!fName.isEmpty()){
                  int id = QFontDatabase::addApplicationFont(fName);
                  QStringList lst = QFontDatabase::applicationFontFamilies(id);
                  StelLogger::writeLog(QString("START HERE:\n"));
                  for (int i = 0; i < lst.size(); ++i)
                            StelLogger::writeLog(lst.at(i).toLocal8Bit().constData());

this printed in the log file this:
START HERE:

DejaVu Sans

Surprise!!, the problem is that the font name has SPACE. Changing QFont tmpFont("DejaVuSans"); in main.cpp to QFont tmpFont("DejaVu Sans"); fixes the issue.
Now "DejaVu Sans" is used as the default font type as it is expected. In version 0.10.4 it was only being used it in sky labels, but not in the window menus (location, date&time, etc). Also with this fix opengl1 uses now this font aswell, i dont know why but in previous versions it used a different one, so now the font usage is consistent between opengl1 and opengl2.

About rotated text, grid labels are now dejavusans, the result is that they look a bit better than before, you may want to remove
font("DejaVuSans") in the constructor of SkyGrid in GridLinesMgr.cpp since now we can assure that dejavusans is the default font.

Revision history for this message
Bogdan Marinov (daggerstab) wrote :

Thank you very much, Faluco! If this also fixes the unreadable fonts problem, this will be very nice. I'll commit the fix right away.

Do you follow Stellarium's mailing list?
https://lists.sourceforge.net/lists/listinfo/stellarium-pubdevel

Revision history for this message
faluco (borja-ferav) wrote :

Yes Bodgan, i was following the issue "Windows visual bugs after the last changes" in the list. But im not registered, i guess i should do it to have a more direct communication.

Revision history for this message
Fabien Chéreau (xalioth) wrote :

Faluco, you're great :D Thanks a lot lot :)

Revision history for this message
faluco (borja-ferav) wrote :

You're both welcome :) it's a pleasure for me to be of some help.

Revision history for this message
faluco (borja-ferav) wrote :

I've found two small and trivial visual artifacts:

1) In the star/planet info text (upper left corner), the DMS info has a spare space in the minutes field when printing stuff using decimal values (used in J2000). The fix is to remove the first qSetFieldWidth(width) in line
"os << qSetFieldWidth(width) << m << qSetFieldWidth(0) << '\''<< fixed << qSetFieldWidth(width) << qSetPadChar('0') << s<< qSetFieldWidth(0) << '\"';"
found in StelUtils.cpp in function radToDmsStr. I think you only need to force a width in the seconds argument, no need in the minutes part.

2) When you zoom in a lot the FOV field text gets pretty long (like 0.0001525º), this overlaps with the FPS field. So my suggestion would be moving the fps field 2 or 3 chars to the right. I'm attaching a screenshot to show it
LINK: http://img249.imageshack.us/img249/9276/bugno.png
I guess a possible fix would be changing fps->setPos(datetime->x()-140, 0); line 570 in StelguiItems.cpp, this is safe because the date&time field will not overlap with the fps unless we go up to years like 2510212 which doesnt make sense.

An additional question, is it safe to revert rev.6080 (Fix a small rendering bug on some linux.) with latest changes, or does this bug still happen?

I copied this from the devel list since im unsure if my emails are arriving and because maybe you prefer bugs to be reported here instead of using the list.

Changed in stellarium:
status: Fix Committed → Fix Released
Revision history for this message
GordieJ (gordiejones) wrote : Invitation to connect on LinkedIn

LinkedIn
------------

Bug,

I'd like to add you to my professional network on LinkedIn.

- Gordon

Gordon Jones
Retired Pastor at none
Greater Chicago Area

Confirm that you know Gordon Jones:
https://www.linkedin.com/e/h11lya-hnomwvs9-4o/isd/17850622385/Lah2GX-2/?hs=false&tok=2mMeWkRVyEVRY1

--
You are receiving Invitation to Connect emails. Click to unsubscribe:
http://www.linkedin.com/e/h11lya-hnomwvs9-4o/Gr1V3mIVDHq94OR43gcTYBwVrFCfbWf-TOOkpXK/goo/521134%40bugs%2Elaunchpad%2Enet/20061/I5884823431_1/?hs=false&tok=03Bu9_63yEVRY1

(c) 2012 LinkedIn Corporation. 2029 Stierlin Ct, Mountain View, CA 94043, USA.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.