Bug 156775 Allow fonts to benefit from ResourceManager
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.
bundles/org.eclipse.jface/src/org/eclipse/jface/resource/FontRegistry.java
* thread before calling this method.
     * </p>
     * <p>
     * The OS name (retrieved using <code>System.getProperty("os.name")</code>)
     * is converted to lowercase, purged of whitespace, and appended 
     * as suffix (separated by an underscore <code>'_'</code>) to the given 
     * location string to yield the base name of a resource bundle
     * acceptable to <code>ResourceBundle.getBundle</code>.
     * The standard Java resource bundle mechanism is then used to locate
     * and open the appropriate properties file, taking into account
     * locale specific variations.
     * </p>
     * <p>
     * For example, on the Windows 2000 operating system the location string
     * <code>"com.example.myapp.Fonts"</code> yields the base name 
     * <code>"com.example.myapp.Fonts_windows2000"</code>. For the US English locale,
     * this further elaborates to the resource bundle name
     * <code>"com.example.myapp.Fonts_windows2000_en_us"</code>.
     * </p>
     * <p>
     * If no appropriate OS-specific resource bundle is found, the
     * process is repeated using the location as the base bundle name.
     * </p>
     * <p>
     * The property file contains entries that look like this:
     * <pre>
     *	textfont.0=MS Sans Serif-regular-10
     *	textfont.1=Times New Roman-regular-10
     *	
     *	titlefont.0=MS Sans Serif-regular-12