org.foray.font
Class FontConsumer4a

java.lang.Object
  extended by org.foray.font.FontConsumer4a
All Implemented Interfaces:
org.axsl.font.FontConsumer

public class FontConsumer4a
extends Object
implements org.axsl.font.FontConsumer

An implementation of the aXSL FontConsumer interface. Instances are obtained by using the FOrayFontConsumer constructor(s). FOrayFontConsumer instances can then be used to obtain implementations of FontUse and Font which provide direct services to the client application.


Field Summary
static byte ENCODING_ANY
          Constant indicating that the font selection process is free to use any encoding that it can, including creating new ones, to make its full complement of glyphs available during the font selection process.
static byte ENCODING_INTERNAL_ONLY
          Constant indicating that only a font's internal encoding should be used during the font selection process.
static byte ENCODING_SPECIFIED_ONLY
          Constant indicating that only the encoding specified in the RegisteredFontDesc (from the font-configuration) should be used during the font selection process.
 
Fields inherited from interface org.axsl.font.FontConsumer
FONT_SOURCE_FREE_STANDING, FONT_SOURCE_SYSTEM
 
Constructor Summary
FontConsumer4a(FontServer4a server)
          Constructor.
 
Method Summary
 ConsumerFont4a getConsumerFont(Font4a font)
          Returns the FontUse instance for a given font.
protected  FontUse4a getDefaultFontUse()
          Return a default font.
 byte getEncodingLatitude()
          Returns the encoding latitude for this font consumer.
 FontSelector getFontSelectorAuto()
          Returns the "auto" font selector for this consumer.
 String getFontSelectorAutoType()
          Returns the "auto" font selector type for this consumer.
 FontSelector getFontSelectorCBC()
          Returns the character-by-character font selector for this consumer.
 FontServer4a getFontServer()
          Returns the parent font server instance.
 org.apache.commons.logging.Log getLogger()
          Provides the font system with the Log implementation which should be used to log messages.
 List<Font4a> getUsedFonts()
           
 List<FontUse4a> getUsedFontUses()
           
 boolean isUsingFreeStandingFonts()
          Indicates whether this consumer can use free-standing fonts or not.
 boolean isUsingSystemFonts()
          Indicates whether this consumer can use system fonts or not.
 void optimizeFonts()
           
 boolean preferFreeStandingFonts()
          Indicates whether free-standing fonts are preferred over system fonts.
protected  ConsumerFont4a registerFontUse(Font4a font)
          Record the fact that this FontConsumer has used this font.
 org.axsl.font.FontUse selectFontCss(List<String> familyList, org.axsl.font.Font.Style style, org.axsl.font.Font.Weight weight, org.axsl.font.Font.Variant variant, org.axsl.font.Font.Stretch stretch, int size, int codePoint)
           
 org.axsl.font.FontUse selectFontPanose(byte[] panose, int codePoint)
           
 org.axsl.font.FontUse selectFontXsl(org.axsl.font.Font.SelectionStrategy selectionStrategy, List<String> familyList, org.axsl.font.Font.Style style, org.axsl.font.Font.Weight weight, org.axsl.font.Font.Variant variant, org.axsl.font.Font.Stretch stretch, int size, int codePoint)
           
 void setEncodingLatitude(int encodingLatitude)
          Sets the encoding latitude that may be used during the font selection process.
 void setFontSelectorAutoType(String newFontSelectorAutoType)
          Sets the "auto" font selector type for this consumer.
 void setFontSources(int[] fontSources)
           
 void setLogger(org.apache.commons.logging.Log logger)
          Use this method to set a logger for this font consumer.
protected  Font4a whichUse(RegisteredFontDesc rfd, int codePoint)
          Since RegisteredFont and RegisteredFontDesc instances can encapsulate either a FreeStandingFont or a SystemFont, or both, this method selects which one should be used, based on the FontConsumer instances parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCODING_INTERNAL_ONLY

public static final byte ENCODING_INTERNAL_ONLY
Constant indicating that only a font's internal encoding should be used during the font selection process.

See Also:
Constant Field Values

ENCODING_SPECIFIED_ONLY

public static final byte ENCODING_SPECIFIED_ONLY
Constant indicating that only the encoding specified in the RegisteredFontDesc (from the font-configuration) should be used during the font selection process.

See Also:
Constant Field Values

ENCODING_ANY

public static final byte ENCODING_ANY
Constant indicating that the font selection process is free to use any encoding that it can, including creating new ones, to make its full complement of glyphs available during the font selection process.

See Also:
Constant Field Values
Constructor Detail

FontConsumer4a

public FontConsumer4a(FontServer4a server)
Constructor.

Parameters:
server - The FOrayFontServer instance serving this FontConsumer.
Method Detail

setFontSources

public void setFontSources(int[] fontSources)
Specified by:
setFontSources in interface org.axsl.font.FontConsumer

setLogger

public void setLogger(org.apache.commons.logging.Log logger)
Use this method to set a logger for this font consumer. This will override the logger used by FOrayFontServer.

Parameters:
logger - The new logger.

getLogger

public org.apache.commons.logging.Log getLogger()
Provides the font system with the Log implementation which should be used to log messages.

Returns:
Commons Log implementation which should be used to log messages for this FontConsumer.

isUsingFreeStandingFonts

