org.foray.font.config
Class RegisteredFontDesc

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

public class RegisteredFontDesc
extends Object

RegisteredFontDesc encapsulates the set of characteristics about how a font is used. An RFD instance has one RegisteredFontFamily parent, which provides the font-family context in which it can be selected, and one RegisteredFont parent, which provides the link to the actual font. It is analogous to the font-description element in the font configuration, and is typically created directly as that is parsed.

An RFD instance is primarily in font resolution, where its characteristics are comapared, in the context of the parent RegisteredFontFamily font family, to those requested by the font selection process.


Field Summary
static byte QTY_SIMULATED_STRETCH
          Constant indicating the number of simulated "stretch" components.
static byte SIMULATE_CONDENSED_INDEX
          Constant indicating the index for the "condensed" simulated stretch bucket.
static byte SIMULATE_EXPANDED_INDEX
          Constant indicating the index for the "expanded" simulated stretch bucket.
static byte SIMULATE_EXTRA_CONDENSED_INDEX
          Constant indicating the index for the "extra-condensed" simulated stretch bucket.
static byte SIMULATE_EXTRA_EXPANDED_INDEX
          Constant indicating the index for the "extra-expanded" simulated stretch bucket.
static byte SIMULATE_SEMI_CONDENSED_INDEX
          Constant indicating the index for the "semi-condensed" simulated stretch bucket.
static byte SIMULATE_SEMI_EXPANDED_INDEX
          Constant indicating the index for the "semi-expanded" simulated stretch bucket.
static byte SIMULATE_ULTRA_CONDENSED_INDEX
          Constant indicating the index for the "ultra-condensed" simulated stretch bucket.
static byte SIMULATE_ULTRA_EXPANDED_INDEX
          Constant indicating the index for the "ultra-expanded" simulated stretch bucket.
 
Constructor Summary
RegisteredFontDesc(RegisteredFont rf, RegisteredFontFamily rff, org.axsl.ps.Encoding encoding, org.axsl.font.Font.Style fontStyle, org.axsl.font.Font.Weight fontWeight, org.axsl.font.Font.Variant fontVariant, org.axsl.font.Font.Stretch fontStretch)
          Construct a FontDescription instance.
 
