1 | package org.expeditee.gio;
|
---|
2 |
|
---|
3 | import java.io.File;
|
---|
4 |
|
---|
5 | import 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 | */
|
---|
20 | public 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 | }
|
---|