All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.w3c.css.properties.CssFontWeight

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

public class CssFontWeight
extends CssProperty
implements CssFontConstant

   'font-weight'

Value: normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
Initial: normal
Applies to: all elements
Inherited: yes
Percentage values: N/A

The 'font-weight' property selects the weight of the font. The values '100' to '900' form an ordered sequence, where each number indicates a weight that is at least as dark as its predecessor. The keyword 'normal' is synonymous with '400', and 'bold' is synonymous with '700'. Keywords other than 'normal' and 'bold' have been shown to be often confused with font names and a numerical scale was therefore chosen for the 9-value list.

   P { font-weight: normal }    400
   H1 { font-weight: 700 }      bold
 

The 'bolder' and 'lighter' values select font weights that are relative to the weight inherited from the parent:

   STRONG { font-weight: bolder }
 

Child elements inherit the resultant weight, not the keyword value.

Fonts (the font data) typically have one or more properties whose values are names that are descriptive of the "weight" of a font. There is no accepted, universal meaning to these weight names. Their primary role is to distinguish faces of differing darkness within a single font family. Usage across font families is quite variant; for example a font that you might think of as being bold might be described as being Regular, Roman, Book, Medium, Semi- or DemiBold, Bold, or Black, depending on how black the "normal" face of the font is within the design. Because there is no standard usage of names, the weight property values in CSS1 are given on a numerical scale in which the value '400' (or 'normal') corresponds to the "normal" text face for that family. The weight name associated with that face will typically be Book, Regular, Roman, Normal or sometimes Medium.

The association of other weights within a family to the numerical weight values is intended only to preserve the ordering of darkness within that family. However, the following heuristics tell how the assignment is done in typical cases:

The following two examples illustrate the process. Assume four weights in the "Example1" family, from lightest to darkest: Regular, Medium, Bold, Heavy. And assume six weights in the "Example2" family: Book, Medium, Bold, Heavy, Black, ExtraBlack. Note how in the second example it has been decided not to assign "Example2 ExtraBlack" to anything.

     Available faces       |  Assignments  |  Filling the holes
     ----------------------+---------------+-------------------
     "Example1 Regular"    |  400          |  100, 200, 300
     "Example1 Medium"     |  500          |
     "Example1 Bold"       |  700          |  600
     "Example1 Heavy"      |  800          |  900
 
     Available faces       |  Assignments  |  Filling the holes
     ----------------------+---------------+-------------------
     "Example2 Book"       |  400          |  100, 200, 300
     "Example2 Medium"     |  500          |
     "Example2 Bold"       |  700          |  600      
     "Example2 Heavy"      |  800          |
     "Example2 Black"      |  900          |
     "Example2 ExtraBlack" |  (none)       |
 

Since the intent of the relative keywords 'bolder' and 'lighter' is to darken or lighten the face within the family and because a family may not have faces aligned with all the symbolic weight values, the matching of 'bolder' is to the next darker face available on the client within the family and the matching of 'lighter' is to the next lighter face within the family. To be precise, the meaning of the relative keywords 'bolder' and 'lighter' is as follows:

There is no guarantee that there will be a darker face for each of the 'font-weight' values; for example, some fonts may have only a normal and a bold face, others may have eight different face weights. There is no guarantee on how a UA will map font faces within a family to weight values. The only guarantee is that a face of a given value will be no less dark than the faces of lighter values.


Variable Index

 o value
an index in a array

Constructor Index

 o CssFontWeight()
Create a new FontWeight with the default value.
 o CssFontWeight(CssExpression)
Creates a new CssFontWeight with an expression.

Method Index

 o addToStyle(CssStyle)
Add this property to the CssStyle
 o equals(CssProperty)
Compares two properties for equality.
 o get()
Returns the current value.
 o getPropertyInStyle(CssStyle, boolean)
Get this property in the style.
 o getPropertyName()
Returns the name of this property.
 o isDefault()
Is the value of this property is a default value.
 o isSoftlyInherited()
Returns true if this property is "softly" inherited e.g.
 o toString()
Returns a string representation of the object.

Variables

 o value
 protected int value
an index in a array

See Also:
FONTWEIGHT

Constructors

 o CssFontWeight
 public CssFontWeight()
Create a new FontWeight with the default value.

 o CssFontWeight
 public CssFontWeight(CssExpression expr) throws InvalidParamException
Creates a new CssFontWeight with an expression.

Parameters:
expr - the expression
Throws: InvalidParamException
values are incorrect

Methods

 o get
 public Object get()
Returns the current value.

Overrides:
get in class CssProperty
 o isSoftlyInherited
 public boolean isSoftlyInherited()
Returns true if this property is "softly" inherited e.g. his value equals inherit

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

Overrides:
toString in class CssProperty
 o getPropertyName
 public String getPropertyName()
Returns the name of this property.

Overrides:
getPropertyName in class CssProperty
 o addToStyle
 public void addToStyle(CssStyle style)
Add this property to the CssStyle

Parameters:
style - The CssStyle
Overrides:
addToStyle in class CssProperty
 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 equals
 public boolean equals(CssProperty property)
Compares two properties for equality.

Parameters:
value - The other property.
Overrides:
equals in class CssProperty
 o isDefault
 public boolean isDefault()
Is the value of this property is a default value. It is used by all macro for the function print

Overrides:
isDefault in class CssProperty

All Packages  Class Hierarchy  This Package  Previous  Next  Index