Method Summary
 boolean equivalent(RegisteredFontDesc otherDesc)
          Determine whether two RegisteredFontDesc instances have the same set of characteristics (font-weight, font-style, etc).
 boolean equivalentExceptWeight(RegisteredFontDesc otherDesc)
          Determine whether two RegisteredFontDesc instances have the same set of characteristics (font-family, font-style, etc), but without regard to font-weight.
 boolean generalTypeMatches(boolean freeStandingFonts, boolean systemFonts)
          Determines whether this registered font can return a Font instance that matches the general type requested.
 org.axsl.ps.Encoding getEncoding()
          Return the prescribed encoding for this description.
 org.axsl.font.Font.Stretch getFontStretch()
          Return the font-stretch for this registered description.
 org.axsl.font.Font.Style getFontStyle()
          Returns the font style.
 org.axsl.font.Font.Variant getFontVariant()
          Return the font-variant for this registered description.
 org.axsl.font.Font.Weight getFontWeight()
          Returns the font weight.
 RegisteredFont getRegisteredFont()
          Returns the related registered font instance.
 RegisteredFontFamily getRegisteredFontFamily()
          Returns the related registered font family instance.
 float getSimulateBackslant()
          Returns the simulated backslant angle.
 float getSimulateCondensed()
          Returns the simulated "condensed" percentage.
 float getSimulateExpanded()
          Returns the simulated "expanded" percentage.
 float getSimulateExtraCondensed()
          Returns the simulated "extra-condensed" percentage.
 float getSimulateExtraExpanded()
          Returns the simulated "extra-expanded" percentage.
 float getSimulateOblique()
          Returns the simulated oblique angle.
 float getSimulateSemiCondensed()
          Returns the simulated "semi-condensed" percentage.
 float getSimulateSemiExpanded()
          Returns the simulated "semi-expanded" percentage.
 float getSimulateSmallCaps()
          Returns the simulated small-caps percentage.
 float getSimulateStretch(int index)
          Get the simulated font-stretch value by array position.
 float getSimulateUltraCondensed()
          Returns the simulated "ultra-condensed" percentage.
 float getSimulateUltraExpanded()
          Returns the simulated "ultra-expanded" percentage.
 boolean matchIgnoreWeight(RegisteredFontFamily family, boolean considerSimulated, org.axsl.font.Font.Style style, org.axsl.font.Font.Variant variant, org.axsl.font.Font.Stretch stretch, boolean freeStandingFonts, boolean systemFonts)
          Indicates whether this font description matches a given set of criteria, withour regard to the font-weight.
 boolean matchPerfect(RegisteredFontFamily family, boolean considerSimulated, 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)
          Indicates whether this font description perfectly matches a given set of criteria.
 RegisteredFontDesc nextBolderFont()
          Returns the next bolder font in the font-family than this font.
 RegisteredFontDesc nextLighterFont()
          Returns the next lighter font in the font-family than this font.
 void setSimulateBackslant(float simulateBackSlant)
          Sets the simulated backslant angle.
 void setSimulateCondensed(float value)
          Sets the simulated "condensed" percentage.
 void setSimulateExpanded(float value)
          Sets the simulated "expanded" percentage.
 void setSimulateExtraCondensed(float value)
          Sets the simulated "extra-condensed" percentage.
 void setSimulateExtraExpanded(float value)
          Sets the simulated "extra-expanded" percentage.
 void setSimulateOblique(float simulateOblique)
          Sets the simulated oblique angle.
 void setSimulateSemiCondensed(float value)
          Sets the simulated "semi-condensed" percentage.
 void setSimulateSemiExpanded(float value)
          Sets the simulated "semi-expanded" percentage.
 void setSimulateSmallCaps(float simulateSmallCaps)
          Sets the simulated small-caps for this registered description.
 void setSimulateStretch(float[] newStretchArray)
          Sets the simulated stretch array.
 void setSimulateStretch(int index, float value)
          Set the simulated font-stretch value by array position.
 void setSimulateUltraCondensed(float value)
          Sets the simulated "ultra-condensed" percentage.
 void setSimulateUltraExpanded(float value)
          Sets the simulated "ultra-expanded" percentage.
 boolean stretchMatches(org.axsl.font.Font.Stretch desiredStretch, boolean considerSimulated)
          Indicates whether this font description matches a given stretch.
 boolean styleMatches(org.axsl.font.Font.Style inputDesiredStyle, boolean considerSimulated)
          Indicates whether this font description matches a given style.
 boolean variantMatches(org.axsl.font.Font.Variant desiredVariant, boolean considerSimulated)
          Indicates whether this font description matches a given variant.
 boolean weightMatches(org.axsl.font.Font.Weight desiredWeight)
          Indicates whether this font description matches a given weight.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

QTY_SIMULATED_STRETCH

public static final byte QTY_SIMULATED_STRETCH
Constant indicating the number of simulated "stretch" components.

See Also:
Constant Field Values

SIMULATE_ULTRA_CONDENSED_INDEX

public static final byte SIMULATE_ULTRA_CONDENSED_INDEX
Constant indicating the index for the "ultra-condensed" simulated stretch bucket.

See Also:
Constant Field Values

SIMULATE_EXTRA_CONDENSED_INDEX

public static final byte SIMULATE_EXTRA_CONDENSED_INDEX
Constant indicating the index for the "extra-condensed" simulated stretch bucket.

See Also:
Constant Field Values

SIMULATE_CONDENSED_INDEX

public static final byte SIMULATE_CONDENSED_INDEX
Constant indicating the index for the "condensed" simulated stretch bucket.

See Also:
Constant Field Values

SIMULATE_SEMI_CONDENSED_INDEX

