Class WFont

java.lang.Object
eu.webtoolkit.jwt.WFont

public class WFont
extends java.lang.Object
A value class that describes a font.
  • Constructor Details

    • WFont

      public WFont()
      A default font (dependent on the user agent).
    • WFont

      public WFont​(WFont.GenericFamily family)
      A font of a given family.

      Creates a Medium font of the given family.

  • Method Details

    • equals

      public boolean equals​(WFont other)
      Indicates whether some other object is "equal to" this one.
    • setFamily

      public void setFamily​(WFont.GenericFamily genericFamily, java.lang.CharSequence specificFamilies)
      Sets the font family.

      The font family is specified using a generic family name, in addition to a comma-seperated list of specific font choices.

      The first specific font that can be matched will be used, otherwise a generic font will be used.

      Careful, for a font family name that contains a space, you need to add quotes, to setFamily(), e.g.

      
       WFont mono;
       mono.setFamily(WFont::Monospace, "'Courier New'");
       mono.setSize(18);
      
       
    • setFamily

      public final void setFamily​(WFont.GenericFamily genericFamily)
      Sets the font family.

      Calls setFamily(genericFamily, new WString())

    • getGenericFamily

      public WFont.GenericFamily getGenericFamily()
      Returns the font generic family.
    • getSpecificFamilies

      public WString getSpecificFamilies()
      Returns the font specific family names.
    • setStyle

      public void setStyle​(WFont.Style style)
      Sets the font style.
    • getStyle

      public WFont.Style getStyle()
      Returns the font style.
    • setVariant

      public void setVariant​(WFont.Variant variant)
      Sets the font variant.
    • getVariant

      public WFont.Variant getVariant()
      Returns the font variant.
    • setWeight

      public void setWeight​(WFont.Weight weight, int value)
      Sets the font weight.

      When setting weight == Value, you may specify a value.

      Valid values are between 100 and 900, and are rounded to multiples of 100.

    • setWeight

      public final void setWeight​(WFont.Weight weight)
      Sets the font weight.

      Calls setWeight(weight, 400)

    • getWeight

      public WFont.Weight getWeight()
      Returns the font weight.
    • getWeightValue

      public int getWeightValue()
      Returns the font weight value.
    • setSize

      public void setSize​(WFont.Size size, WLength length)
      Sets the font size (deprecated)

      Use setSize() or setSize() instead.

    • setSize

      public void setSize​(WFont.Size size)
      Sets the font size.

      Sets the font size using a predefined CSS size.

    • setSize

      public void setSize​(WLength size)
      Sets the font size.

      Sets the font size.

    • getSize

      public WFont.Size getSize​(double mediumSize)
      Returns the font size.
    • getSize

      public final WFont.Size getSize()
      Returns the font size.

      Returns getSize(16)

    • getFixedSize

      public WLength getFixedSize()
      Deprecated.
      This method has been renamed to getSizeLength()
      Returns the font size as a numerical value (deprecated).

    • getSizeLength

      public WLength getSizeLength​(double mediumSize)
      Returns the font size as a numerical value.

      Absolute size enumerations are converted to a length assuming a Medium font size of 16 px.

    • getSizeLength

      public final WLength getSizeLength()
      Returns the font size as a numerical value.

      Returns getSizeLength(16)

    • updateDomElement

      public void updateDomElement​(DomElement element, boolean fontall, boolean all)