SourceForge.net Logo
aXSL API 0.2

org.axsl.font
Class FontUtility

java.lang.Object
  extended by org.axsl.font.FontUtility

public final class FontUtility
extends java.lang.Object

Class containing font-related utility methods.

References to CSS2 are to the Cascading Style Sheet standard, version 2.0, found at:

http://www.w3.org/TR/REC-CSS2/

References to XSL-FO refer to the eXtensible Stylesheet Language Formatting Objects standard, version 1.0, found at:

http://www.w3.org/TR/2001/REC-xsl-20011015/


Field Summary
static java.lang.String[] EMPTY_STRING_ARRAY
          An array of Strings with zero elements, useful especially as a return value.
static java.lang.String INPUT_100
          String value for input "100".
static java.lang.String INPUT_200
          String value for input "200".
static java.lang.String INPUT_300
          String value for input "300".
static java.lang.String INPUT_400
          String value for input "400".
static java.lang.String INPUT_500
          String value for input "500".
static java.lang.String INPUT_600
          String value for input "600".
static java.lang.String INPUT_700
          String value for input "700".
static java.lang.String INPUT_800
          String value for input "800".
static java.lang.String INPUT_900
          String value for input "900".
static java.lang.String INPUT_BACKSLANT
          String value for input "backslant".
static java.lang.String INPUT_BOLD
          String value for input "bold".
static java.lang.String INPUT_CONDENSED
          String value for input "condensed".
static java.lang.String INPUT_EXPANDED
          String value for input "expanded".
static java.lang.String INPUT_EXTRA_CONDENSED
          String value for input "extra-condensed".
static java.lang.String INPUT_EXTRA_EXPANDED
          String value for input "extra-expanded".
static java.lang.String INPUT_INVALID
          String value for invalid input.
static java.lang.String INPUT_ITALIC
          String value for input "italic".
static java.lang.String INPUT_NORMAL
          String value for input "normal".
static java.lang.String INPUT_OBLIQUE
          String value for input "oblique".
static java.lang.String INPUT_SEMI_CONDENSED
          String value for input "semi-condensed".
static java.lang.String INPUT_SEMI_EXPANDED
          String value for input "semi-expanded".
static java.lang.String INPUT_SMALL_CAPS
          String value for input "small-caps".
static java.lang.String INPUT_ULTRA_CONDENSED
          String value for input "ultra-condensed".
static java.lang.String INPUT_ULTRA_EXPANDED
          String value for input "ultra-expanded".
static java.lang.String[] VALID_STRETCH_STRINGS
          Array containing the valid font stretch input values, sorted alphabetically so that they can be binary searched.
static Font.Stretch[] VALID_STRETCH_VALUES
          Array containing the parsed font stretch values that correspond to the Strings in VALID_STRETCH_STRINGS.
static java.lang.String[] VALID_WEIGHT_STRINGS
          Array containing the valid font weight input values, sorted alphabetically so that they can be binary searched.
static Font.Weight[] VALID_WEIGHT_VALUES
          Array containing the parsed font weight values that correspond to the Strings in VALID_WEIGHT_STRINGS.
 
Method Summary
static java.lang.String[] cssFontFamily(java.lang.String input)
          Converts a CSS2-style String input for font-family into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).
static Font.Stretch cssFontStretch(java.lang.String input, boolean lowerCaseOnly)
          Converts a CSS2-style String input for font-stretch into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).
static Font.Style cssFontStyle(java.lang.String input, boolean lowerCaseOnly)
          Converts a CSS2-style String input for font-style into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).
static Font.Variant cssFontVariant(java.lang.String input, boolean lowerCaseOnly)
          Converts a CSS2-style String input for font-variant into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).
static Font.Weight cssFontWeight(java.lang.String input, boolean lowerCaseOnly)
          Converts a CSS2-style String input for font-weight into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).
static java.lang.String[] foFontFamily(java.lang.String input)
          Same as cssFontFamily(String), except input is an XSL-FO-style String.
static Font.SelectionStrategy foFontSelectionStrategy(java.lang.String input, boolean lowerCaseOnly)
          Converts XSL-FO String input for font-selection-strategy into a value expected by FontConsumer.selectFontXsl(Font.SelectionStrategy, String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).
static Font.Stretch foFontStretch(java.lang.String input, boolean lowerCaseOnly)
          Same as cssFontStretch(String, boolean), except input is an XSL-FO-style String.
static Font.Style foFontStyle(java.lang.String input, boolean lowerCaseOnly)
          Same as cssFontStyle(String, boolean), except input is an XSL-FO-style String.
static Font.Variant foFontVariant(java.lang.String input, boolean lowerCaseOnly)
          Same as cssFontVariant(String, boolean), except input is an XSL-FO-style String.
