Bug 189633 - worldclock plasmoid freezes if Helvetica font is not installed
Summary: worldclock plasmoid freezes if Helvetica font is not installed
Status: RESOLVED FIXED
Alias: None
Product: marble
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Henry de Valence
URL:
Keywords:
: 180920 200634 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-04-14 19:39 UTC by Jacopo De Simoi
Modified: 2009-11-15 15:13 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jacopo De Simoi 2009-04-14 19:39:53 UTC
Version:            (using KDE 4.2.2)
OS:                Linux
Installed from:    Compiled From Sources

The worldclock plasmoid initializes the font size in a dynamic way, by increasing the size of the font until it's big enough.  ( worldclock.cpp: 289-310)
The "helvetica" font family is hardcoded and there is no check that ensures it to be installed in the system.
If this is not the case the for loops around lines 289-310 will never terminate and plasma freezes.

 --J
Comment 1 Jacopo De Simoi 2009-04-14 19:41:44 UTC
I don't know whether or not it is standard not to have the helvetica font installed, but maybe using the default font could just be a nice solution.
Comment 2 Henry de Valence 2009-04-15 03:43:01 UTC
I picked Helvetica because it is aesthetically pleasing to me. I was under the impression that if Qt can't find the correct font it will try to find another font that looks similar, rather than looping infinitely. So if one didn't have Helvetica it would pick e.g. FreeSans or something.
Comment 3 Jacopo De Simoi 2009-04-15 06:14:38 UTC
You are perfectly right, the issue is actually something else. 
In my system Helvetica happens to be a bitmap font (don't ask me why, I really have no idea).
So it's probably a misconfiguration of my fonts; however, imo it might be the case to make sure in advance that the font is scalable (passing QFont::ForceOutline as a style strategy seems not to work) for instance by suitably checking QFontInfo in the loop...

--J
Comment 4 Torsten Rahn 2009-07-10 18:58:41 UTC
Reassigning this bug. Did you manage in the meantime to figure out the true cause of this issue?
Comment 5 Jacopo De Simoi 2009-07-11 10:17:08 UTC
the "true" cause is again the fact that IF helvetica font is installed as a bitmap font, the loop will cycle forever, since the font will never get big enough as to satisfy the condition to bail out.
The code assumes that helvetica, or whatever font replaces it, is an outline font, and that assumption may be wrong
Comment 6 Dario Andres 2009-07-21 16:08:04 UTC
*** Bug 200634 has been marked as a duplicate of this bug. ***
Comment 7 Dario Andres 2009-07-21 16:08:53 UTC
As identified in bug 200634: this bug happens due a Gentoo misconfiguration of fonts.
Comment 8 Jacopo De Simoi 2009-07-23 10:38:27 UTC
(In reply to comment #7)
> As identified in bug 200634: this bug happens due a Gentoo misconfiguration of
> fonts.

I believe that, no matter how fonts are configured or misconfigured, plasma should *not* freeze because of such a trivial issue.

This is the relevant part of the code (there is a similar piece right before this):

worldclock.cpp:307
for ( int curSize = 4; ; ++curSize, ++lastSize ) {
      QFont font( "Helvetica", curSize, QFont::Bold);
      QFontMetrics metrics( font );
      QRect rect = metrics.boundingRect( timestr );
      if ( rect.width()  > timeRect.width() ||
           rect.height() > timeRect.height() ) {
                  break;
           }
      }

I believe that we could already be safe with something like the following:

LARGE_SIZE=100; 
...
QRect oldRect;
for ( int curSize = 4; ; ++curSize, ++lastSize ) {
      QFont font( "Helvetica", curSize, QFont::Bold);
      QFontMetrics metrics( font );
      QRect rect = metrics.boundingRect( timestr );
      if ( rect.width()  > timeRect.width() ||
           rect.height() > timeRect.height() ||
           (curSize > LARGE_SIZE && oldRect == rect) ) {
                  break;
           }
     oldRect = rect;
      }

At this point the font would not scale with the widget, and then it would be ok to blame gentoo for that.
Of course there are probably more elegant ways to deal with this problem than the one I propose here, but I think we should at least get started with something concrete.  

 Thanks
  --J
Comment 9 Jacopo De Simoi 2009-07-29 11:49:48 UTC
ping?
Comment 10 Jacopo De Simoi 2009-07-29 12:29:30 UTC
as a *WORKAROUND* for us gentooers please check http://christopherowen.id.au/blog/2008/01/22/not-any-helvetica-i-know/
Comment 11 Dario Andres 2009-08-19 23:26:33 UTC
*** Bug 180920 has been marked as a duplicate of this bug. ***
Comment 12 Dennis Nienhüser 2009-11-15 15:11:30 UTC
SVN commit 1049582 by nienhueser:

Do not assume fonts are arbitrarily scalable.
CCBUG: 189633


 M  +30 -19    worldclock.cpp  
 M  +1 -0      worldclock.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1049582
Comment 13 Dennis Nienhüser 2009-11-15 15:13:41 UTC
SVN commit 1049584 by nienhueser:

Do not assume fonts are arbitrarily scalable. Backport of commit 1049582
BUG: 189633


 M  +30 -19    worldclock.cpp  
 M  +1 -0      worldclock.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1049584