Class FontSpec

java.lang.Object
com.helger.pdflayout.spec.FontSpec
All Implemented Interfaces:
Serializable

@NotThreadSafe @MustImplementEqualsAndHashcode public class FontSpec extends Object implements Serializable
Defines a text font specification containing the font, the font size and the text color.
Author:
Philip Helger
See Also:
  • Field Details

    • DEFAULT_COLOR

      public static final PLColor DEFAULT_COLOR
      The default font color: black
  • Constructor Details

    • FontSpec

      public FontSpec(@Nonnull PreloadFont aPreloadFont, @Nonnegative float fFontSize)
      Constructor with a PreloadFont and a font size, using the default color DEFAULT_COLOR.
      Parameters:
      aPreloadFont - Preload font to use. May not be null.
      fFontSize - Font size to use. Must be > 0.
    • FontSpec

      public FontSpec(@Nonnull PreloadFont aPreloadFont, @Nonnegative float fFontSize, @Nonnull PLColor aColor)
      Constructor with a PreloadFont, a font size and a custom color.
      Parameters:
      aPreloadFont - Preload font to use. May not be null.
      fFontSize - Font size to use. Must be > 0.
      aColor - The color to use. May not be null.
      Since:
      7.2.0
  • Method Details

    • getPreloadFont

      @Nonnull public final PreloadFont getPreloadFont()
      Returns:
      The font to use. Never null.
    • getPreloadFontID

      @Nonnull @Nonempty public final String getPreloadFontID()
      Returns:
      The ID of the font to use. Never null.
    • getFontSize

      @Nonnegative public final float getFontSize()
      Returns:
      The font size in points. Always > 0.
    • getColor

      @Nonnull public final PLColor getColor()
      Returns:
      The text color to use.
    • getCloneWithDifferentFont

      @Nonnull public FontSpec getCloneWithDifferentFont(@Nonnull PreloadFont aNewFont)
      Return a clone of this object but with a different font.
      Parameters:
      aNewFont - The new font to use. Must not be null.
      Returns:
      this if the fonts are equal - a new object otherwise.
    • getCloneWithDifferentFontSize

      @Nonnull public FontSpec getCloneWithDifferentFontSize(float fNewFontSize)
      Return a clone of this object but with a different font size.
      Parameters:
      fNewFontSize - The new font size to use. Must be > 0.
      Returns:
      this if the font sizes are equal - a new object otherwise.
    • getCloneWithDifferentColor

      @Nonnull public FontSpec getCloneWithDifferentColor(@Nonnull PLColor aNewColor)
      Return a clone of this object but with a different color.
      Parameters:
      aNewColor - The new color to use. May not be null.
      Returns:
      this if the colors are equal - a new object otherwise.
      Since:
      7.2.0
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object