Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to change the default font of my RCP application?(I want every control to use the font I select.)
How to change the default font of my RCP application? [message #500698] Fri, 27 November 2009 15:00 Go to next message
Marton Sigmond is currently offline Marton SigmondFriend
Messages: 73
Registered: July 2009
Location: Hungary
Member
Hi,

I would like the whole RCP application use a specific font.
So without calling the setFont() method for every control in the whole app, I would like to set it globally, like setting a default font.

Is it possible?

Thank you for your help.
Marton


Best Regards,
Marton Sigmond
Senior Software Engineer
Re: How to change the default font of my RCP application? [message #501089 is a reply to message #500698] Mon, 30 November 2009 23:00 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Hi Marton,

It should be given that the font can be set globally in the eclipse
preferences General/Appearance/Colors and Fonts/Basic/Text

If you can't use that then please take a look at the org.eclipse.ui.themes
extension point. Be sure to look at the extension point description and look
at the example in the end. In addition to this, Kai Toedters MP3 managers
contains an example implementation of themes.

--

Best Regards,
Wim Jongman

-- The name is Baud......, James Baud.
(Eclipse Old Skool Quote Service)
> Hi,
>
> I would like the whole RCP application use a specific font.
> So without calling the setFont() method for every control in the whole app,
I would like to set it globally, like setting a default font.
>
> Is it possible?
>
> Thank you for your help.
> Marton
Re: How to change the default font of my RCP application? [message #501415 is a reply to message #501089] Wed, 02 December 2009 09:21 Go to previous messageGo to next message
Marton Sigmond is currently offline Marton SigmondFriend
Messages: 73
Registered: July 2009
Location: Hungary
Member
Hi Wim,

thank you for the answer.

The first approach cannot be taken, since this is an RCP application that does not have preferences menu.

Themes:
Many fonts can be overridden, but not the default font.

So for example when I create an instance of the org.eclipse.swt.widgets.Label, it uses some font.
What is the font that the Label uses?
How can I set it globally (without calling the setFont method for each label)?

And of course not just the Label I am interested in, but every widget.
Can I set a font that every widget uses by default?

Thanks,
Marton


Best Regards,
Marton Sigmond
Senior Software Engineer
Re: How to change the default font of my RCP application? [message #501418 is a reply to message #501415] Wed, 02 December 2009 09:41 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
SWT uses the System-Font like you specified it your
OS-Theme-Configuration. In plain 3.x there's not other possibility than
to call setFont() on all the labels.

The future (e4) though will solve this by letting you use a declartive
Syntax (similar to CSS) the this would look like this:

my.css
------
Label {
font-family: Comic Sans;
}

The nice thing is that the e4-css engine coming with e4 0.9 can be run
on 3.5-SWT-Code without problems.

The best thing to find out how it works is to check out the CSS-Example
part of the e4-CVS
(dev.eclipse.org:/cvsroot/eclipse/e4/org.eclipse.e4/examples /org.eclipse.e4.ui.examples.css.rcp).

Tom

Marton Sigmond schrieb:
> Hi Wim,
>
> thank you for the answer.
>
> The first approach cannot be taken, since this is an RCP application
> that does not have preferences menu.
>
> Themes:
> Many fonts can be overridden, but not the default font.
>
> So for example when I create an instance of the
> org.eclipse.swt.widgets.Label, it uses some font.
> What is the font that the Label uses?
> How can I set it globally (without calling the setFont method for each
> label)?
>
> And of course not just the Label I am interested in, but every widget.
> Can I set a font that every widget uses by default?
>
> Thanks,
> Marton
>
Re: How to change the default font of my RCP application? [message #501419 is a reply to message #501415] Wed, 02 December 2009 09:44 Go to previous messageGo to next message
Adam Lucarz is currently offline Adam LucarzFriend
Messages: 518
Registered: July 2009
Senior Member
Hi,

the font styles are taken from the os and some can be overriden by the mentioned theme extension point. But these can be only done for special purposes. The better approach would be to create the swt widgets by a factory like construct and to set the fonts by setFont() on every widget to get full control.

But at the end this is a very time consuming work, because the support for font styling is very restricted in eclipse rcp (until e4 ?). The philosophy of eclipse rcp is to integrate into the running os like a native app. Therefore this font customizing feature is not really evolved.

Have you ever tried to change the font of outlook or word?

Greetings
Adam
Re: How to change the default font of my RCP application? [message #501433 is a reply to message #501418] Wed, 02 December 2009 10:09 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Forgot to mention. There's another solution to this which also provides
declarative styleing for (SWT, Swing, Qt, ...).

The project is named UFaceKit [1] comes with it's own very tiny
Declarative Styling Syntax (compared to the big dependency stack of
e4-0.9 styling).

The bad thing is that UFaceKit has no build yet (we've been blocked by
bringing all dependencies to orbit) you can consume out of the box so
you need to checkout the sources from SVN.

Since 1 week all dependencies for the SWT-Port of UFace are in orbit and
we started working on a Buckminster build

Talking of UFaceKit it provides other probably interesting features like:
* Declarative Styling (including automatic resource management for
colors, fonts, images)
* MVP Development model
* Java5-Viewers with type safety
* XPath-Query to walk your UI-Widget-Tree
* JSON-Serialization (Handy for JUnit-Tests)
* Events on programmatic property setting
* Reflective API similar to EMF
* Declarative UI-Definition using EMF
* ...

Tom

[1]http://wiki.eclipse.org/UFaceKit

Tom Schindl schrieb:
> SWT uses the System-Font like you specified it your
> OS-Theme-Configuration. In plain 3.x there's not other possibility than
> to call setFont() on all the labels.
>
> The future (e4) though will solve this by letting you use a declartive
> Syntax (similar to CSS) the this would look like this:
>
> my.css
> ------
> Label {
> font-family: Comic Sans;
> }
>
> The nice thing is that the e4-css engine coming with e4 0.9 can be run
> on 3.5-SWT-Code without problems.
>
> The best thing to find out how it works is to check out the CSS-Example
> part of the e4-CVS
> (dev.eclipse.org:/cvsroot/eclipse/e4/org.eclipse.e4/examples /org.eclipse.e4.ui.examples.css.rcp).
>
> Tom
>
> Marton Sigmond schrieb:
>> Hi Wim,
>>
>> thank you for the answer.
>>
>> The first approach cannot be taken, since this is an RCP application
>> that does not have preferences menu.
>>
>> Themes:
>> Many fonts can be overridden, but not the default font.
>>
>> So for example when I create an instance of the
>> org.eclipse.swt.widgets.Label, it uses some font.
>> What is the font that the Label uses?
>> How can I set it globally (without calling the setFont method for each
>> label)?
>>
>> And of course not just the Label I am interested in, but every widget.
>> Can I set a font that every widget uses by default?
>>
>> Thanks,
>> Marton
>>
Re: How to change the default font of my RCP application? [message #501436 is a reply to message #501433] Wed, 02 December 2009 10:47 Go to previous message
Marton Sigmond is currently offline Marton SigmondFriend
Messages: 73
Registered: July 2009
Location: Hungary
Member
Guys,

thank you for your replies.

I am already aware of the E4 and the UFaceKit, and I find them the most exciting projects of these days!
I am also a frequent reader of Tom's blog. Smile
Thank you for your hard work on this!

Best regards,
Marton


Best Regards,
Marton Sigmond
Senior Software Engineer
Previous Topic:Trying to Understand RCP & its Platform dependencies
Next Topic:Open Perspectives
Goto Forum:
  


Current Time: Fri Mar 29 07:19:54 GMT 2024

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

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

Back to the top