Bug 205474 - [Themes] The wrong default font is loaded when you specify a different theme.
Summary: [Themes] The wrong default font is loaded when you specify a different theme.
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Kevin McGuire CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 224723
  Show dependency tree
 
Reported: 2007-10-04 13:00 EDT by Matthew Hatem CLA
Modified: 2008-04-30 19:57 EDT (History)
6 users (show)

See Also:


Attachments
Patch to fix this problem based on HEAD (1.32 KB, patch)
2007-10-04 13:00 EDT, Matthew Hatem CLA
no flags Details | Diff
Patch to keep new behaviour but revert to system fonts in HC (1.68 KB, patch)
2008-04-22 10:49 EDT, Kevin McGuire CLA
no flags Details | Diff
Updated patch to directly use DEFAULT_FONT in HC where no default (1.70 KB, patch)
2008-04-24 12:04 EDT, Kevin McGuire CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Hatem CLA 2007-10-04 13:00:13 EDT
Created attachment 79751 [details]
Patch to fix this problem based on HEAD

Build ID: 3.4

Steps To Reproduce:
1. Create an RCP application that enables preference pages
2. Create a new theme extension
3. Set that theme as the current theme
4. Run the RCP app and open the preference pages.  

Bug: Note that the banner area in the preference page is not the proper font.  On windows it's MS Sans Serif and not bold.  The default is defined in JFaceResources as Tahoma 10pt bold and since the new theme does not override that font the font should default to the definition in JFaceResources.

Attaching patch..
Comment 1 Boris Bokowski CLA 2007-10-04 13:06:35 EDT
Kim, could you please review the patch?  Matt can commit but would like to have someone double-check his fix.
Comment 2 Kim Horne CLA 2007-10-04 13:09:43 EDT
Fix in HEAD.  Thanks Matthew!
Comment 3 Kim Horne CLA 2007-10-29 10:53:55 EDT
I believe I've verified this in I20071029-0010 but I'd appreciate a second look Matthew.
Comment 4 Matthew Hatem CLA 2007-10-30 13:42:06 EDT
Looks good to me.
Comment 5 Dani Megert CLA 2008-03-31 08:11:03 EDT
This fix is not OK and caused bug 224723. Should reopen, revert and find better fix.
Comment 6 Kim Horne CLA 2008-03-31 08:48:26 EDT
Reopening.  
Comment 7 Kim Horne CLA 2008-04-21 12:28:38 EDT
I think this fix itself is fine - the original code, pre fix, was bogus.  This fix has merely exposed a problem with how we handle high contrast in JFace.  Either we should disregard the provided property files or we should be smarter about how we apply them.  One possible solution: instead of taking them as-supplied we should take the font face and combine it with the default system font size.  Alternatively, in high contrast we simply make every font default to the system font.
Comment 8 Kevin McGuire CLA 2008-04-22 09:55:28 EDT
Kim and I discussed and I'll work on a patch
Comment 9 Kevin McGuire CLA 2008-04-22 10:49:16 EDT
Created attachment 97026 [details]
Patch to keep new behaviour but revert to system fonts in HC

I've created a new patch.  It simply keeps the new behaviour that Matt provided, except in HC mode where it reverts to the old behaviour (which resolves to the system font).  Its a hack but the least disruptive change given the milestone.

I've tested this new patch and it results in the correct text font in HC.

Matt, can you verify it fixes your case too?

I've create bug #228207 as a placeholder for a better fix in 3.5.
Comment 10 Kim Horne CLA 2008-04-22 12:46:01 EDT
(In reply to comment #9)
> Created an attachment (id=97026) [details]
> Patch to keep new behaviour but revert to system fonts in HC
> 
> I've created a new patch.  It simply keeps the new behaviour that Matt
> provided, except in HC mode where it reverts to the old behaviour (which
> resolves to the system font).  Its a hack but the least disruptive change given
> the milestone.
> 
> I've tested this new patch and it results in the correct text font in HC.
> 
> Matt, can you verify it fixes your case too?
> 
> I've create bug #228207 as a placeholder for a better fix in 3.5.
> 

Instead of passing the key in could we not pass in JFaceResources.DEFAULT_FONT?  This would have the same effect without the side effects that this bug corrected, namely: polluting the JFaceRegistry with keys for each of the fonts requested on a particular theme and the creation and destruction of fonts (all identical) for each requested font?
Comment 11 Kevin McGuire CLA 2008-04-23 19:53:19 EDT
(In reply to comment #10)
> Instead of passing the key in could we not pass in JFaceResources.DEFAULT_FONT?
>  This would have the same effect without the side effects that this bug
> corrected, namely: polluting the JFaceRegistry with keys for each of the fonts
> requested on a particular theme and the creation and destruction of fonts (all
> identical) for each requested font?

Its a good point.

I was going for smallest code delta given the milestone and the complexity of jface vs. themes.

My first reaction to your suggestion was that it duplicates the behaviour of how we end up with DEFAULT_FONT (right now its set where, via FontRegistry.defaultFontRecord()? ).

But I guess the claim is that the HC theme is in fact wrong wrt. fonts: it's use of empty <fontOverride>'s was relying on incorrect defaulting behaviour.

Our claim is:
   HC + empty defaultFont = DEFAULT_FONT

So I think your suggestion is the right one.  As a bonus, it'll be a bit easier to figure out how you end up with DEFAULT_FONT when in HC; presently its rather magical.

Even some other mythical HC theme would want to default like this so there's no possibility of regression by moving the behaviour here.
Comment 12 Kevin McGuire CLA 2008-04-24 12:04:26 EDT
Created attachment 97481 [details]
Updated patch to directly use DEFAULT_FONT in HC where no default
Comment 13 Kevin McGuire CLA 2008-04-24 13:27:40 EDT
Raji, Matt suggested you may have time to verify this.
Since its a pretty straightforward delta from what he submitted I am going to go ahead and release it. 

Verified we get the right size text font in HC.
Comment 14 Kevin McGuire CLA 2008-04-24 13:31:57 EDT
patch released
Comment 15 Kevin McGuire CLA 2008-04-30 19:57:05 EDT
Verified in I20080429-0100 that we are getting the correct text font in HC.
Reporter will need to say whether it fixes their case.