Class FontFamily

All Implemented Interfaces:
CssProperty, Serializable, Cloneable

public class FontFamily extends AbstractCssProperty<FontFamily>
 font-family: font|initial|inherit;

 Value:       [[ <family-name> | <generic-family> ] [, <family-name>| <generic-family>]* ] | inherit
 Initial:        depends on user agent
 Applies to:     all elements
 Inherited:      yes
 Percentages:    N/A
 Media:          visual
 Computed value:         as specified

 Support Classes :-
 1. GenericFontFamilyNameContants
 
Since:
1.0.0
See Also:
  • Field Details

  • Constructor Details

    • FontFamily

      public FontFamily()
      The initial will be set as the value
    • FontFamily

      public FontFamily(String cssValue)
      Parameters:
      cssValue - the css value to set.
    • FontFamily

      public FontFamily(String... fontFamilyNames)
       Eg:-
       String[] fontFamilyNames = {"Times New Roman", "Georgia", GenericFontFamilyNameContants.SERIF};
      
       
      Parameters:
      fontFamilyNames - the font family names.
    • FontFamily

      public FontFamily(FontFamily fontFamily)
      Parameters:
      fontFamily - the FontFamily object from which the cssValue to set.And, null will throw NullValueException
  • Method Details

    • getBuiltCssValue

      protected static String getBuiltCssValue(String... fontFamilyNames)
      Parameters:
      fontFamilyNames -
      Returns:
      the built cssValue string from the given fontFamilyNames.
      Since:
      1.0.0
    • getCssName

      public String getCssName()
      Returns:
      the name portion in style, eg align-content for style align-content: center.
    • getCssValue

      public String getCssValue()
      Returns:
      the value portion in style, eg center for style align-content: center.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • setCssValue

      public FontFamily setCssValue(String cssValue)
      Specified by:
      setCssValue in class AbstractCssProperty<FontFamily>
      Parameters:
      cssValue - The value should be a fontFamilies sequence for example \ "Times New Roman\", Georgia, Serif Or initial/inherit.
      Returns:
      the current object.
      Since:
      1.0.0
    • getExtractedFamilyNames

      protected static String[] getExtractedFamilyNames(String familyNames, boolean validate)
      Parameters:
      familyNames -
      validate - TODO
      Returns:
      an array containing extracted family names from the given input.
      Since:
      1.0.0
    • setFontFamilyNames

      public void setFontFamilyNames(String[] fontFamilyNames)
       Eg:-
       String[] fontFamilyNames = {"Times New Roman", "Georgia", GenericFontFamilyNameContants.SERIF};
      
       
      Parameters:
      fontFamilyNames - the fontFamilyNames to set
      Since:
      1.0.0
    • getFontFamilyNames

      public String[] getFontFamilyNames()
      gets the font family names as an array and if here is no names set then returns an empty array.
       Note: it will never return null.
       
      Returns:
      the fontFamilyNames. If there is no family name set then returns an empty array instead of null.
      Since:
      1.0.0
    • setAsInitial

      public void setAsInitial()
      sets as initial
      Since:
      1.0.0
    • setAsInherit

      public void setAsInherit()
      sets as inherit
      Since:
      1.0.0
    • addFontFamilyName

      public static void addFontFamilyName(String fontFamilyName)
      Parameters:
      fontFamilyName - the supported font-family.
      Since:
      1.0.0
    • addFontFamilyNames

      public static void addFontFamilyNames(Collection<String> fontFamilyNames)
      Parameters:
      fontFamilyNames - the supported font-family names.
      Since:
      1.0.0
    • getAddedFontFamilyNames

      public Set<String> getAddedFontFamilyNames()
      Returns:
      the set of font-family names added by FontFamily#addFontFamilyName(String) and FontFamily#addFontFamilyNames(Collection) methods.
      Since:
      1.0.0
    • isValidateFontFamilyName

      public boolean isValidateFontFamilyName()
      Returns:
      the validateFontFamilyName
      Since:
      1.0.0
    • setValidateFontFamilyName

      public void setValidateFontFamilyName(boolean validateFontFamilyName)
      Parameters:
      validateFontFamilyName - the validateFontFamilyName to set
      Since:
      1.0.0
    • isValidateFontFamilyNameGlobally

      public static boolean isValidateFontFamilyNameGlobally()
      Returns:
      the validateFontFamilyNameGlobally
      Since:
      1.0.0
    • setValidateFontFamilyNameGlobally

      public static void setValidateFontFamilyNameGlobally(boolean validateFontFamilyNameGlobally)
      Parameters:
      validateFontFamilyNameGlobally - the validateFontFamilyNameGlobally to set
      Since:
      1.0.0
    • isValid

      public static boolean isValid(String cssValue)
      Returns:
      true if the given cssValue is validate. It also checks whether the font-family names added by FontFamily#addFontFamilyName(String) and FontFamily#addFontFamilyNames(Collection) methods contain the given cssValue.
      Since:
      1.0.0