Package org.jfree.svg

Class StandardFontFunction

java.lang.Object
org.jfree.svg.StandardFontFunction
All Implemented Interfaces:
Function<String,​String>

public class StandardFontFunction
extends Object
implements Function<String,​String>
The standard function used in JFreeSVG to create font references for the SVG output. This implementation will substitute SVG generic font names for the Java logical fonts. Methods are provided for adding more font substitutions if you require them. This function will also surround the font name with single-quotes, which addresses issue #27.
Since:
5.0
  • Constructor Summary

    Constructors
    Constructor Description
    StandardFontFunction()
    Creates a new instance with mappings for the Java logical fonts.
  • Method Summary

    Modifier and Type Method Description
    String apply​(String family)
    Returns the SVG font reference for the supplied (Java) font family name.
    String get​(String family)
    Returns the (substitute) SVG font family name for the specified Java font family name, or null if there is no substitute.
    void put​(String family, String substitute)
    Adds a substitute font family name (to be used in the SVG output) for the given Java font family name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Constructor Details

    • StandardFontFunction

      Creates a new instance with mappings for the Java logical fonts.
  • Method Details

    • get

      public String get​(String family)
      Returns the (substitute) SVG font family name for the specified Java font family name, or null if there is no substitute.
      Parameters:
      family - the Java font family name (null not permitted).
      Returns:
      The substitute SVG font family name, or null.
    • put

      public void put​(String family, String substitute)
      Adds a substitute font family name (to be used in the SVG output) for the given Java font family name. If the specified alternate is null it has the effect of clearing any existing substitution.
      Parameters:
      family - the Java font family name (null not permitted).
      substitute - the font family name to substitute in the SVG output (null permitted).
    • apply

      public String apply​(String family)
      Returns the SVG font reference for the supplied (Java) font family name. This implementation provides substitute names for the Java logical fonts. Other Java font family names are not changed, but all font family names are surrounded in single quotes for the SVG output.
      Specified by:
      apply in interface Function<String,​String>
      Parameters:
      family - the font family name (null not permitted).
      Returns:
      The SVG font reference (never null).