org.foray.font.config
Class RegisteredFontFamily

java.lang.Object
  extended by org.foray.font.config.RegisteredFontFamily

public class RegisteredFontFamily
extends Object

Class representing a font family that has been registered for use with FOray. This currently is just a collection of the fonts that are in this family. The actual font characteristics used in font resolution should be stored in the RegisteredFont itself.


Constructor Summary
RegisteredFontFamily(FontServer4a fontServer, String name)
          Constructor.
 
Method Summary
static float convertPercent(String inputString, float defaultValue)
          Converts a String representing a percentage to its decimal value.
 RegisteredFontDesc findRegisteredFontDesc(org.axsl.font.Font.Style style, org.axsl.font.Font.Weight weight, org.axsl.font.Font.Variant variant, org.axsl.font.Font.Stretch stretch, boolean freeStandingFonts, boolean systemFonts)
          This method encapsulates the "per-descriptor matching rules" described in the CSS 2 documentation at Section 15.5.
 List<RegisteredFontDesc> getFontDescriptions()
          Returns the list of RegisteredFontDesc instances that are associated with this family.
 FontServer4a getFontServer()
          Return the related font server.
 String getName()
          Returns the name of this font family.
 RegisteredFontDesc nextBolderFont(RegisteredFontDesc baseline)
          Returns the next bolder font.
 RegisteredFontDesc nextLighterFont(RegisteredFontDesc baseline)
          Returns the next lighter font.
 void registerFontDesc(RegisteredFont registeredFont, org.axsl.ps.Encoding encoding, org.axsl.font.Font.Style style, org.axsl.font.Font.Weight weight, org.axsl.font.Font.Variant variant, org.axsl.font.Font.Stretch stretch, float simulatedSmallCaps, float simulatedOblique, float simulatedBackslant, float[] simulatedStretch)
          Maps a font-description to a RegisteredFont for this font-family.
 void registerFontDesc(RegisteredFont registeredFont, org.axsl.ps.Encoding encoding, String style, String weight, String variant, String stretch, String simulatedSmallCaps, String simulatedOblique, String simulatedBackslant, String[] simulatedStretch)
          Maps a font-description to a RegisteredFont for this font-family.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegisteredFontFamily

public RegisteredFontFamily(FontServer4a fontServer,
                            String name)
Constructor.

Parameters:
fontServer - The parent font server.
name - The name of this font family (e.g. "Courier").
Method Detail

getName

public String getName()
Returns the name of this font family.

Returns:
The name of this font family (e.g. "Courier").

registerFontDesc

public void registerFontDesc(RegisteredFont registeredFont,
                             org.axsl.ps.Encoding encoding,
                             String style,
                             String weight,
                             String variant,
                             String stretch,
                             String simulatedSmallCaps,
                             String simulatedOblique,
                             String simulatedBackslant,
                             String[] simulatedStretch)
                      throws org.axsl.font.FontException
Maps a font-description to a RegisteredFont for this font-family.

Parameters:
registeredFont - the RegisteredFont that should be supplied when a font matching this description is requested.
encoding - The encoding for the font description.
style - The style (normal, italic, etc.).
weight - The weight (normal, bold, 100, etc.).
variant - The variant (normal, small-caps).
stretch - The stretch (normal, condensed, etc.).
simulatedSmallCaps - A percentage.
simulatedOblique - A number of degrees.
simulatedBackslant - A number of degrees.
simulatedStretch - A percentage.
Throws:
org.axsl.font.FontException - For error in registration.

registerFontDesc

public void registerFontDesc(RegisteredFont registeredFont,
                             org.axsl.ps.Encoding encoding,
                             org.axsl.font.Font.Style style,
                             org.axsl.font.Font.Weight weight,
                             org.axsl.font.Font.Variant variant,
                             org.axsl.font.Font.Stretch stretch,
                             float simulatedSmallCaps,
                             float simulatedOblique,
                             float simulatedBackslant,
                             float[] simulatedStretch)
                      throws org.axsl.font.FontException
Maps a font-description to a RegisteredFont for this font-family.

Parameters:
registeredFont - the RegisteredFont that should be supplied when a font matching this description is requested.
encoding - The encoding for the font description.
style - The style (normal, italic, etc.).
weight - The weight (normal, bold, 100, etc.).
variant - The variant (normal, small-caps).
stretch - The stretch (normal, condensed, etc.).
simulatedSmallCaps - A percentage.
simulatedOblique - A number of degrees.
simulatedBackslant - A number of degrees.
simulatedStretch - A percentage.
Throws:
org.axsl.font.FontException - For error in registration.

findRegisteredFontDesc

public RegisteredFontDesc findRegisteredFontDesc(org.axsl.font.Font.Style style,
                                                 org.axsl.font.Font.Weight weight,
                                                 org.axsl.font.Font.Variant variant,
                                                 org.axsl.font.Font.Stretch stretch,
                                                 boolean freeStandingFonts,
                                                 boolean systemFonts)
This method encapsulates the "per-descriptor matching rules" described in the CSS 2 documentation at Section 15.5.

Parameters:
style - The font-style constant requested.
weight - The font-weight constant requested.
variant - The font-variant constant requested.
stretch - The font-stretch constant requested.
freeStandingFonts - Indicates whether free-standing fonts can be considered in this selection.
systemFonts - Indicates whether system fonts can be considered in this selection.
Returns:
The first matching RegisteredFontDesc found for this font-family, or null if none match.

getFontServer

public FontServer4a getFontServer()
Return the related font server.

Returns:
The font server.

nextBolderFont

public RegisteredFontDesc nextBolderFont(RegisteredFontDesc baseline)
Returns the next bolder font.

Parameters:
baseline - The baseline font for which a bolder version should be found.
Returns:
The next bolder font, or the baseline font if no bolder font exists.

nextLighterFont

public RegisteredFontDesc nextLighterFont(RegisteredFontDesc baseline)
Returns the next lighter font.

Parameters:
baseline - The baseline font for which a lighter version should be found.
Returns:
The next lighter font, or the baseline font if no lighter font exists.

convertPercent

public static float convertPercent(String inputString,
                                   float defaultValue)
Converts a String representing a percentage to its decimal value.

Parameters:
inputString - A String representing a percentage. It must end with the "%" symbol.
defaultValue - The value to be returned if the parse is unsuccessful.
Returns:
The converted percentage, or defaultValue if the input is not valid. An input value of "98%" will return 98.0.

getFontDescriptions

public List<RegisteredFontDesc> getFontDescriptions()
Returns the list of RegisteredFontDesc instances that are associated with this family.

Returns:
The font descriptions.


Copyright © 2017. All rights reserved.