All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.w3c.css.properties.CssFont

java.lang.Object
   |
   +----org.w3c.css.properties.CssProperty
           |
           +----org.w3c.css.properties.CssFont

public class CssFont
extends CssProperty
implements CssOperator, CssFontConstant

   'font'

Value: [ <font-style> || <font-variant> || <font-weight> ]? <font-size> [ / <line-height> ]? <font-family>
Initial: not defined for shorthand properties
Applies to: all elements
Inherited: yes
Percentage values: allowed on <font-size> and <line-height>

The 'font' property is a shorthand property for setting 'font-style', 'font-variant', 'font-weight', 'font-size', 'line-height' and 'font-family' at the same place in the style sheet. The syntax of this property is based on a traditional typographical shorthand notation to set multiple properties related to fonts.

For a definition of allowed and initial values, see the previously defined properties. Properties for which no values are given are set to their initial value.

   P { font: 12pt/14pt sans-serif }
   P { font: 80% sans-serif }
   P { font: x-large/110% "new century schoolbook", serif }
   P { font: bold italic large Palatino, serif }
   P { font: normal small-caps 120%/120% fantasy }
   

In the second rule, the font size percentage value ('80%') refers to the font size of the parent element. In the third rule, the line height percentage refers to the font size of the element itself.

In the first three rules above, the 'font-style', 'font-variant' and 'font-weight' are not explicitly mentioned, which means they are all three set to their initial value ('normal'). The fourth rule sets the 'font-weight' to 'bold', the 'font-style' to 'italic' and implicitly sets 'font-variant' to 'normal'.

The fifth rule sets the 'font-variant' ('small-caps'), the 'font-size' (120% of the parent's font), the 'line-height' (120% times the font size) and the 'font-family' ('fantasy'). It follows that the keyword 'normal' applies to the two remaining properties: 'font-style' and 'font-weight'.

See Also:
CssFontStyle, CssFontVariant, CssFontWeight, CssFontSize, CssLineHeight, CssFontFamily, CssPercentage, CssLength

Constructor Index

 o CssFont()
Create a new CssFont
 o CssFont(CssExpression)
Creates a new CssFont

Method Index

 o addToStyle(CssStyle)
Add this property to the CssStyle
 o equals(CssProperty)
Compares two properties for equality.
 o get()
Returns the value of this property
 o getImportant()
Returns true if this property is important.
 o getPropertyInStyle(CssStyle, boolean)
Get this property in the style.
 o getPropertyName()
Returns the name of this property
 o print(CssPrinterStyle)
Print this property.
 o setImportant()
Set this property to be important.
 o setInfo(int, String)
Update the source file and the line.
 o setSelectors(CssSelectors)
Set the context.
 o toString()
Returns a string representation of the object.

Constructors

 o CssFont
 public CssFont()
Create a new CssFont

 o CssFont
 public CssFont(CssExpression expression) throws InvalidParamException
Creates a new CssFont

Parameters:
expression - The expression for this property
Throws: InvalidParamException
The expression is incorrect

Methods

 o get
 public Object get()
Returns the value of this property

Overrides:
get in class CssProperty
 o toString
 public String toString()
Returns a string representation of the object.

Overrides:
toString in class CssProperty
 o setImportant
 public void setImportant()
Set this property to be important. Overrides this method for a macro

Overrides:
setImportant in class CssProperty
 o getImportant
 public boolean getImportant()
Returns true if this property is important. Overrides this method for a macro

Overrides:
getImportant in class CssProperty
 o print
 public void print(CssPrinterStyle printer)
Print this property.

Parameters:
printer - The printer
Overrides:
print in class CssProperty
See Also:
toString, getPropertyName
 o addToStyle
 public void addToStyle(CssStyle style)
Add this property to the CssStyle

Parameters:
style - The CssStyle
Overrides:
addToStyle in class CssProperty
 o setInfo
 public void setInfo(int line,
                     String source)
Update the source file and the line. Overrides this method for a macro

Parameters:
line - The line number where this property is defined
source - The source file where this property is defined
Overrides:
setInfo in class CssProperty
 o equals
 public boolean equals(CssProperty property)
Compares two properties for equality.

Parameters:
value - The other property.
Overrides:
equals in class CssProperty
 o setSelectors
 public void setSelectors(CssSelectors selector)
Set the context. Overrides this method for a macro

Overrides:
setSelectors in class CssProperty
See Also:
order, handleRule
 o getPropertyInStyle
 public CssProperty getPropertyInStyle(CssStyle style,
                                       boolean resolve)
Get this property in the style.

Parameters:
style - The style where the property is
resolve - if true, resolve the style to find this property
Overrides:
getPropertyInStyle in class CssProperty
 o getPropertyName
 public String getPropertyName()
Returns the name of this property

Overrides:
getPropertyName in class CssProperty

All Packages  Class Hierarchy  This Package  Previous  Next  Index