com.atlassian.confluence.util
Class DefaultFontManager

java.lang.Object
  extended by com.atlassian.confluence.util.DefaultFontManager
All Implemented Interfaces:
FontManager

public class DefaultFontManager
extends java.lang.Object
implements FontManager


Field Summary
static java.lang.String DEFAULT_FONT
           
static org.apache.log4j.Category log
           
 
Constructor Summary
DefaultFontManager()
           
 
Method Summary
static java.io.File getBaseFontsDir()
           
 java.lang.String getCurrentFont()
           
 void installFont(java.io.File candidateFontFile)
          Deprecated. Since 2.8
 void installFont(org.springframework.core.io.Resource fontResource)
          Builds a FOP font metrics file and copies it and the font resource itself to the "fonts" directory inside Confluence home.
 boolean isCustomFontInstalled()
           
 void restoreDefaultFont()
          Removes custom font if one has been installed and reconfigures FOP to use the default font
 void setFopConfigurationFactory(FopConfigurationFactory fopConfigurationFactory)
           
 void setFopFactory(org.apache.fop.apps.FopFactory fopFactory)
           
protected  void writeCustomFopConfig(com.atlassian.confluence.util.DefaultFontManager.Font font)
          Writes a FOP configuration file containing the declaration of our custom font
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Category log

DEFAULT_FONT

public static final java.lang.String DEFAULT_FONT
See Also:
Constant Field Values
Constructor Detail

DefaultFontManager

public DefaultFontManager()
Method Detail

installFont

public void installFont(java.io.File candidateFontFile)
                 throws java.io.IOException,
                        org.apache.fop.apps.FOPException
Deprecated. Since 2.8

Builds a FOP font metrics file and copies it and the font file itself to the "fonts" directory inside Confluence home. Also builds a FOP config file to register the font with FOP. (currently supports True Type and True Type Collection font files - TTF and TTC)

Specified by:
installFont in interface FontManager
Throws:
java.io.IOException -
  • if the font being installed does not exist
  • if there is an error copying the font file to the fonts folder in the Confluence home directory
  • or if there is an error converting a file path to a URL
org.apache.fop.apps.FOPException - if there is an error registering this new font with FOP
See Also:
installFont(org.springframework.core.io.Resource)

installFont

public void installFont(org.springframework.core.io.Resource fontResource)
                 throws java.io.IOException,
                        org.apache.fop.apps.FOPException
Builds a FOP font metrics file and copies it and the font resource itself to the "fonts" directory inside Confluence home. Also builds a FOP config file to register the font with FOP. (currently supports True Type and True Type Collection font files - TTF and TTC)

Specified by:
installFont in interface FontManager
Parameters:
fontResource - resource to install as a font
Throws:
java.io.IOException -
  • if the font resource does not exist
  • if there is an error copying the font resource to the fonts folder in the Confluence home directory
  • or if there is an error converting a file path to a URL
org.apache.fop.apps.FOPException - if there is an error registering this new font with FOP

restoreDefaultFont

public void restoreDefaultFont()
                        throws org.apache.fop.apps.FOPException
Description copied from interface: FontManager
Removes custom font if one has been installed and reconfigures FOP to use the default font

Specified by:
restoreDefaultFont in interface FontManager
Throws:
org.apache.fop.apps.FOPException - if there is an error registering the default font with FOP

getCurrentFont

public java.lang.String getCurrentFont()
Specified by:
getCurrentFont in interface FontManager
Returns:
either the custom font (if one exists) or the default font (Verdana).

isCustomFontInstalled

public boolean isCustomFontInstalled()
Specified by:
isCustomFontInstalled in interface FontManager
Returns:
true if a custom font has been installed

writeCustomFopConfig

protected void writeCustomFopConfig(com.atlassian.confluence.util.DefaultFontManager.Font font)
                             throws java.io.IOException
Writes a FOP configuration file containing the declaration of our custom font

Throws:
java.io.IOException - if there are any errors converting file paths to URL's or there is an error closing the writer

getBaseFontsDir

public static java.io.File getBaseFontsDir()

setFopFactory

public void setFopFactory(org.apache.fop.apps.FopFactory fopFactory)

setFopConfigurationFactory

public void setFopConfigurationFactory(FopConfigurationFactory fopConfigurationFactory)


Copyright © 2003-2008 Atlassian Pty Ltd. All Rights Reserved.