static Font.Weight foFontWeight(java.lang.String input, boolean lowerCaseOnly)
          Same as cssFontWeight(String, boolean), except input is an XSL-FO-style String.
static java.lang.String fontStretchName(Font.Stretch fontStretch)
          Returns a String description for a numeric font-weight value, suitable for using in user messages.
static java.lang.String fontStyleName(Font.Style fontStyle)
          Returns a String description for a font-style value, suitable for using in user messages.
static java.lang.String fontVariantName(Font.Variant fontVariant)
          Returns a String description for a numeric font-weight value, suitable for using in user messages.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INPUT_INVALID

public static final java.lang.String INPUT_INVALID
String value for invalid input.

See Also:
Constant Field Values

INPUT_NORMAL

public static final java.lang.String INPUT_NORMAL
String value for input "normal".

See Also:
Constant Field Values

INPUT_ITALIC

public static final java.lang.String INPUT_ITALIC
String value for input "italic".

See Also:
Constant Field Values

INPUT_OBLIQUE

public static final java.lang.String INPUT_OBLIQUE
String value for input "oblique".

See Also:
Constant Field Values

INPUT_BACKSLANT

public static final java.lang.String INPUT_BACKSLANT
String value for input "backslant".

See Also:
Constant Field Values

INPUT_SMALL_CAPS

public static final java.lang.String INPUT_SMALL_CAPS
String value for input "small-caps".

See Also:
Constant Field Values

INPUT_ULTRA_CONDENSED

public static final java.lang.String INPUT_ULTRA_CONDENSED
String value for input "ultra-condensed".

See Also:
Constant Field Values

INPUT_EXTRA_CONDENSED

public static final java.lang.String INPUT_EXTRA_CONDENSED
String value for input "extra-condensed".

See Also:
Constant Field Values

INPUT_CONDENSED

public static final java.lang.String INPUT_CONDENSED
String value for input "condensed".

See Also:
Constant Field Values

INPUT_SEMI_CONDENSED

public static final java.lang.String INPUT_SEMI_CONDENSED
String value for input "semi-condensed".

See Also:
Constant Field Values

INPUT_SEMI_EXPANDED

public static final java.lang.String INPUT_SEMI_EXPANDED
String value for input "semi-expanded".

See Also:
Constant Field Values

INPUT_EXPANDED

public static final java.lang.String INPUT_EXPANDED
String value for input "expanded".

See Also:
Constant Field Values

INPUT_EXTRA_EXPANDED

public static final java.lang.String INPUT_EXTRA_EXPANDED
String value for input "extra-expanded".

See Also:
Constant Field Values

INPUT_ULTRA_EXPANDED

public static final java.lang.String INPUT_ULTRA_EXPANDED
String value for input "ultra-expanded".

See Also:
Constant Field Values

INPUT_100

public static final java.lang.String INPUT_100
String value for input "100".

See Also:
Constant Field Values

INPUT_200

public static final java.lang.String INPUT_200
String value for input "200".

See Also:
Constant Field Values

INPUT_300

public static final java.lang.String INPUT_300
String value for input "300".

See Also:
Constant Field Values

INPUT_400

public static final java.lang.String INPUT_400
String value for input "400".

See Also:
Constant Field Values

INPUT_500

public static final java.lang.String INPUT_500
String value for input "500".

See Also:
Constant Field Values

INPUT_600

public static final java.lang.String INPUT_600
String value for input "600".

See Also:
Constant Field Values

INPUT_700

public static final java.lang.String INPUT_700
String value for input "700".

See Also:
Constant Field Values

INPUT_800

public static final java.lang.String INPUT_800
String value for input "800".

See Also:
Constant Field Values

INPUT_900

public static final java.lang.String INPUT_900
String value for input "900".

See Also:
Constant Field Values

INPUT_BOLD

public static final java.lang.String INPUT_BOLD
String value for input "bold".

See Also:
Constant Field Values

EMPTY_STRING_ARRAY

public static final java.lang.String[] EMPTY_STRING_ARRAY
An array of Strings with zero elements, useful especially as a return value.


VALID_WEIGHT_STRINGS

public static final java.lang.String[] VALID_WEIGHT_STRINGS
Array containing the valid font weight input values, sorted alphabetically so that they can be binary searched. Indexes correspond to those in VALID_WEIGHT_VALUES.


VALID_WEIGHT_VALUES

public static final Font.Weight[] VALID_WEIGHT_VALUES
Array containing the parsed font weight values that correspond to the Strings in VALID_WEIGHT_STRINGS.


VALID_STRETCH_STRINGS

