public interface Font
Modifier and Type | Interface and Description |
---|---|
static class |
Font.Baseline
Enumeration of the various baselines that can be defined in a font.
|
static class |
Font.Complexity
Enumeration of constants to describe the complexity of a font.
|
static class |
Font.Embedding
Enumeration of the types of font embedding.
|
static class |
Font.Format
Enumeration of constants to describe the format of a font.
|
static class |
Font.LineHeightAlgorithm
Enumeration of possible algorithms that could be used to compute the
line-height for a given font.
|
static class |
Font.SelectionStrategy
Enumeration of constants needed to describe the various font selection
strategies.
|
static class |
Font.Stretch
Enumeration of constants needed to describe the "stretch" value of a
font.
|
static class |
Font.Style
Enumeration of constants needed to describe the style of a font.
|
static class |
Font.Variant
Enumeration of constants needed to describe the variant of a font.
|
static class |
Font.Weight
Enumeration of constants needed to describe the weight of a font.
|
static class |
Font.WritingMode
Enumeration of possible writing-modes that a font might have.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
INVALID_STRING
The String "invalid", defined as a constant to avoid duplication.
|
static java.lang.String |
NORMAL_STRING
The String "normal", defined as a constant to avoid duplication.
|
Modifier and Type | Method and Description |
---|---|
Font.Baseline |
baseline(java.lang.String script)
Determines which baseline should be used by this font for a specified script.
|
int |
baselineOffset(Font.WritingMode writingMode,
Font.Baseline baselineType,
int fontSize)
Returns the location of the specified baseline.
|
int |
getAscender(int fontSize)
Returns the Ascender value for this font, scaled to a specific point
size.
|
java.awt.Font |
getAwtFont(int fontSize)
If this Font has a java.awt.Font associated with it, return it.
|
int |
getCapHeight(int fontSize)
Returns the CapHeight value for this font, scaled to a specific point
size.
|
int |
getDefaultWidth()
Returns the default glyph width for this font.
|
int |
getDescender(int fontSize)
Returns the Descender value for this font, scaled to a specific point
size.
|
java.lang.String |
getFamilyName()
Returns this font's font-family name.
|
Font.Complexity |
getFontComplexity()
Returns a value indicating whether this font is a simple or composite
font.
|
Font.Format |
getFontFormat()
Returns a value indicating what format (e.g.
|
java.lang.String |
getFontName()
Returns this font's name.
|
Encoding |
getInternalEncoding()
Get the font's internal Encoding scheme.
|
float |
getItalicAngle()
Returns the ItalicAngle value for this font.
|
byte[] |
getPanose()
Returns the Panose array for this font.
|
java.lang.String |
getPostscriptName()
Returns the PostScript name of the font.
|
int |
getStemV()
Returns the StemV value for this font, used in a PDF Font Descriptor, as
defined in the PDF Reference, Second Edition, Section 5.7.
|
int |
getXHeight(int fontSize)
Returns the XHeight value for this font, scaled to a specific point
size.
|
boolean |
isEmbeddable()
Tells the client application whether this font can be embedded or not.
|
boolean |
isPdfStandardFont()
Indicates whether this font is one of the PDF Base-14 fonts.
|
boolean |
isSubsettable()
Tells the client application whether a subset of this font can be
embedded.
|
int |
kern(int glyphIndex1,
int glyphIndex2)
Computes the kerning needed between two glyphs in this font.
|
float |
normalLineHeightFactor(Font.LineHeightAlgorithm algorithm)
Returns a factor suitable for computing a "normal" line-height as
defined in the CSS and XSL-FO standards.
|
int |
overlinePosition(int fontSize)
The recommended position of the bottom of the overline stroke, relative
to the baseline, in millipoints.
|
int |
overlineSize(int fontSize)
The recommended thickness, in millipoints, of the overline stroke for
this font.
|
int |
strikeoutPosition(int fontSize)
The recommended position of the top of the strikeout stroke, relative to
the baseline, in millipoints.
|
int |
strikeoutSize(int fontSize)
The recommended thickness, in millipoints, of the strikeout stroke for
this font.
|
int |
subscriptShift(int fontSize)
The amount by which the alphabetic baseline should be shifted when
writing subscripts for this font.
|
int |
superscriptShift(int fontSize)
The amount by which the alphabetic baseline should be shifted when
writing superscripts for this font.
|
int |
underlinePosition(int fontSize)
The recommended position of the top of the underline stroke, relative to
the baseline, in millipoints.
|
int |
underlineSize(int fontSize)
The recommended thickness, in millipoints, of the underline stroke for
this font.
|
boolean |
usableInPostScriptOutput()
Indicates whether this font can be referenced within a PostScript file.
|
int |
width(int metricIndex,
int fontSize)
Returns the width of a glyph for this font, at a specified point size.
|
int |
width(IntSequence metricIndexes,
int offset,
int length,
int fontSize,
int letterSpacing,
int wordSpacing,
FontOptions options,
Orthography orthography)
Calculates the width of a given glyph sequence, considering letter spacing, word spacing, and font options
such as kerning and ligatures.
|
int |
widthEstimate(int codePoint,
int fontSize)
Returns the estimated width of a Unicode character for this font, at a
specified point size.
|
static final java.lang.String NORMAL_STRING
static final java.lang.String INVALID_STRING
int getAscender(int fontSize)
fontSize
- The font size, in millipoints.int getDescender(int fontSize)
fontSize
- The font size, in millipoints.int getCapHeight(int fontSize)
fontSize
- The font size, in millipoints.int getXHeight(int fontSize)
fontSize
- The font size, in millipoints.int width(int metricIndex, int fontSize)
metricIndex
- The metric index for which the width should be returned.
For TrueType fonts the metric index is the same as the glyph index.
For Type1 fonts, a CharSet is used to map between the glyph index and the metric index.fontSize
- The size, in millipoints, of the font.codePoint
, or Integer.MIN_VALUE
if such a glyph is not found.int width(IntSequence metricIndexes, int offset, int length, int fontSize, int letterSpacing, int wordSpacing, FontOptions options, Orthography orthography)
metricIndexes
- The metric indexes of the glyph sequence whose width should be computed.offset
- The zero-based index into metricIndexes
that is the start of what should be computed.length
- The number of glyph indexes in metricIndexes
that should be computed.fontSize
- The size, in millipoints, of the font.letterSpacing
- The size, in millipoints, of any additional letter-spacing.wordSpacing
- The size, in millipoints, of any additional 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.metricIndexes
.
Letter-spacing and kerning are added between characters in metricIndexes
, but are not added
either before or after.
(Adding letter-spacing or kerning before or after would require making assumptions about the context of
{metricIndexes 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".int widthEstimate(int codePoint, int fontSize)
width(int, int)
has indicated that the font cannot return a
true width.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 the implementation cannot estimate such a width.boolean isEmbeddable()
boolean isSubsettable()
java.awt.Font getAwtFont(int fontSize)
fontSize
- The font size, in millipoints.Font
instance, if there is one,
otherwise null.boolean usableInPostScriptOutput()
java.lang.String getFamilyName()
getFontName()
,
getPostscriptName()
java.lang.String getFontName()
getFamilyName()
,
getPostscriptName()
java.lang.String getPostscriptName()
getFamilyName()
,
getFontName()
Encoding getInternalEncoding()
FontUse.getEncoding()
Font.Complexity getFontComplexity()
Font.Complexity.SIMPLE
,
or Font.Complexity.COMPOSITE
.Font.Format getFontFormat()
Font.Format.TYPE1
,
or Font.Format.TRUETYPE
.int kern(int glyphIndex1, int glyphIndex2)
glyphIndex1
- The glyph index of the first (left in a left-to-right system) glyph.glyphIndex2
- The glyph index of the second (right in left-to-right system) glyph.float getItalicAngle()
int getStemV()
int getDefaultWidth()
boolean isPdfStandardFont()
float normalLineHeightFactor(Font.LineHeightAlgorithm algorithm)
Returns a factor suitable for computing a "normal" line-height as defined in the CSS and XSL-FO standards. The line-height is the distance, including leading, between the baselines of stacked lines of text. The CSS and XSL-FO standards recommend that the "normal" value for line-height fall between 1.0 and 1.2. (see Section 7.15.4 of XSL-FO 1.0) This method attempts to find a suitable value based on the characteristics of the font itself.
Design Note 1: This method returns a float factor instead of a computation of the actual line-height to facilitate the handling of inheritance where that is required. For example, for CSS and XSL-FO, the factor is what is inherited instead of the computed line-height.
algorithm
- The specifier of an algorithm that should be used to
compute the factor.
Valid values include Font.LineHeightAlgorithm.DEFAULT
, which puts the
implementation in complete control of the computation.
Other algorithms may be added in the future.int baselineOffset(Font.WritingMode writingMode, Font.Baseline baselineType, int fontSize)
writingMode
- Constant indicating the direction in which the script
is being written.baselineType
- Constant indicating which baseline is sought.fontSize
- The size, in millipoints, at which the font is scaled.Font.Baseline baseline(java.lang.String script)
script
- The 4-character (or less) OpenType script name assigned by Microsoft for which
a baseline is sought.
A partial list of these values can be found in
the script tags list
in the OpenType documentation.
A more comprehensive list of these values can be found at the Microsoft Typography
Script
tags page.
Design Note 1: Considerable difficulty was encountered in deciding how this parameter should be represented. At one time, an enumeration ofISO 15924 values was used. However, the OpenType script values are controlled by Microsoft, and there appears to be no necessary relationship between them. Also, the use of an enumeration seems unnecessarily restrictive, since 1) font developers can actually use any script name that they wish, at the risk of being non-standard, and 2) new scripts may be added at any time that are not yet included in the enumeration. The main drawback of using a String representation is that it must be tied to one standard, instead of being generic enough to handle other possible naming conventions for scripts. This drawback was deemed acceptable, as 1) OpenType is the only known format currently offering such features, and 2) other formats may use the same format or a format that can readily be converted to and from the OpenType convention.
int subscriptShift(int fontSize)
fontSize
- The size, in millipoints, at which the font is scaled.int superscriptShift(int fontSize)
fontSize
- The size, in millipoints, at which the font is scaled.int underlineSize(int fontSize)
fontSize
- The font size for which the underline thickness should be
computed.int underlinePosition(int fontSize)
fontSize
- The font size for which the underline position should be
computed.int overlineSize(int fontSize)
fontSize
- The font size for which the overline thickness should be
computed.int overlinePosition(int fontSize)
fontSize
- The font size for which the overline position should be
computed.int strikeoutSize(int fontSize)
fontSize
- The font size for which the strikeout thickness should be
computed.int strikeoutPosition(int fontSize)
fontSize
- The font size for which the strikeout position should be
computed.byte[] getPanose()
This documentation was created 2017-01-24 at 21:26 GMT by The aXSL Group and may be freely copied. See license for details.