Class FontUIResource
java.lang.Object
java.awt.Font
javax.swing.plaf.FontUIResource
- All Implemented Interfaces:
Serializable, UIResource
A subclass of java.awt.Font that implements UIResource.
UI classes which set default font properties should use
this class.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans
package.
Please see XMLEncoder
.
- See Also:
-
Field Summary
Fields declared in class Font
BOLD, CENTER_BASELINE, DIALOG, DIALOG_INPUT, HANGING_BASELINE, ITALIC, LAYOUT_LEFT_TO_RIGHT, LAYOUT_NO_LIMIT_CONTEXT, LAYOUT_NO_START_CONTEXT, LAYOUT_RIGHT_TO_LEFT, MONOSPACED, name, PLAIN, pointSize, ROMAN_BASELINE, SANS_SERIF, SERIF, size, style, TRUETYPE_FONT, TYPE1_FONT
Modifier and TypeFieldDescriptionstatic final int
The bold style constant.static final int
The baseline used in ideographic scripts like Chinese, Japanese, and Korean when laying out text.static final String
A String constant for the canonical family name of the logical font "Dialog".static final String
A String constant for the canonical family name of the logical font "DialogInput".static final int
The baseline used in Devanagari and similar scripts when laying out text.static final int
The italicized style constant.static final int
A flag to layoutGlyphVector indicating that text is left-to-right as determined by Bidi analysis.static final int
A flag to layoutGlyphVector indicating that text in the char array after the indicated limit should not be examined.static final int
A flag to layoutGlyphVector indicating that text in the char array before the indicated start should not be examined.static final int
A flag to layoutGlyphVector indicating that text is right-to-left as determined by Bidi analysis.static final String
A String constant for the canonical family name of the logical font "Monospaced".protected String
The logical name of thisFont
, as passed to the constructor.static final int
The plain style constant.protected float
The point size of thisFont
infloat
.static final int
The baseline used in most Roman scripts when laying out text.static final String
A String constant for the canonical family name of the logical font "SansSerif".static final String
A String constant for the canonical family name of the logical font "Serif".protected int
The point size of thisFont
, rounded to integer.protected int
The style of thisFont
, as passed to the constructor.static final int
Identify a font resource of type TRUETYPE.static final int
Identify a font resource of type TYPE1. -
Constructor Summary
ConstructorsConstructorDescriptionFontUIResource
(Font font) Constructs aFontUIResource
.FontUIResource
(String name, int style, int size) Constructs aFontUIResource
. -
Method Summary
Methods declared in class Font
canDisplay, canDisplay, canDisplayUpTo, canDisplayUpTo, canDisplayUpTo, createFont, createFont, createFonts, createFonts, createGlyphVector, createGlyphVector, createGlyphVector, createGlyphVector, decode, deriveFont, deriveFont, deriveFont, deriveFont, deriveFont, deriveFont, equals, getAttributes, getAvailableAttributes, getBaselineFor, getFamily, getFamily, getFont, getFont, getFont, getFontName, getFontName, getItalicAngle, getLineMetrics, getLineMetrics, getLineMetrics, getLineMetrics, getMaxCharBounds, getMissingGlyphCode, getName, getNumGlyphs, getPSName, getSize, getSize2D, getStringBounds, getStringBounds, getStringBounds, getStringBounds, getStyle, getTransform, hashCode, hasLayoutAttributes, hasUniformLineMetrics, isBold, isItalic, isPlain, isTransformed, layoutGlyphVector, textRequiresLayout, toString
Modifier and TypeMethodDescriptionboolean
canDisplay
(char c) Checks if thisFont
has a glyph for the specified character.boolean
canDisplay
(int codePoint) Checks if thisFont
has a glyph for the specified character.int
canDisplayUpTo
(char[] text, int start, int limit) Indicates whether or not thisFont
can display the characters in the specifiedtext
starting atstart
and ending atlimit
.int
canDisplayUpTo
(String str) Indicates whether or not thisFont
can display a specifiedString
.int
canDisplayUpTo
(CharacterIterator iter, int start, int limit) Indicates whether or not thisFont
can display the text specified by theiter
starting atstart
and ending atlimit
.static Font
createFont
(int fontFormat, File fontFile) Returns a newFont
using the specified font type and the specified font file.static Font
createFont
(int fontFormat, InputStream fontStream) Returns a newFont
using the specified font type and input data.static Font[]
createFonts
(File fontFile) Returns a new array ofFont
decoded from the specified file.static Font[]
createFonts
(InputStream fontStream) Returns a new array ofFont
decoded from the specified stream.createGlyphVector
(FontRenderContext frc, char[] chars) Creates aGlyphVector
by mapping characters to glyphs one-to-one based on the Unicode cmap in thisFont
.createGlyphVector
(FontRenderContext frc, int[] glyphCodes) Creates aGlyphVector
by mapping characters to glyphs one-to-one based on the Unicode cmap in thisFont
.createGlyphVector
(FontRenderContext frc, String str) Creates aGlyphVector
by mapping characters to glyphs one-to-one based on the Unicode cmap in thisFont
.Creates aGlyphVector
by mapping the specified characters to glyphs one-to-one based on the Unicode cmap in thisFont
.static Font
Returns theFont
that thestr
argument describes.deriveFont
(float size) Creates a newFont
object by replicating the currentFont
object and applying a new size to it.deriveFont
(int style) Creates a newFont
object by replicating the currentFont
object and applying a new style to it.deriveFont
(int style, float size) Creates a newFont
object by replicating thisFont
object and applying a new style and size.deriveFont
(int style, AffineTransform trans) Creates a newFont
object by replicating thisFont
object and applying a new style and transform.deriveFont
(AffineTransform trans) Creates a newFont
object by replicating the currentFont
object and applying a new transform to it.deriveFont
(Map<? extends AttributedCharacterIterator.Attribute, ?> attributes) Creates a newFont
object by replicating the currentFont
object and applying a new set of font attributes to it.boolean
Compares thisFont
object to the specifiedObject
.Map
<TextAttribute, ?> Returns a map of font attributes available in thisFont
.Returns the keys of all the attributes supported by thisFont
.byte
getBaselineFor
(char c) Returns the baseline appropriate for displaying this character.Returns the family name of thisFont
.Returns the family name of thisFont
, localized for the specified locale.static Font
Returns aFont
object from the system properties list.static Font
Gets the specifiedFont
from the system properties list.static Font
getFont
(Map<? extends AttributedCharacterIterator.Attribute, ?> attributes) Returns aFont
appropriate to the attributes.Returns the font face name of thisFont
.Returns the font face name of theFont
, localized for the specified locale.float
Returns the italic angle of thisFont
.getLineMetrics
(char[] chars, int beginIndex, int limit, FontRenderContext frc) Returns aLineMetrics
object created with the specified arguments.getLineMetrics
(String str, int beginIndex, int limit, FontRenderContext frc) Returns aLineMetrics
object created with the specified arguments.getLineMetrics
(String str, FontRenderContext frc) getLineMetrics
(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc) Returns aLineMetrics
object created with the specified arguments.Returns the bounds for the character with the maximum bounds as defined in the specifiedFontRenderContext
.int
Returns the glyphCode which is used when thisFont
does not have a glyph for a specified unicode code point.getName()
Returns the logical name of thisFont
.int
Returns the number of glyphs in thisFont
.Returns the postscript name of thisFont
.int
getSize()
Returns the point size of thisFont
, rounded to an integer.float
Returns the point size of thisFont
infloat
value.getStringBounds
(char[] chars, int beginIndex, int limit, FontRenderContext frc) Returns the logical bounds of the specified array of characters in the specifiedFontRenderContext
.getStringBounds
(String str, int beginIndex, int limit, FontRenderContext frc) Returns the logical bounds of the specifiedString
in the specifiedFontRenderContext
.getStringBounds
(String str, FontRenderContext frc) Returns the logical bounds of the specifiedString
in the specifiedFontRenderContext
.getStringBounds
(CharacterIterator ci, int beginIndex, int limit, FontRenderContext frc) Returns the logical bounds of the characters indexed in the specifiedCharacterIterator
in the specifiedFontRenderContext
.int
getStyle()
Returns the style of thisFont
.Returns a copy of the transform associated with thisFont
.int
hashCode()
Returns a hashcode for thisFont
.boolean
Return true if this Font contains attributes that require extra layout processing.boolean
Checks whether or not thisFont
has uniform line metrics.boolean
isBold()
Indicates whether or not thisFont
object's style is BOLD.boolean
isItalic()
Indicates whether or not thisFont
object's style is ITALIC.boolean
isPlain()
Indicates whether or not thisFont
object's style is PLAIN.boolean
Indicates whether or not thisFont
object has a transform that affects its size in addition to the Size attribute.layoutGlyphVector
(FontRenderContext frc, char[] text, int start, int limit, int flags) Returns a newGlyphVector
object, performing full layout of the text if possible.static boolean
textRequiresLayout
(char[] chars, int start, int end) Returns true if any part of the specified text is from a complex script for which the implementation will need to invoke layout processing in order to render correctly when usingdrawString(String,int,int)
and other text rendering methods.toString()
Converts thisFont
object to aString
representation.Methods declared in class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
FontUIResource
Constructs aFontUIResource
.- Parameters:
name
- the font namestyle
- the style constant for the fontsize
- the point size of the font
-
FontUIResource
-