public static final byte SIMULATE_SEMI_CONDENSED_INDEX
Constant indicating the index for the "semi-condensed" simulated stretch bucket.

See Also:
Constant Field Values

SIMULATE_SEMI_EXPANDED_INDEX

public static final byte SIMULATE_SEMI_EXPANDED_INDEX
Constant indicating the index for the "semi-expanded" simulated stretch bucket.

See Also:
Constant Field Values

SIMULATE_EXPANDED_INDEX

public static final byte SIMULATE_EXPANDED_INDEX
Constant indicating the index for the "expanded" simulated stretch bucket.

See Also:
Constant Field Values

SIMULATE_EXTRA_EXPANDED_INDEX

public static final byte SIMULATE_EXTRA_EXPANDED_INDEX
Constant indicating the index for the "extra-expanded" simulated stretch bucket.

See Also:
Constant Field Values

SIMULATE_ULTRA_EXPANDED_INDEX

public static final byte SIMULATE_ULTRA_EXPANDED_INDEX
Constant indicating the index for the "ultra-expanded" simulated stretch bucket.

See Also:
Constant Field Values
Constructor Detail

RegisteredFontDesc

public RegisteredFontDesc(RegisteredFont rf,
                          RegisteredFontFamily rff,
                          org.axsl.ps.Encoding encoding,
                          org.axsl.font.Font.Style fontStyle,
                          org.axsl.font.Font.Weight fontWeight,
                          org.axsl.font.Font.Variant fontVariant,
                          org.axsl.font.Font.Stretch fontStretch)
Construct a FontDescription instance.

Parameters:
rf - The parent registered font.
rff - The parent registered font family.
encoding - The specified encoding.
fontStyle - The font style (normal, italic, etc.)
fontWeight - The font weight(100, 200, bold, etc.)
fontVariant - The font variant (normal, small-caps)
fontStretch - The font stretch (normal, condensed, etc.)
Method Detail

getFontStyle

public org.axsl.font.Font.Style getFontStyle()
Returns the font style.

Returns:
The font style.

getFontWeight

public org.axsl.font.Font.Weight getFontWeight()
Returns the font weight.

Returns:
The font weight.

getFontVariant

public org.axsl.font.Font.Variant getFontVariant()
Return the font-variant for this registered description.

Returns:
The font-variant value.

getFontStretch

public org.axsl.font.Font.Stretch getFontStretch()
Return the font-stretch for this registered description.

Returns:
The font-stretch value.

setSimulateSmallCaps

public void setSimulateSmallCaps(float simulateSmallCaps)
Sets the simulated small-caps for this registered description.

Parameters:
simulateSmallCaps - The percentage that should be applied to simulated small-caps items for this font. A value of "80" will result in small-caps items that are 80% of the font-size of caps.

getSimulateSmallCaps

public float getSimulateSmallCaps()
Returns the simulated small-caps percentage.

Returns:
The simulated small-caps percentage.

setSimulateOblique

public void setSimulateOblique(float simulateOblique)
Sets the simulated oblique angle.

Parameters:
simulateOblique - The new simulated oblique angle.

getSimulateOblique

public float getSimulateOblique()
Returns the simulated oblique angle.

Returns:
The simulated oblique angle.

setSimulateBackslant

public void setSimulateBackslant(float simulateBackSlant)
Sets the simulated backslant angle.

Parameters:
simulateBackSlant - The new simulated backslant angle.

getSimulateBackslant

public float getSimulateBackslant()
Returns the simulated backslant angle.

Returns:
The simulated backslant angle.

setSimulateStretch

public void setSimulateStretch(int index,
                               float value)
Set the simulated font-stretch value by array position.

Parameters:
index - Index into the internal array.
value - The percentage value to which the array element should be set.

getSimulateStretch

public float getSimulateStretch(int index)
Get the simulated font-stretch value by array position.

Parameters:
index - Index into the internal array.
Returns:
The percentage value of the stretch for the index provided.

setSimulateStretch

public void setSimulateStretch(float[] newStretchArray)
Sets the simulated stretch array.

