guk.editIM
Class FontLoader

java.lang.Object
  |
  +--guk.editIM.FontLoader

public class FontLoader
extends java.lang.Object

This class loads a font dynamically, either from file or from a resource. Note that only the user of the font might be able to handle certain glyphs in cut and paste, as other applications may have no access to an appropriate font (as opposed to the situation when using globally installed fonts).


Field Summary
(package private) static int debug
          debug level, as explained in DebugEditIM.
(package private) static java.awt.Font font
          private font object for the current INTERNAL font
(package private) static java.util.Vector iFonts
          internal font names
 
Constructor Summary
FontLoader()
          The constructor preloads internal fonts and inits iFonts.
FontLoader(int udebug)
          The constructor preloads internal fonts and inits iFonts.
 
Method Summary
private  void fontName(java.awt.Font thisFont)
          Print the name of the font with verbosity level 0.
 java.awt.Font fontSet(java.lang.String nameF, int sizeF, java.awt.Font oldFont)
          Find a font with the requested properties or derive it from a known font.
 java.util.Vector getInternalFonts()
          Tell which fonts have been loaded dynamically.
 java.lang.String getInternalName(java.awt.Font afont)
          Get the special "internal" name of a font.
 void loadFonts()
          Initializes the iFonts font collection.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

font

static java.awt.Font font
private font object for the current INTERNAL font

iFonts

static java.util.Vector iFonts
internal font names

debug

static int debug
debug level, as explained in DebugEditIM.
Constructor Detail

FontLoader

public FontLoader()
The constructor preloads internal fonts and inits iFonts. Sets debug level to default, which is quite un-verbose.

FontLoader

public FontLoader(int udebug)
The constructor preloads internal fonts and inits iFonts. Here we can pass the debug level.
Parameters:
debug - Gives a debug level from -1 to infinite (-1 or below mutes normal messages)
Method Detail

fontSet

public java.awt.Font fontSet(java.lang.String nameF,
                             int sizeF,
                             java.awt.Font oldFont)
Find a font with the requested properties or derive it from a known font.
Parameters:
nameF - Name of the font family to be found or null for default.
sizeF - Size in points for the font. If 1 or smaller, take size from oldFont or use default if no oldFont.
oldFont - An already known font from which the new font can be derived, or null.
Returns:
A font which is as close as possible to the requested one. Worst case is returning oldFont.

getInternalFonts

public java.util.Vector getInternalFonts()
Tell which fonts have been loaded dynamically.
Returns:
A list (Vector with Strings) of the internal names of the dynamically loaded fonts.

getInternalName

public java.lang.String getInternalName(java.awt.Font afont)
Get the special "internal" name of a font. Just prefixes the font family name with "Dynamic: " in order to do this. Generates the internal String name for the given aFont, for comparison. Of course, I could encapsulate the loaded fonts in a class with an own equals() or an own conversion to string... I want a certain amount of "do not care" properties, so the normal to string or equals() is not appropriate.
Parameters:
aFont - An arbitrary font, but should be a dynamic one.
Returns:
A special name for that font as described above.

fontName

private void fontName(java.awt.Font thisFont)
Print the name of the font with verbosity level 0.
Parameters:
thisFont - is "named" (size, family, name) to STDOUT

loadFonts

public void loadFonts()
Initializes the iFonts font collection. Load dynamic fonts and remember them in iFonts.