public static final java.lang.String[] VALID_STRETCH_STRINGS
Array containing the valid font stretch input values, sorted alphabetically so that they can be binary searched. Indexes correspond to those in VALID_STRETCH_VALUES.


VALID_STRETCH_VALUES

public static final Font.Stretch[] VALID_STRETCH_VALUES
Array containing the parsed font stretch values that correspond to the Strings in VALID_STRETCH_STRINGS.

Method Detail

foFontSelectionStrategy

public static Font.SelectionStrategy foFontSelectionStrategy(java.lang.String input,
                                                             boolean lowerCaseOnly)
Converts XSL-FO String input for font-selection-strategy into a value expected by FontConsumer.selectFontXsl(Font.SelectionStrategy, String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).

Parameters:
input - The XSL-FO-style String to be converted.
lowerCaseOnly - Set to true to insist that all input values be lowercase.
Returns:
The parsed font-selection-strategy value, one of: Font.SelectionStrategy.CHARACTER_BY_CHARACTER or Font.SelectionStrategy.AUTO. If the input is invalid, returns null.

cssFontStyle

public static Font.Style cssFontStyle(java.lang.String input,
                                      boolean lowerCaseOnly)
Converts a CSS2-style String input for font-style into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).

Parameters:
input - The CSS2-style String to be converted.
lowerCaseOnly - Set to true to insist that all input values be lowercase. There is some ambiguity about whether CSS is case-sensitive or not. If it is, all input should be lower case.
Returns:
For valid input, one of: Font.Style.NORMAL, Font.Style.ITALIC, Font.Style.OBLIQUE, or Font.Style.BACKSLANT. For invalid input, return null.
See Also:
FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int)

foFontStyle

public static Font.Style foFontStyle(java.lang.String input,
                                     boolean lowerCaseOnly)
Same as cssFontStyle(String, boolean), except input is an XSL-FO-style String.

Parameters:
input - The XSL-FO-style String to be converted.
lowerCaseOnly - Set to true to insist that all input values be lowercase. There is some ambiguity about whether XSL-FO is case-sensitive or not. If it is, all input should be lower case.
Returns:
For valid input, one of: Font.Style.NORMAL, Font.Style.ITALIC, Font.Style.OBLIQUE, or Font.Style.BACKSLANT. For invalid input, returns null.
See Also:
cssFontStyle(String, boolean)

cssFontWeight

public static Font.Weight cssFontWeight(java.lang.String input,
                                        boolean lowerCaseOnly)
Converts a CSS2-style String input for font-weight into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).

Parameters:
input - The CSS2-style String to be converted.
lowerCaseOnly - Set to true to insist that all input values be lowercase. There is some ambiguity about whether CSS is case-sensitive or not. If it is, all input should be lower case.
Returns:
For valid input, one of Font.Weight.EXTREMELY_LIGHT, Font.Weight.VERY_LIGHT, Font.Weight.LIGHT, Font.Weight.NORMAL, Font.Weight.DARK, Font.Weight.SEMI_BOLD, Font.Weight.BOLD, Font.Weight.EXTRA_BOLD, or Font.Weight.BLACK. For invalid input, return null.
See Also:
FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int)

foFontWeight

public static Font.Weight foFontWeight(java.lang.String input,
                                       boolean lowerCaseOnly)
Same as cssFontWeight(String, boolean), except input is an XSL-FO-style String.

Parameters:
input - The XSL-FO-style String to be converted.
lowerCaseOnly - Set to true to insist that all input values be lowercase. There is some ambiguity about whether XSL-FO is case-sensitive or not. If it is, all input should be lower case.
Returns:
For valid input, one of Font.Weight.EXTREMELY_LIGHT, Font.Weight.VERY_LIGHT, Font.Weight.LIGHT, Font.Weight.NORMAL, Font.Weight.DARK, Font.Weight.SEMI_BOLD, Font.Weight.BOLD, Font.Weight.EXTRA_BOLD, or Font.Weight.BLACK. For invalid input, return null.
See Also:
cssFontWeight(String, boolean)

cssFontVariant

public static Font.Variant cssFontVariant(java.lang.String input,
                                          boolean lowerCaseOnly)
Converts a CSS2-style String input for font-variant into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).

Parameters:
input - The CSS2-style String to be converted.
lowerCaseOnly - Set to true to insist that all input values be lowercase. There is some ambiguity about whether CSS is case-sensitive or not. If it is, all input should be lower case.
Returns:
For valid input, one of: Font.Variant.NORMAL or Font.Variant.SMALL_CAPS. For invalid input, return null.
See Also:
FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int)

foFontVariant

public static Font.Variant foFontVariant(java.lang.String input,
                                         boolean lowerCaseOnly)
Same as cssFontVariant(String, boolean), except input is an XSL-FO-style String.