public boolean isUsingFreeStandingFonts()
Indicates whether this consumer can use free-standing fonts or not.

Returns:
True iff this consumer can use free-standing fonts.

isUsingSystemFonts

public boolean isUsingSystemFonts()
Indicates whether this consumer can use system fonts or not.

Returns:
True iff this consumer can use system fonts.

preferFreeStandingFonts

public boolean preferFreeStandingFonts()
Indicates whether free-standing fonts are preferred over system fonts.

Returns:
True iff free-standing fonts are preferred over system fonts.

getFontServer

public FontServer4a getFontServer()
Returns the parent font server instance.

Returns:
The parent font server instance.

getFontSelectorAutoType

public String getFontSelectorAutoType()
Returns the "auto" font selector type for this consumer.

Returns:
The "auto" font selector type for this consumer.

setFontSelectorAutoType

public void setFontSelectorAutoType(String newFontSelectorAutoType)
Sets the "auto" font selector type for this consumer.

Parameters:
newFontSelectorAutoType - The new "auto" font selector type for this consumer.

getFontSelectorCBC

public FontSelector getFontSelectorCBC()
Returns the character-by-character font selector for this consumer.

Returns:
The character-by-character font selector for this consumer.

getFontSelectorAuto

public FontSelector getFontSelectorAuto()
Returns the "auto" font selector for this consumer.

Returns:
The "auto" font selector for this consumer.

selectFontXsl

public org.axsl.font.FontUse selectFontXsl(org.axsl.font.Font.SelectionStrategy selectionStrategy,
                                           List<String> familyList,
                                           org.axsl.font.Font.Style style,
                                           org.axsl.font.Font.Weight weight,
                                           org.axsl.font.Font.Variant variant,
                                           org.axsl.font.Font.Stretch stretch,
                                           int size,
                                           int codePoint)
                                    throws org.axsl.font.FontException
Specified by:
selectFontXsl in interface org.axsl.font.FontConsumer
Throws:
org.axsl.font.FontException

getDefaultFontUse

protected FontUse4a getDefaultFontUse()
Return a default font. We don't care what it can encode.

Returns:
A default font.

whichUse

protected Font4a whichUse(RegisteredFontDesc rfd,
                          int codePoint)

Since RegisteredFont and RegisteredFontDesc instances can encapsulate either a FreeStandingFont or a SystemFont, or both, this method selects which one should be used, based on the FontConsumer instances parameters.

In cases where both a FreeStandingFont and a SystemFont are available, and either can be selected, this method also breaks the tie, again using a FontConsumer parameter. Although each has access to the other's methods for things that it does not natively know, there are still potential differences between the two (especially font metrics), and an application needs to be able to select which one it prefers.

Parameters:
rfd - The RegisteredFontDesc instance which points to the usable font.
codePoint - The Unicode code point that should be tested to ensure that it can be encoded.
Returns:
The FontUse instance dictated by the parameters of consumer.

selectFontCss

public org.axsl.font.FontUse selectFontCss(List<String> familyList,
                                           org.axsl.font.Font.Style style,
                                           org.axsl.font.Font.Weight weight,
                                           org.axsl.font.Font.Variant variant,
                                           org.axsl.font.Font.Stretch stretch,
                                           int size,
                                           int codePoint)
                                    throws org.axsl.font.FontException
Specified by:
selectFontCss in interface org.axsl.font.FontConsumer
Throws:
org.axsl.font.FontException

getUsedFonts

public List<Font4a> getUsedFonts()
Specified by:
getUsedFonts in interface org.axsl.font.FontConsumer

getUsedFontUses

public List<FontUse4a> getUsedFontUses()
Specified by:
getUsedFontUses in interface org.axsl.font.FontConsumer

registerFontUse

protected ConsumerFont4a registerFontUse(Font4a font)
Record the fact that this FontConsumer has used this font.

Parameters:
font - The Font instance that was used.
Returns:
The consumer font that encapsulates font for this consumer.

optimizeFonts

public void optimizeFonts()
Specified by:
optimizeFonts in interface org.axsl.font.FontConsumer

getConsumerFont

public ConsumerFont4a getConsumerFont(Font4a font)
Returns the FontUse instance for a given font.

Parameters:
font - The Font instance for which we wish to find the related FontUse instance.
Returns:
The related FontUse instance.

getEncodingLatitude

public byte getEncodingLatitude()
Returns the encoding latitude for this font consumer.

Returns:
One of the valid encoding latitude specifiers: ENCODING_INTERNAL_ONLY, ENCODING_SPECIFIED_ONLY, or ENCODING_ANY.

setEncodingLatitude

public void setEncodingLatitude(int encodingLatitude)
                         throws org.axsl.font.FontException
Sets the encoding latitude that may be used during the font selection process.

Parameters:
encodingLatitude - One of the valid encoding latitude specifiers: ENCODING_INTERNAL_ONLY, ENCODING_SPECIFIED_ONLY, or ENCODING_ANY.
Throws:
org.axsl.font.FontException - If the encoding latitude is not valid.

selectFontPanose

public org.axsl.font.FontUse selectFontPanose(byte[] panose,
                                              int codePoint)
                                       throws org.axsl.font.FontException
Specified by:
selectFontPanose in interface org.axsl.font.FontConsumer
Throws:
org.axsl.font.FontException


Copyright © 2017. All rights reserved.