source: trunk/src/org/expeditee/gio/FontManager.java@ 1500

Last change on this file since 1500 was 1125, checked in by bln4, 6 years ago

org.apollo.items.EmulatedTextItem ->
org.expeditee.agents.GraphFramesetLinks ->
org.expeditee.gio.FontManager ->
org.expeditee.gio.javafx.JavaFXFontManager ->
org.expeditee.gio.swing.SwingFontManager ->
org.expeditee.gui.MessageBay ->
org.expeditee.io.WebParser ->
org.expeditee.items.Text ->

The above files are been altered so that there is no longer any chance Font references will be shared amongst Text Items. How default Fonts are used has been altered so that a Text Item using the default font remember that this is the case. This is a follow up to an initial fix for the same problem that turned out to be insufficient.

File size: 1.9 KB
Line 
1package org.expeditee.gio;
2
3import java.io.File;
4
5import org.expeditee.core.Font;
6
7/**
8 * Class for managing font references in Expeditee. Expeditee's Font class is an
9 * opaque handle that is translated to an internal representation when used by
10 * other managers. The internal representation used for a given Font handle is
11 * implementation-specific (i.e. if an exact match for the font handle is not registered
12 * with the manager, the alternative selected is undefined).
13 *
14 * TTF font files can be registered with the manager to increase the range of internal
15 * fonts available, and a collection of handles to all of the fonts the manager supports
16 * can be requested.
17 *
18 * @author cts16
19 */
20public abstract class FontManager {
21
22 protected static final String DEFAULT_FONT_FAMILY = "Serif";
23 protected static final int DEFAULT_FONT_SIZE = 18;
24
25 /** The default font registered with the manager. */
26 private Font _defaultFont = new Font();
27
28 /** Returns the default font registered with the manager. */
29 public final Font getDefaultFont()
30 {
31 return _defaultFont;
32 }
33
34 /** Sets the default font for the font manager. */
35 public final void setDefaultFont(final Font font)
36 {
37 _defaultFont = font;
38 }
39
40 /** Registers a font file with the font manager, and returns the handle
41 to the newly registered font. */
42 public abstract Font registerFontFile(File fontFile);
43
44 /** Gets an array of all font families registered with the manager. */
45 public abstract String[] getRegisteredFontFamilies();
46
47 /** Returns true if the given font is registered with the manager. */
48 public abstract boolean isFontFamilyRegistered(String fontFamily);
49
50 /** Returns a handle representing the actual font used for the given font. */
51 public abstract Font getActualFont(Font font);
52
53 /** Checks if the given font was matched exactly by the font manager. */
54 public boolean fontIsActualFont(Font font)
55 {
56 if (font == null) return false;
57
58 return font.equals(getActualFont(font));
59 }
60
61
62}
Note: See TracBrowser for help on using the repository browser.