Parameters:
input - The XSL-FO-style String to be converted.
lowerCaseOnly - Set to true to insist that all input values be lowercase. There is some ambiguity about whether XSL-FO is case-sensitive or not. If it is, all input should be lower case.
Returns:
For valid input, one of: Font.Variant.NORMAL or Font.Variant.SMALL_CAPS. For invalid input, return null.
See Also:
cssFontVariant(String, boolean)

cssFontStretch

public static Font.Stretch cssFontStretch(java.lang.String input,
                                          boolean lowerCaseOnly)
Converts a CSS2-style String input for font-stretch into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).

Parameters:
input - The CSS2-style String to be converted.
lowerCaseOnly - Set to true to insist that all input values be lowercase. There is some ambiguity about whether CSS is case-sensitive or not. If it is, all input should be lower case.
Returns:
For valid input, one of Font.Stretch.ULTRA_CONDENSED, Font.Stretch.EXTRA_CONDENSED, Font.Stretch.CONDENSED, Font.Stretch.SEMI_CONDENSED, Font.Stretch.NORMAL, Font.Stretch.SEMI_EXPANDED, Font.Stretch.EXPANDED, Font.Stretch.EXTRA_EXPANDED, Font.Stretch.ULTRA_EXPANDED. For invalid input, return null.
See Also:
FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int)

foFontStretch

public static Font.Stretch foFontStretch(java.lang.String input,
                                         boolean lowerCaseOnly)
Same as cssFontStretch(String, boolean), except input is an XSL-FO-style String.

Parameters:
input - The XSL-FO-style String to be converted.
lowerCaseOnly - Set to true to insist that all input values be lowercase. There is some ambiguity about whether XSL-FO is case-sensitive or not. If it is, all input should be lower case.
Returns:
For valid input, one of Font.Stretch.ULTRA_CONDENSED, Font.Stretch.EXTRA_CONDENSED, Font.Stretch.CONDENSED, Font.Stretch.SEMI_CONDENSED, Font.Stretch.NORMAL, Font.Stretch.SEMI_EXPANDED, Font.Stretch.EXPANDED, Font.Stretch.EXTRA_EXPANDED, Font.Stretch.ULTRA_EXPANDED. For invalid input, return null.
See Also:
cssFontStretch(String, boolean)

cssFontFamily

public static java.lang.String[] cssFontFamily(java.lang.String input)
Converts a CSS2-style String input for font-family into a value expected by FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int).

Parameters:
input - The CSS2-style font-family String to be converted. This is a comma-delimited String containing one or more potential font-family items to be selected. Consult the CSS2 standard for details.
Returns:
A String array with the parsed font-family items in it. This method never returns "null", but may return an array with zero elements for invalid input.
See Also:
FontConsumer.selectFontCss(String[], Font.Style, Font.Weight, Font.Variant, Font.Stretch, int, int)

foFontFamily

public static java.lang.String[] foFontFamily(java.lang.String input)
Same as cssFontFamily(String), except input is an XSL-FO-style String.

Parameters:
input - The XSL-FO font-family String to be converted. This is a comma-delimited String containing one or more potential font-family items to be selected. Consult the XSL-FO standard for details.
Returns:
A String array with the parsed font-family items in it. This method never returns "null", but may return an array with zero elements for invalid input.
See Also:
cssFontFamily(String)

fontStyleName

public static java.lang.String fontStyleName(Font.Style fontStyle)
Returns a String description for a font-style value, suitable for using in user messages.

Parameters:
fontStyle - The Font.Style instance for which
Returns:
A String description for fontStyle.

fontVariantName

public static java.lang.String fontVariantName(Font.Variant fontVariant)
Returns a String description for a numeric font-weight value, suitable for using in user messages.

Parameters:
fontVariant - One of Font.Variant.NORMAL or Font.Variant.SMALL_CAPS.
Returns:
A String description for fontWeight.

fontStretchName

public static java.lang.String fontStretchName(Font.Stretch fontStretch)
Returns a String description for a numeric font-weight value, suitable for using in user messages.

Parameters:
fontStretch - One of Font.Stretch.ULTRA_CONDENSED, Font.Stretch.EXTRA_CONDENSED, Font.Stretch.CONDENSED, Font.Stretch.SEMI_CONDENSED, Font.Stretch.NORMAL, Font.Stretch.SEMI_EXPANDED, Font.Stretch.EXPANDED, Font.Stretch.EXTRA_EXPANDED, or Font.Stretch.ULTRA_EXPANDED.
Returns:
A String description for fontStretch.

SourceForge.net Logo
aXSL API 0.2

This documentation was created August 8 2007 by The aXSL Group and may be freely copied. See license for details.