Class FontResource


  • public class FontResource
    extends Resource
    A Resource wrapping a Font.
    See Also:
    Resource, Font
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.Font font  
      private static java.util.logging.Logger logger  
      static java.lang.String SCHEME  
    • Constructor Summary

      Constructors 
      Constructor Description
      FontResource​(java.lang.String primaryKey, java.awt.Font font)  
      FontResource​(java.lang.String primaryKey, java.net.URI resourceLocator)
      Do not use directly.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.Font getEmergencyFont()
      Gets a font of last resort, as finding fonts must not fail! Currently using the default Java font, not matter how ugly.
      java.awt.Font getFont()
      Gets the Font represented by this resource.
      void preload()
      Preload the resource if possible/meaningful.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • font

        private java.awt.Font font
    • Constructor Detail

      • FontResource

        public FontResource​(java.lang.String primaryKey,
                            java.awt.Font font)
      • FontResource

        public FontResource​(java.lang.String primaryKey,
                            java.net.URI resourceLocator)
                     throws java.io.IOException
        Do not use directly.
        Parameters:
        primaryKey - The primary key.
        resourceLocator - The URI used when loading this resource.
        Throws:
        java.io.IOException - if unable to read the font.
    • Method Detail

      • preload

        public void preload()
        Preload the resource if possible/meaningful.
        Specified by:
        preload in class Resource
      • getFont

        public java.awt.Font getFont()
        Gets the Font represented by this resource. As failure to load a critical font might remove the ability to even display an error message, it is too risky to allow this routine to return null. Hence the emergency font use.
        Returns:
        The Font for this resource, or the default Java font if none found.
      • getEmergencyFont

        public static java.awt.Font getEmergencyFont()
        Gets a font of last resort, as finding fonts must not fail! Currently using the default Java font, not matter how ugly.
        Returns:
        The default Java font.