Parameters:
newStretchArray - The new simulated stretch array.

setSimulateUltraCondensed

public void setSimulateUltraCondensed(float value)
Sets the simulated "ultra-condensed" percentage.

Parameters:
value - The new simulated "ultra-condensed" percentage.

getSimulateUltraCondensed

public float getSimulateUltraCondensed()
Returns the simulated "ultra-condensed" percentage.

Returns:
The simulated "ultra-condensed" percentage.

setSimulateExtraCondensed

public void setSimulateExtraCondensed(float value)
Sets the simulated "extra-condensed" percentage.

Parameters:
value - The new simulated "extra-condensed" percentage.

getSimulateExtraCondensed

public float getSimulateExtraCondensed()
Returns the simulated "extra-condensed" percentage.

Returns:
The simulated "extra-condensed" percentage.

setSimulateCondensed

public void setSimulateCondensed(float value)
Sets the simulated "condensed" percentage.

Parameters:
value - The new simulated "condensed" percentage.

getSimulateCondensed

public float getSimulateCondensed()
Returns the simulated "condensed" percentage.

Returns:
The simulated "condensed" percentage.

setSimulateSemiCondensed

public void setSimulateSemiCondensed(float value)
Sets the simulated "semi-condensed" percentage.

Parameters:
value - The new simulated "semi-condensed" percentage.

getSimulateSemiCondensed

public float getSimulateSemiCondensed()
Returns the simulated "semi-condensed" percentage.

Returns:
The simulated "semi-condensed" percentage.

setSimulateSemiExpanded

public void setSimulateSemiExpanded(float value)
Sets the simulated "semi-expanded" percentage.

Parameters:
value - The new simulated "semi-expanded" percentage.

getSimulateSemiExpanded

public float getSimulateSemiExpanded()
Returns the simulated "semi-expanded" percentage.

Returns:
The simulated "semi-expanded" percentage.

setSimulateExpanded

public void setSimulateExpanded(float value)
Sets the simulated "expanded" percentage.

Parameters:
value - The new simulated "expanded" percentage.

getSimulateExpanded

public float getSimulateExpanded()
Returns the simulated "expanded" percentage.

Returns:
The simulated "expanded" percentage.

setSimulateExtraExpanded

public void setSimulateExtraExpanded(float value)
Sets the simulated "extra-expanded" percentage.

Parameters:
value - The new simulated "extra-expanded" percentage.

getSimulateExtraExpanded

public float getSimulateExtraExpanded()
Returns the simulated "extra-expanded" percentage.

Returns:
The simulated "extra-expanded" percentage.

setSimulateUltraExpanded

public void setSimulateUltraExpanded(float value)
Sets the simulated "ultra-expanded" percentage.

Parameters:
value - The new simulated "ultra-expanded" percentage.

getSimulateUltraExpanded

public float getSimulateUltraExpanded()
Returns the simulated "ultra-expanded" percentage.

Returns:
The simulated "ultra-expanded" percentage.

getRegisteredFont

public RegisteredFont getRegisteredFont()
Returns the related registered font instance.

Returns:
The related registered font instance.

getRegisteredFontFamily

public RegisteredFontFamily getRegisteredFontFamily()
Returns the related registered font family instance.

Returns:
The related registered font family instance.

getEncoding

public org.axsl.ps.Encoding getEncoding()
Return the prescribed encoding for this description.

Returns:
The prescribed encoding for this description.

nextBolderFont

public RegisteredFontDesc nextBolderFont()
Returns the next bolder font in the font-family than this font.

Returns:
The next bolder font in the font-family than this one.

nextLighterFont

public RegisteredFontDesc nextLighterFont()
Returns the next lighter font in the font-family than this font.

Returns:
The next lighter font in the font-family than this one.

equivalent

public boolean equivalent(RegisteredFontDesc otherDesc)
Determine whether two RegisteredFontDesc instances have the same set of characteristics (font-weight, font-style, etc). Note that, for purposes of this method, the encoding is not considered to be a characteristic.

