Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Which font for all platforms?
Which font for all platforms? [message #492753] Wed, 21 October 2009 15:08 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Hi there,

How do I correctly enter a font name that is platform independent? I
want to set a font explicitly such that it is correct for all platforms
Windows/Linux/Mac.

So what is a platform independent font?

If I do not set any font at all, the different platforms use different
default fonts (Windows=Tahoma, Linux=Sans, Mac=Lucida). Is there any way
to get the same font for different platforms?

What's the right way to do it?

Cheers,
Hauke
Re: Which font for all platforms? [message #492966 is a reply to message #492753] Thu, 22 October 2009 14:14 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Hauke,

Of course the first standard question is, are you sure you want to do this?
The fonts that are used by default on the various platforms come from the
OS, and should generally be used by apps in order to appear visually
consistent with other native apps. Additionally, some users may have
specifically changed these default fonts in their OS, either for aestetics
or for practical reasons (eg.- accessibility).

That being said, if you still want to do this, you'll just need to find a
font that you like that's commonly-available. All you need is a common face
name, then use Device.getFontList(...) to get the available sizes. There
are many available fonts in common between my Windows 2000 and OSX 10.5
machines: Arial, Comic Sans MS, Courier, Courier New, Georgia, Impact,
others... However when I also look at RHEL4 the only one I see in common is
Courier.

HTH,
Grant


"Hauke Fuhrmann" <haf@informatik.uni-kiel.de> wrote in message
news:hbn85f$3d9$1@build.eclipse.org...
> Hi there,
>
> How do I correctly enter a font name that is platform independent? I
> want to set a font explicitly such that it is correct for all platforms
> Windows/Linux/Mac.
>
> So what is a platform independent font?
>
> If I do not set any font at all, the different platforms use different
> default fonts (Windows=Tahoma, Linux=Sans, Mac=Lucida). Is there any way
> to get the same font for different platforms?
>
> What's the right way to do it?
>
> Cheers,
> Hauke
Re: Which font for all platforms? [message #493907 is a reply to message #492753] Wed, 28 October 2009 13:16 Go to previous message
Felipe Heidrich is currently offline Felipe HeidrichFriend
Messages: 29
Registered: July 2009
Junior Member
All control are created with the correct font for the platform.

To obtain the default font for the platform use Device#getSystemFont().

If you really need to force the same font on all platforms, the only reliable way to do that is to ship your own (true type) font with your product and use Device#loadFont(String) to make it usuable from SWT.

Felipe
Previous Topic:Refresh problem
Next Topic:StyledText paragraph indent
Goto Forum:
  


Current Time: Tue Apr 16 16:58:47 GMT 2024

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

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

Back to the top