Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Set Default Font To Use Eclipse Neon Editor Font Zoom Feature
Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1736017] Fri, 24 June 2016 12:35 Go to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
I would like to adapt my custom Eclipse editor to use the new font zoom feature as described here ("Commands and shortcuts to zoom in text editors"):

https://www.eclipse.org/eclipse/news/4.6/M4/

Momentarily I set the default font in a PreferenceInitializer class.

PreferenceConverter.setDefault(storeR, "colourkeyfont1", new FontData(font, fsize, 0));


However this ahs no effect when using the default TextEditor font settings. I also tried the JFaceResources.getTextFont() to no avail.

How do I have to configure the default editor font that the new feature is applied?
Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1741022 is a reply to message #1736017] Mon, 22 August 2016 11:58 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Your editor has to implement AbstractTextEditor (or be a "multi" editor whose current tab is an AbstractTextEditor, or -from upcoming Neon.1- has an adapter to AbstractTextEditor), and implement properly the getSymbolicFontName() . See https://git.eclipse.org/c/platform/eclipse.platform.text.git/tree/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextZoomHandler.java
Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747066 is a reply to message #1741022] Wed, 09 November 2016 08:04 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
Dear Mickael,

sorry for my late reply. I came aware of your answer yesterday.

However could you be more specific.

Do I have to create my own command and overwrite the key combination for my editor. Or can I capture somehow the zoom command to increase and update my custom fonts?

How do I use the adapter to the AbstractTextEditor in my custom editor?

My custom editor extends the TextEditor.

[Updated on: Wed, 09 November 2016 08:04]

Report message to a moderator

Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747069 is a reply to message #1747066] Wed, 09 November 2016 08:14 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Does your editor inherit from AbstractTextEditor?
Your font need to defined via the fontDefinition extension: http://help.eclipse.org/neon/topic/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ui_themes.html#e.fontDefinition to be accessible via the font registry:
textEditor.getSite().getWorkbenchWindow().getWorkbench().getThemeManager().getCurrentTheme().getFontRegistry()

Then you just need to have getSymbolicFontName() on your editor return the font definition id.
Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747075 is a reply to message #1747069] Wed, 09 November 2016 09:15 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
My editor inherits from "org.eclipse.ui.editors.text.TextEditor"

So I have to add a font definition to my editor from the extension points like this:

http://stackoverflow.com/questions/34952310/how-to-change-font-size-for-an-eclipse-editor-programmatically/34953145

Do I have to implement the getSymbolicFontName() myself?

Will the editor automatically resize the fonts from the font definition after an zoom event or do I need to implement an extra action to update my fonts from my custom font preferences?

Please note that I have defined several font preferences to change several fonts individually.

IPreferenceStore storeR = EditorPlugin.getDefault().getPreferenceStore();
Font f= JFaceResources.getFont(JFaceResources.TEXT_FONT);
PreferenceConverter.setDefault(storeR, "colourkeyfont", f.getFontData());
PreferenceConverter.setDefault(storeR, "colourkeyfont1", f.getFontData());
PreferenceConverter.setDefault(storeR, "colourkeyfont2", f.getFontData());
PreferenceConverter.setDefault(storeR, "colourkeyfont3", f.getFontData());
PreferenceConverter.setDefault(storeR, "colourkeyfont4", f.getFontData());
PreferenceConverter.setDefault(storeR, "colourkeyfont5", f.getFontData());
PreferenceConverter.setDefault(storeR, "colourkeyfont6", f.getFontData());
PreferenceConverter.setDefault(storeR, "colourkeyfont7", f.getFontData());
PreferenceConverter.setDefault(storeR, "colourkeyfont8", f.getFontData());






[Updated on: Wed, 09 November 2016 09:21]

Report message to a moderator

Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747079 is a reply to message #1747075] Wed, 09 November 2016 09:21 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Quote:
My editor inherits from "org.eclipse.ui.editors.text.TextEditor"

