Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Font mixup
Font mixup [message #59901] Wed, 14 November 2007 13:09 Go to next message
Eclipse UserFriend
I had some trouble with fonts where Graphics#getFont() returned another
font than I requested.
In my example a wanted to have a font with the size 13 style SWT.NORMAL
but received size 12 style SWT.BOLD.

I found out that the reason is hash-function ResourceFactory#getFont
where a hashkey for each font is calculated by XORing font name, font
size and font style.
This means that, asuming an identical font name, all fonts with an odd
size and SWT.NORMAL are treated identical to their even predecessors
with a SWT.BOLD style.

As a possible bugfix, I would propose to left shift the font size before
adding:
Integer key = new Integer( name.hashCode() ^ (height << 2) ^ style );

There's still a little uncertainty because of the font name however this
should lead to problems only in rare cases.

I filed a bug for this issue:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=209843
Re: Font mixup [message #60388 is a reply to message #59901] Mon, 19 November 2007 06:54 Go to previous message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

I applied the fix proposal - let's see whether the font name will cause any
problems.

Ciao
Frank

"Stefan R
Previous Topic:History of RAP
Next Topic:NPE in org.eclipse.core.runtime when starting RAP-app
Goto Forum:
  


Current Time: Mon Jun 02 16:04:51 EDT 2025

Powered by FUDForum. Page generated in 0.02387 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top