Parameters:
otherDesc - A RegisteredFontDesc instance which should be compared to this one.
Returns:
True iff otherDesc has the same set of characteristics as this.

equivalentExceptWeight

public boolean equivalentExceptWeight(RegisteredFontDesc otherDesc)
Determine whether two RegisteredFontDesc instances have the same set of characteristics (font-family, font-style, etc), but without regard to font-weight. Note that, for purposes of this method, the encoding is not considered to be a characteristic.

Parameters:
otherDesc - A RegisteredFontDesc instance which should be compared to this one.
Returns:
True iff otherDesc has the same set of characteristics as this, but without regard to font-weight. In other words, if all other characteristics are equal, true will be returned, regardless of whether font-weight is equal or not.

styleMatches

public boolean styleMatches(org.axsl.font.Font.Style inputDesiredStyle,
                            boolean considerSimulated)
Indicates whether this font description matches a given style.

Parameters:
inputDesiredStyle - The style to match.
considerSimulated - Indicates whether simulated features should be considered in the test.
Returns:
True iff the style of this font description matches the criteria.

variantMatches

public boolean variantMatches(org.axsl.font.Font.Variant desiredVariant,
                              boolean considerSimulated)
Indicates whether this font description matches a given variant.

Parameters:
desiredVariant - The variant to match.
considerSimulated - Indicates whether simulated features should be considered in the test.
Returns:
True iff the style of this font description matches the criteria.

stretchMatches

public boolean stretchMatches(org.axsl.font.Font.Stretch desiredStretch,
                              boolean considerSimulated)
Indicates whether this font description matches a given stretch.

Parameters:
desiredStretch - The stretch to match.
considerSimulated - Indicates whether simulated features should be considered in the test.
Returns:
True iff the style of this font description matches the criteria.

weightMatches

public boolean weightMatches(org.axsl.font.Font.Weight desiredWeight)
Indicates whether this font description matches a given weight.

Parameters:
desiredWeight - The weight to match.
Returns:
True iff the style of this font description matches the criteria.

matchPerfect

public boolean matchPerfect(RegisteredFontFamily family,
                            boolean considerSimulated,
                            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)
Indicates whether this font description perfectly matches a given set of criteria.

Parameters:
family - The desired font-family.
considerSimulated - Indicates whether simulated features should be considered in this selection.
style - The desired style.
weight - The desired weight.
variant - The desired variant.
stretch - The desired stretch.
freeStandingFonts - Indicates whether free-standing fonts can be considered in this selection.
systemFonts - Indicates whether system fonts can be consdidered in this selection.
Returns:
True iff this font descriptions perfectly matches all of the selection criteria.

matchIgnoreWeight

public boolean matchIgnoreWeight(RegisteredFontFamily family,
                                 boolean considerSimulated,
                                 org.axsl.font.Font.Style style,
                                 org.axsl.font.Font.Variant variant,
                                 org.axsl.font.Font.Stretch stretch,
                                 boolean freeStandingFonts,
                                 boolean systemFonts)
Indicates whether this font description matches a given set of criteria, withour regard to the font-weight.

Parameters:
family - The desired font-family.
considerSimulated - Indicates whether simulated features should be considered in this selection.
style - The desired style.
variant - The desired variant.
stretch - The desired stretch.
freeStandingFonts - Indicates whether free-standing fonts can be considered in this selection.
systemFonts - Indicates whether system fonts can be consdidered in this selection.
Returns:
True iff this font descriptions perfectly matches all of the selection criteria.

generalTypeMatches

public boolean generalTypeMatches(boolean freeStandingFonts,
                                  boolean systemFonts)
Determines whether this registered font can return a Font instance that matches the general type requested.

Parameters:
freeStandingFonts - True iff the returned font can be a FreeStandingFont.
systemFonts - True iff the returned font can be a SystemFont.
Returns:
True iff this registered font is able to return a Font instance that matches the needs described by freeStandingFonts and systemFonts.


Copyright © 2017. All rights reserved.