So it is also an AbstractTextEditor and the command is supposed to work as soon as getSymbolicFontName() returns the target font and target font is in the FontRegistry,

I think the best is simply that you debug your code. Put a breakpoint on AbstractTextZoomHandler and try to invoke the zoom command to actually see what it does and what it expects.
Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747106 is a reply to message #1747079] Wed, 09 November 2016 13:34 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
I now created an fontDefinition as described here:

http://stackoverflow.com/questions/34952310/how-to-change-font-size-for-an-eclipse-editor-programmatically/34953145

The getSymbolicFontName() is private in the AbstractTextEditor so I cannot override this method in my editor class or am I doing soemthing wrong?


Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747108 is a reply to message #1747106] Wed, 09 November 2016 14:06 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

See how the getSymbolicFont() method is implemented. It gives a hint about how to configure the editor.

Quote:
Please note that I have defined several font preferences to change several fonts individually.

Unfortunately, this use-case isn't properly supported by zoom at the moment: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=483921 . Contributions would be welcome Wink
icon14.gif  Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747110 is a reply to message #1747108] Wed, 09 November 2016 14:23 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
Dear Mickael.
Thank you very much so far for your kind help and time.
I think I can work something out.


Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747177 is a reply to message #1747108] Thu, 10 November 2016 14:16 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
Dear Mickael,

after I implemented my zoom action by overwriting the default keys I detected
several crashes when zooming several times:

After some investigation with the Sleak:

https://www.eclipse.org/articles/swt-design-2/sleak.htm
http://www.vogella.com/tutorials/EclipsePerformance/article.html

I found that more and more font objects are created until no more OS handles are available leading to a freezing of the application, etc.

I use the PreferenceConverter to update my font preferences:

PreferenceConverter.setValue(store, "myfont", font);

Then to verify this behaviour I opened the JDT editor and again by zooming a time in and a time out (the keys were pressed a while) I could increase the handles again.

I can only guess that somewhere in the preferences the Font handles are not disposed.

Is this a unknown bug and can you verify this behaviour?



Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747178 is a reply to message #1747177] Thu, 10 November 2016 14:27 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Is this a bug in Eclipse Platform or in your code? Can you reproduce it with vanilla Eclipse and the plain text editor? If so, please report it ASAP to bugs.eclipse.org.
Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747180 is a reply to message #1747178] Thu, 10 November 2016 14:45 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
I think it is a platform bug because I use JDT and the JDT editor. But however I need to reproduce it in Eclipse itself without my RCP.

Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747184 is a reply to message #1747178] Thu, 10 November 2016 15:15 Go to previous messageGo to next message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
I reproduced this on a new Eclipse platform installation and sleak from within Eclipse in debug mode using the texteditor and the Java editor

https://www.eclipse.org/swt/tools.php

If you constantly zoom in and out more font objects are created probably without using a FontRegistry:

http://www.java2s.com/Tutorial/Java/0280__SWT/UsingtheFontRegistry.htm

You won't do that in practice but if you have more seperate fonts this error multiplies leading to a no more native handle situation.

After about 10000 Font objects the error and freezing occurs. It takes a while with the normal text editor.

[Updated on: Thu, 10 November 2016 15:21]

Report message to a moderator

Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747185 is a reply to message #1747184] Thu, 10 November 2016 15:16 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Ok, please report it to bugs.eclipse.org
Re: Set Default Font To Use Eclipse Neon Editor Font Zoom Feature [message #1747193 is a reply to message #1747185] Thu, 10 November 2016 15:41 Go to previous message
Marcel Austenfeld is currently offline Marcel AustenfeldFriend
Messages: 160
Registered: July 2009
Senior Member
Bug submitted:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=507363#c0
Previous Topic:Is it possible to add handler before "Save all" is performed ?
Next Topic:Workbench window opens in primary monitor only when trying to open from second monitor
Goto Forum:
  


Current Time: Thu Apr 25 13:29:38 GMT 2024

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

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

Back to the top