public interface FontUse
Font
as it is used by a specific
FontConsumer
, for a specific Encoding
and for a specific
font family. It is possible for a FontConsumer
to use the same
Font
instance in more than one way, due to more than one encoding or
the font being configured in more than one font family.Modifier and Type | Method and Description |
---|---|
boolean |
canMakeFontOutput(java.lang.String mimeType)
Indicates whether this FontUse instance is capable of creating a
FontOutput instance for a given mime type. |
IntSequence |
encode(java.lang.CharSequence chars,
int offset,
int length,
FontOptions options,
Orthography orthography)
Retrieve the array of font glyph indexes for a specified Word.
|
int |
encode(int codePoint)
Retrieve the font glyph index for a specified Unicode character.
|
Encoding |
getEncoding()
Get the Encoding scheme that is used to encode characters in this Font.
|
Font |
getFont()
Return the parent Font.
|
FontConsumer |
getFontConsumer()
Returns the FontConsumer for whom this FontUse exists.
|
FontOutput |
getFontOutput(java.lang.String mimeType)
Provide a
FontOutput implementation for a given mime type. |
java.lang.String |
getPostscriptName()
Returns the PostScript name of the font.
|
boolean |
glyphAvailable(int codePoint)
Reports whether a glyph can be encoded for a given Unicode code
point.
|
FontUse |
nextBolderFont()
Returns the next bolder font in this font's font-family, if one exists,
or null if this is the boldest font.
|
Font.Weight |
nextBolderWeight()
Returns the weight of the next bolder font in this font's font-family,
if one exists.
|
FontUse |
nextLighterFont()
Returns the next lighter font in this font's font-family, if one exists,
or null if this is the lightest font.
|
Font.Weight |
nextLighterWeight()
Returns the weight of the next lighter font in this font's font-family,
if one exists.
|
void |
registerCharsUsed(java.lang.CharSequence charSequence)
Convenience method that provides the equivalent of running
registerCharUsed(int) for each char in a given
String, StringBuffer or other CharSequence . |
void |
registerCharUsed(int codePoint)
Records the fact that a FontConsumer is using a particular character.
|
float |
simulateBackslant()
If this font has been configured to simulate the "backslant" font-style,
return the percentage of 90 degrees that should be used to compute
the angle at which the characters should be skewed to obtain that
effect.
|
float |
simulateCondensed()
If this font has been configured to simulate the "condensed"
font-stretch, return the percentage that should be applied to the width
of characters in this font to achieve that effect.
|
float |
simulateExpanded()
If this font has been configured to simulate the "expanded"
font-stretch, return the percentage that should be applied to the width
of characters in this font to achieve that effect.
|
float |
simulateExtraCondensed()
If this font has been configured to simulate the "extra-condensed"
font-stretch, return the percentage that should be applied to the width
of characters in this font to achieve that effect.
|
float |
simulateExtraExpanded()
If this font has been configured to simulate the "extra-expanded"
font-stretch, return the percentage that should be applied to the width
of characters in this font to achieve that effect.
|
float |
simulateOblique()
If this font has been configured to simulate the "oblique" font-style,
return the percentage of 90 degrees that should be used to compute
the angle at which the characters should be skewed to obtain that
effect.
|
float |
simulateSemiCondensed()
If this font has been configured to simulate the "semi-condensed"
font-stretch, return the percentage that should be applied to the width
of characters in this font to achieve that effect.
|
float |
simulateSemiExpanded()
If this font has been configured to simulate the "semi-expanded"
font-stretch, return the percentage that should be applied to the width
of characters in this font to achieve that effect.
|
float |
simulateSmallCaps()
If this font has been configured to simulate small-caps,
returns the percentage of the font-size that will be used to compute
the faux small-caps size.
|
float |
simulateUltraCondensed()
If this font has been configured to simulate the "ultra-condensed"
font-stretch, return the percentage that should be applied to the width
of characters in this font to achieve that effect.
|
float |
simulateUltraExpanded()
If this font has been configured to simulate the "ultra-expanded"
font-stretch, return the percentage that should be applied to the width
of characters in this font to achieve that effect.
|
int |
smallCapsSize(int fontSize)
Computes the size, in millipoints, which should be used for the
intrinsically lowercase characters in this font.
|
int |
unavailableChar(java.lang.CharSequence chars,
int beginIndex)
Examines each character in a specified portion of a String or other
CharSequence to determine whether a glyph can be encoded for that
character.
|
int[] |
unavailableChars(java.lang.CharSequence chars,
int beginIndex)
Examines each character in a specified portion of a String or other
CharSequence to determine whether a glyph can be encoded for that
character.
|
boolean |
wasUsed()
Indicates whether any characters registered use.
|
int |
width(java.lang.CharSequence chars,
int offset,
int length,
int fontSize,
int letterSpacing,
int wordSpacing,
FontOptions options,
Orthography orthography)
Calculates the width of a given character sequence, considering letter spacing, word spacing, and font options
such as kerning and ligatures.
|
int |
width(int codePoint,
int fontSize)
Returns the width of a Unicode character for this font, at a specified point size.
|
Font getFont()
FontConsumer getFontConsumer()
Encoding getEncoding()
Font.getInternalEncoding()
int encode(int codePoint)
Retrieve the font glyph index for a specified Unicode character. Note that if the font is subsetted, the glyph index returned is that for the subsetted font, not for the original font. This is needed to properly build and retrieve font subset information and to ensure that the right encoding is used.
Design Note: This method returns an int (instead of a char) because it is conceivable that some fonts will need more than 16 bits to express their glyph indexes.
codePoint
- The Unicode character for which the glyph index is
desired.codePoint
. This is normally the
code that is written to an output document (such as PDF or PostScript).IntSequence encode(java.lang.CharSequence chars, int offset, int length, FontOptions options, Orthography orthography)
Retrieve the array of font glyph indexes for a specified Word.
Note that the results of this method may not be equal to the sum of the results of encode(int)
because of possible font substitutions such as ligatures.
Note that if the font is subsetted, the glyph index returned is that for the subsetted font, not for the original
font.
This is needed to properly build and retrieve font subset information and to ensure that the right encoding is
used.
Design Note: This method returns ints (instead of a chars) because it is conceivable that some fonts will need more than 16 bits to express their glyph indexes.
chars
- The character sequence containing the characters that should be encoded.offset
- The zero-based index into chars
that is the start of what should be encoded.length
- The number of chars in chars
that should be encoded.
Implementations should assume that each word will be hyphenated no more than one time, i.e that the word will
span, at most, two lines.
Therefore, this index should always be zero or one.
For the first option (index 0), the index should always be zero, as there will always be only one segment for
that option.options
- The font options, such as ligatures and small-caps that should be used when computing the glyphs
for this word.orthography
- The orthography that should be used when applying font features like subsitutions.int unavailableChar(java.lang.CharSequence chars, int beginIndex)
Examines each character in a specified portion of a String or other CharSequence to determine whether a glyph can be encoded for that character. If a glyph cannot be encoded, either because the Font does not have a glyph for the character, or because the FontUse encoding cannot encode the character, the character's index in the CharSequence is returned. Unprintable code points for spacing, breaking, and layout control are treated by all fonts as "available".
chars
- The String, StringBuffer or other CharSequence to be
examined.beginIndex
- The first index in chars
to be examined.chars
at or after
beginIndex
which contains an unencodable character.
If all characters in chars
can be encoded, -1 is returned.unavailableChars(CharSequence, int)
,
glyphAvailable(int)
int[] unavailableChars(java.lang.CharSequence chars, int beginIndex)
Examines each character in a specified portion of a String or other CharSequence to determine whether a glyph can be encoded for that character. If a glyph cannot be encoded, either because the Font does not have a glyph for the character, or because the FontUse encoding cannot encode the character, its index is included in an array of indexes that is returned. Unprintable code points for spacing, breaking, and layout control are treated by all fonts as "available".
chars
- The String, StringBuffer or other CharSequence to be
examined.beginIndex
- The first index in chars
to be examined.chars
for which no glyph can be encoded.
If all characters in chars
can be encoded, null is returned.unavailableChar(CharSequence, int)
,
glyphAvailable(int)
boolean glyphAvailable(int codePoint)
Reports whether a glyph can be encoded for a given Unicode code point.
Note that, even if the Font has a glyph for the character, this method will return false if the character cannot be encoded with this FontUse's encoding. Unprintable code points for spacing, breaking, and layout control are treated by all fonts as "available".
codePoint
- The Unicode character to be tested.unavailableChar(CharSequence, int)
,
unavailableChars(CharSequence, int)
int width(int codePoint, int fontSize)
codePoint
- The Unicode character for which the width should be returned.fontSize
- The size, in millipoints, of the font.codePoint
, or Integer.MIN_VALUE
if such a glyph is not found.int width(java.lang.CharSequence chars, int offset, int length, int fontSize, int letterSpacing, int wordSpacing, FontOptions options, Orthography orthography)
chars
- The character sequence whose width should be computed.offset
- The zero-based index into chars
that is the start of what should be computed.length
- The number of chars in chars
that should be computed.fontSize
- The size, in millipoints, of the font.letterSpacing
- The size, in millipoints, of any letter-spacing.wordSpacing
- The size, in millipoints, of any word-spacing.options
- Options indicating how the font should use its features.orthography
- The orthography that should be used when applying locale-sensitive font features.chars
.
Letter-spacing and kerning are added between characters in chars
, but are not added either
before or after.
(Adding letter-spacing or kerning before or after would require making assumptions about the context of
chars
, including whether it is at the beginning or end of the line, what fonts surround it, etc.)
Word-spacing is added only to space characters (0x20).
Any other whitespace characters that the client applications wishes to have considered as word-spacing must
first be normalized to 0x20.
If there is no glyph for a character in chars
, the width returned will be that of the "missing glyph".Font.Weight nextBolderWeight()
Font.Weight.BLACK
, then returns that value.Font.Weight nextLighterWeight()
Font.Weight.EXTREMELY_LIGHT
, then returns that value.FontUse nextBolderFont()
FontUse nextLighterFont()
float simulateSmallCaps()
FontServer.SMALL_CAP_SIMULATION_INVALID
.int smallCapsSize(int fontSize)
Computes the size, in millipoints, which should be used for the intrinsically lowercase characters in this font. If the font has true small-caps glyphs or is unable to simulate small-caps, the value returned will be the same as the value passed. In other words, no scaling is implied. Only if the font is capable of simulating small-caps will the value returned be different from the value passed.
Not all font-families have a small-caps variant, but small-caps can be simulated by the client application. To do so, 1) convert all text to uppercase characters, and 2) switch back and forth between a larger font size (for characters originally in uppercase) and a smaller font size (for characters originally in lowercase). If the requested font size is 12 points, and the lowercase characters should be scaled at 80%, then the font size to use for the lowercase characters is 9.6 points.
Note that the simulation of small-caps is done entirely outside of the font system. As far as the font system is concerned, the same font is being used regardless of whether it is being used at the size for uppercase characters or the size for lowercase characters. All that is being reported in this method is the computation of what has been configured for the font.
fontSize
- The size, in millipoints, of the font at normal size.
In other words, the size that will be used to create the uppercase
glyphs.float simulateOblique()
float simulateBackslant()
float simulateUltraCondensed()
float simulateExtraCondensed()
float simulateCondensed()
float simulateSemiCondensed()
float simulateSemiExpanded()
float simulateExpanded()
float simulateExtraExpanded()
float simulateUltraExpanded()
java.lang.String getPostscriptName()
void registerCharUsed(int codePoint)
codePoint
- The Unicode character to be registered.void registerCharsUsed(java.lang.CharSequence charSequence)
registerCharUsed(int)
for each char in a given
String, StringBuffer or other CharSequence
.charSequence
- The CharSequence
whose contents should be
registered.FontOutput getFontOutput(java.lang.String mimeType)
FontOutput
implementation for a given mime type.
If the mime type is not supported, an unchecked
UnsupportedOperationException
will be thrown.
To avoid this, use canMakeFontOutput(String)
to check the
capability first.mimeType
- The mime type for which the FontOutput instance should
be obtained.boolean canMakeFontOutput(java.lang.String mimeType)
FontOutput
instance for a given mime type.mimeType
- The mime type for which we are checking the capability.boolean wasUsed()
registerCharUsed(int)
and
registerCharsUsed(CharSequence)
.This documentation was created 2017-01-24 at 21:26 GMT by The aXSL Group and may be freely copied. See license for details.