Project: Eclipse_Platform_UI
Bug 156775 Allow fonts to benefit from ResourceManager
Reported: 2006-09-08 18:13:59 | Status: verified fixed

Eclipse 3.x added a lot of features for manipulating ImageDescriptors and managing them through ResourceManager. Currently, it is cumbersome to do the same thing with Fonts, so most people are still using global Font registry. This enhancement requests that we add features to make Fonts as easy to manage as Images are. - FontDescriptors are provided globally - FontDescriptors are easy to manipulate - Concrete fonts are obtained from the FontDescriptors via a ResourceManager as needed - Fonts benefit from reference-counted shared allocations just like Images do. The attached patch adds the following enhancements for Font management. New Features: 1. (feature) Add helper methods to FontDescriptor to allow font size and style to be set without packing and unpacking the FontData. 2. (performance) Add a getFontData() method to FontDescriptor, to make it possible to manipulate font descriptors without creating a concrete Fonts. 3. (cleanup) Remove NamedFontDescriptor, and replace it with (the more general) ArrayFontDescriptor. 4. (performance) Refactor FontRegistry to use the ResourceManager tree in order to benefit from shared allocations (like Images currently do). 5. (feature) Wherever there is a prominent method that returns a global Font, provide a version that returns a FontDescriptor. Refactor where necessary such that a concrete Font won't be allocated as long as clients are only calling the descriptor version.

Files changed in fix:
bundles/org.eclipse.jface/src/org/eclipse/jface/resource/ArrayFontDescriptor.java bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontDescriptor.java bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java bundles/org.eclipse.jface/src/org/eclipse/jface/resource/JFaceResources.java bundles/org.eclipse.jface/src/org/eclipse/jface/resource/NamedFontDescriptor.java