|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.pt.awt.NFont
Superclass for new fonts, which provide more control than java.awt.Font
.
(NFont is a complete font implementation from scratch, and does not use java.awt.Font
.)
Usage is patterned after Font
, except that drawing is a method on the font rather than a special case of Graphics2D
.
font property flags
. (Flags are identical to Adobe's definitions, with additional as marked.)
standard weight values
display modes
intellectual property font usage restriction settings
and querying
special characters
creation
size
, AffineTransform
getName()
, getFamily()
, getDesigner()
, getCopyright()
, getFormat()
, getSubformat()
, getRights()
, getNumGlyphs()
, getMaxGlyphNum()
getSize()
, getFlags()
, getWeight()
, getTransform()
, isTransformed()
, strFlags(int)
toUnicode(String)
, fromUnicode(String)
, getSpaceEchar()
stringAdvance(String)
, stringAdvance(String)
, estringAdvance(String,int,int)
, charAdvance(int)
, echarAdvance(int)
getStringBounds(String)
, getStringBounds(String,int,int)
, getEstringBounds(String,int,int)
, getMaxCharBounds()
canDisplay(int)
, drawString(Graphics2D,String,float,float)
, drawString(Graphics2D,String,float,float,long,int,Color)
canDisplayEchar(int)
, drawEstring(Graphics2D,String,float,float,long,int,Color)
Field Summary | |
---|---|
static double |
AFM_SCALE
Default coordinate scaling factor. |
protected java.awt.geom.AffineTransform |
at_
|
static int |
FLAG_ALLCAP
|
static int |
FLAG_CONDENSED
Condensed (narrow) (non-Adobe). |
static int |
FLAG_DEFAULT
|
static int |
FLAG_EXPANDED
Expanded (wide) (non-Adobe). |
static int |
FLAG_FIXEDPITCH
|
static int |
FLAG_FORCEBOLD
Force boldface even at small point sizes. |
static int |
FLAG_ITALIC
|
static int |
FLAG_NONE
|
static int |
FLAG_NONSYMBOLIC
Standard Latin character set. |
static int |
FLAG_ORNAMENTAL
Ornamental (non-Adobe). |
static int |
FLAG_SANSSERIF
Opposite of FLAG_SERIF . |
static int |
FLAG_SCRIPT
|
static int |
FLAG_SERIF
|
static int |
FLAG_SMALLCAP
|
static int |
FLAG_SYMBOLIC
Not exactly standard Latin; though could be close. |
static long |
LAYOUT_FALLBACK
Allow font fallback, if in Unicode. |
static long |
LAYOUT_KERN
|
static long |
LAYOUT_LIGATURE
|
static long |
LAYOUT_MINIMUM
Convenience: Minimum formatting necessary for correctness: formatting (tab, softhyphen), (only) necessary ligatures (as in Arabic), font fallback. |
static long |
LAYOUT_NONE
Do no layout: map every character to a separate glyph, if possible, including control, formatting, and combining marks code points. |
static long |
LAYOUT_NORMAL
Convenience: Usual text display, including fallback, ligatures and kerning. |
static long |
LAYOUT_SMALLCAPS
|
static long |
LAYOUT_SWASH
|
static com.pt.lang.UnicodeBlocks[] |
MASKS_NONE
|
protected java.awt.geom.Rectangle2D |
max_
|
static int |
MODE_ADD
Add text to path for clipping. |
static int |
MODE_FILL
Fill text [usual]. |
static int |
MODE_FILL_ADD
Fill text and add to path for clipping. |
static int |
MODE_FILL_STROKE
Fill, then stroke, text. |
static int |
MODE_FILL_STROKE_ADD
Fill, then stroke, text and add to path for clipping. |
static int |
MODE_INVALID
|
static int |
MODE_INVISIBLE
Neither fill nor stroke text (invisible) [used in scanned paper]. |
static int |
MODE_STROKE
Stroke text [outline]. |
static int |
MODE_STROKE_ADD
Stroke text and add to path for clipping. |
static java.lang.String |
NOTDEF
|
static char |
NOTDEF_CHAR
|
static char |
NOTVALID_CHAR
|
static int |
RIGHT_BITMAP
Bitmap embedding only. |
static int |
RIGHT_EDITABLE
Editable embedding. |
static int |
RIGHT_HEURISTIC
Rights not directly available to programmatically, and so were heuristically estimated, as by scanning text for legal language. |
static int |
RIGHT_INSTALL
Installable Embedding. |
static int |
RIGHT_LICENSED
Fonts subject to a licensing agreement are legally protected or licensed. |
static int |
RIGHT_NONCOMMERCIAL
Right to use for non-commercial purposes. |
static int |
RIGHT_NOSUBSET
No subsetting. |
static int |
RIGHT_PREVIEW_PRINT
Print and preview embedding. |
static int |
RIGHT_RESTRICTED
Font (if only this bit set) must not be modified, embedded or exchanged in any manner without first obtaining permission of the legal owner. |
static int |
RIGHT_UNKNOWN
Rights could not be determined programmatically from font data. |
protected float |
size_
|
static java.lang.String |
SUBFORMAT_NONE
|
protected com.pt.awt.font.CMap |
touni_
|
static int |
WEIGHT_BLACK
Black (aka Heavy) |
static int |
WEIGHT_BOLD
Bold |
static int |
WEIGHT_EXTRABOLD
Extra-Bold (aka Ultra-bold) |
static int |
WEIGHT_EXTRALIGHT
Extra-light (aka Ultra-light) |
static int |
WEIGHT_LIGHT
Light |
static int |
WEIGHT_MEDIUM
Medium |
static int |
WEIGHT_NORMAL
Normal (aka Regular) |
static int |
WEIGHT_SEMIBOLD
Semi-bold (aka Demi-bold) |
static int |
WEIGHT_THIN
Thin |
Constructor Summary | |
---|---|
protected |
NFont(java.net.URL source)
Constructor, with source of font data, which may be null . |
Method Summary | |
---|---|
boolean |
canDisplay(int codepoint)
Can the Unicode codepoint be rendered? |
abstract boolean |
canDisplayEchar(int ech)
Can the character ech in the font's encoding be rendered? |
java.awt.geom.Point2D |
charAdvance(int codepoint)
|
NFont |
deriveFont(java.awt.geom.AffineTransform at)
Transform all glyphs by arbitrary affine transform. |
NFont |
deriveFont(float pointsize)
Creates font a new pointsize in pixels. |
abstract void |
drawEstring(java.awt.Graphics2D g,
java.lang.String estr,
float x,
float y,
long layout,
int mode,
java.awt.Color strokecolor)
Draws string str in font's encoding at (x,y) in drawing mode mode. |
void |
drawString(java.awt.Graphics2D g,
java.lang.String uni,
float x,
float y)
Convenience method for drawing string in fill mode . |
void |
drawString(java.awt.Graphics2D g,
java.lang.String uni,
float x,
float y,
long layout,
int mode,
java.awt.Color strokecolor)
Translates Unicode string uni to this font's encoding and invokes drawEstring(Graphics2D, String, float, float, long,int, Color) . |
abstract java.awt.geom.Point2D |
echarAdvance(int ech)
|
java.awt.geom.Point2D |
estringAdvance(java.lang.String estr,
int beginIndex,
int limit)
|
java.lang.String |
fromUnicode(java.lang.String unicode)
Translates Unicode characters into current encoding. |
float |
getAscent()
Returns design ascent of glyphs above baseline (usually a negative number, which is up in Java2D coordinate space). |
java.lang.String |
getCopyright()
Returns copyright, or empty string if unknown. |
float |
getDescent()
Returns maximum descent of glyphs below baseline. |
java.lang.String |
getDesigner()
Returns name of font's designer, or empty string if unknown. |
java.awt.geom.Rectangle2D |
getEstringBounds(java.lang.String estr,
int beginIndex,
int limit)
|
abstract java.lang.String |
getFamily()
Returns name of font, such as "Times". |
int |
getFlags()
Returns additional flags bit mask, such as FLAG_ITALIC and FLAG_FIXEDPITCH . |
abstract java.lang.String |
getFormat()
Returns primary format, such as "Type1" or "OpenType". |
float |
getHeight()
Returns design height of glyphs. |
static NFont |
getInstance(java.lang.String family,
int weight,
int flags,
float size)
Given family name (such as Times ), weight and flags , returns best matching font, at point size size pixels. |
float |
getLeading()
Returns recommended leading, for single spacing. |
static java.util.logging.Logger |
getLogger()
Interesting events are logged to this logger |
abstract java.awt.geom.Rectangle2D |
getMaxCharBounds()
Returns left in rectangle's x, ascent in y, width in width, height in height. |
int |
getMaxGlyphNum()
Returns highest glyph index + 1, which may be larger than getNumGlyphs() if some "slots" are empty. |
protected static com.pt.io.RandomAccessMultiplex |
getMultiplex()
Returns file descriptor multiplexer shared among all NFont s. |
abstract java.lang.String |
getName()
Returns the PostScript name of font, such as "Times-Roman". |
abstract int |
getNumGlyphs()
Returns number of glyphs defined in font. |
int |
getRights()
Returns font usage rights bit mask. |
float |
getSize()
Returns size in pixels. |
java.net.URL |
getSource()
Returns font's source file or URL, which is usually a file, or null if font was created from byte[] or other non-addressible source. |
abstract char |
getSpaceEchar()
Returns the character that seems to be used as a space in the current encoding, or NOTDEF_CHAR if no such character. |
java.awt.geom.Rectangle2D |
getStringBounds(java.lang.String str)
Logical origin, ascent, advance, and height (includes leading). |
java.awt.geom.Rectangle2D |
getStringBounds(java.lang.String str,
int beginIndex,
int limit)
|
java.lang.String |
getSubformat()
Returns secondary format, such as "CFF/CID" under primary format "CFF". |
java.awt.geom.AffineTransform |
getTransform()
Returns a copy of the transform associated with this NFont . |
com.pt.lang.UnicodeBlocks[] |
getUnicode()
Returns Unicode ranges for which font has various levels of coverage: [0] = existence (at least one glyph), [1] = "good" coverage (of visible glyphs), and [2] = full coverage. |
java.lang.String |
getVersion()
Returns version of font, or empty string if there is no version or it is not applicable. |
int |
getWeight()
Returns weight, such as WEIGHT_BOLD . |
boolean |
isHinted()
Returns true iff font has hinted outlines, which in Type 1 and TrueType is a sign of higher quality. |
boolean |
isTransformed()
Returns whether the affine transform is the identity transform without creating a copy. |
static boolean |
isUseBitmaps()
|
void |
setManager(com.pt.awt.font.NFontManager fm)
Sets the font's manager, or null for none. |
static void |
setUseBitmaps(boolean b)
To increase performance, some subclasses may cached glyphs as bitmaps, and in accelerated video memory in Java 5 and later. |
static java.lang.String |
strFlags(int flags)
Decodes flag bit positions into humand-readable string. |
java.awt.geom.Point2D |
stringAdvance(java.lang.String uni)
|
java.awt.geom.Point2D |
stringAdvance(java.lang.String uni,
int beginIndex,
int limit)
|
static java.lang.String |
strRights(int rights)
|
static java.lang.String |
strWeight(int weight)
|
java.lang.String |
toString()
|
java.lang.String |
toUnicode(java.lang.String encoded)
Translates characters in current encoding into Unicode. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int FLAG_NONE
public static final int FLAG_FIXEDPITCH
public static final int FLAG_SERIF
public static final int FLAG_SANSSERIF
FLAG_SERIF
.
public static final int FLAG_SYMBOLIC
FLAG_NONSYMBOLIC
.
public static final int FLAG_SCRIPT
public static final int FLAG_NONSYMBOLIC
public static final int FLAG_ITALIC
public static final int FLAG_ALLCAP
public static final int FLAG_SMALLCAP
public static final int FLAG_FORCEBOLD
public static final int FLAG_CONDENSED
public static final int FLAG_EXPANDED
public static final int FLAG_ORNAMENTAL
public static final int FLAG_DEFAULT
public static final int WEIGHT_THIN
public static final int WEIGHT_EXTRALIGHT
public static final int WEIGHT_LIGHT
public static final int WEIGHT_NORMAL
public static final int WEIGHT_MEDIUM
public static final int WEIGHT_SEMIBOLD
public static final int WEIGHT_BOLD
public static final int WEIGHT_EXTRABOLD
public static final int WEIGHT_BLACK
public static final int MODE_FILL
public static final int MODE_STROKE
public static final int MODE_FILL_STROKE
public static final int MODE_INVISIBLE
public static final int MODE_FILL_ADD
public static final int MODE_STROKE_ADD
public static final int MODE_FILL_STROKE_ADD
public static final int MODE_ADD
public static final int MODE_INVALID
public static final int RIGHT_INSTALL
public static final int RIGHT_LICENSED
public static final int RIGHT_RESTRICTED
public static final int RIGHT_PREVIEW_PRINT
public static final int RIGHT_EDITABLE
public static final int RIGHT_NOSUBSET
public static final int RIGHT_BITMAP
public static final int RIGHT_NONCOMMERCIAL
public static final int RIGHT_HEURISTIC
public static final int RIGHT_UNKNOWN
public static final long LAYOUT_NONE
public static final long LAYOUT_FALLBACK
public static final long LAYOUT_LIGATURE
public static final long LAYOUT_SMALLCAPS
public static final long LAYOUT_SWASH
public static final long LAYOUT_KERN
public static final long LAYOUT_MINIMUM
public static final long LAYOUT_NORMAL
public static final com.pt.lang.UnicodeBlocks[] MASKS_NONE
public static final java.lang.String SUBFORMAT_NONE
public static final java.lang.String NOTDEF
public static final char NOTDEF_CHAR
public static final char NOTVALID_CHAR
public static final double AFM_SCALE
protected com.pt.awt.font.CMap touni_
protected float size_
protected java.awt.geom.AffineTransform at_
protected java.awt.geom.Rectangle2D max_
Constructor Detail |
---|
protected NFont(java.net.URL source)
null
.
Method Detail |
---|
public static NFont getInstance(java.lang.String family, int weight, int flags, float size)
Times
), weight
and flags
, returns best matching font, at point size size pixels.
Font has Unicode encoding, if possible; font can be recoded.
Uses system font manager to find font files in file system and match to requested.
public static void setUseBitmaps(boolean b)
-Dfont.usebitmaps=true
.
public static boolean isUseBitmaps()
public NFont deriveFont(float pointsize)
deriveFont
methods use this to make a clone and might make subsequent changes.
public NFont deriveFont(java.awt.geom.AffineTransform at)
public abstract java.lang.String getName()
public abstract java.lang.String getFamily()
public java.net.URL getSource()
null
if font was created from byte[]
or other non-addressible source.
public java.lang.String getVersion()
public java.lang.String getDesigner()
public java.lang.String getCopyright()
public int getRights()
public abstract java.lang.String getFormat()
public java.lang.String getSubformat()
public abstract int getNumGlyphs()
public int getMaxGlyphNum()
getNumGlyphs()
if some "slots" are empty.
public com.pt.lang.UnicodeBlocks[] getUnicode()
public boolean isHinted()
true
iff font has hinted outlines, which in Type 1 and TrueType is a sign of higher quality.
public float getSize()
public int getWeight()
WEIGHT_BOLD
.
public int getFlags()
FLAG_ITALIC
and FLAG_FIXEDPITCH
.
public java.awt.geom.AffineTransform getTransform()
NFont
.
public boolean isTransformed()
public void setManager(com.pt.awt.font.NFontManager fm)
null
for none.
public java.lang.String toUnicode(java.lang.String encoded)
public java.lang.String fromUnicode(java.lang.String unicode)
NOTDEF_CHAR
is returned.
public abstract char getSpaceEchar()
NOTDEF_CHAR
if no such character.
public java.awt.geom.Point2D stringAdvance(java.lang.String uni)
public java.awt.geom.Point2D stringAdvance(java.lang.String uni, int beginIndex, int limit)
public java.awt.geom.Point2D estringAdvance(java.lang.String estr, int beginIndex, int limit)
public java.awt.geom.Point2D charAdvance(int codepoint)
public abstract java.awt.geom.Point2D echarAdvance(int ech)
public java.awt.geom.Rectangle2D getStringBounds(java.lang.String str)
public java.awt.geom.Rectangle2D getStringBounds(java.lang.String str, int beginIndex, int limit)
public java.awt.geom.Rectangle2D getEstringBounds(java.lang.String estr, int beginIndex, int limit)
public abstract java.awt.geom.Rectangle2D getMaxCharBounds()
public float getHeight()
public float getAscent()
public float getDescent()
public float getLeading()
public boolean canDisplay(int codepoint)
public abstract boolean canDisplayEchar(int ech)
public void drawString(java.awt.Graphics2D g, java.lang.String uni, float x, float y)
fill mode
.
public void drawString(java.awt.Graphics2D g, java.lang.String uni, float x, float y, long layout, int mode, java.awt.Color strokecolor)
drawEstring(Graphics2D, String, float, float, long,int, Color)
.
Note that some fonts contain characters without Unicode mappings and therefore cannot be shown with this method;
in that case, use drawEstring(Graphics2D, String, float, float, long,int, Color)
.
If the font cannot display the Unicode characters and it is managed by a font manager
(which it is ordinarily)
then drawing will try to find the Unicode glyphs in other fonts in the font manager.
public abstract void drawEstring(java.awt.Graphics2D g, java.lang.String estr, float x, float y, long layout, int mode, java.awt.Color strokecolor)
RenderingHints.KEY_ANTIALIASING
hint on the Graphics2D
.
public static java.lang.String strFlags(int flags)
public static java.lang.String strWeight(int weight)
public static java.lang.String strRights(int rights)
public java.lang.String toString()
toString
in class java.lang.Object
protected static com.pt.io.RandomAccessMultiplex getMultiplex()
NFont
s.
Applications can use many fonts, requiring many file descriptors.
Fonts should share file descriptors, taking as needed and releasing when possible, so as not to exhaust the system.
public static java.util.logging.Logger getLogger()
Level.CONFIG
font path, fonts found;
Level.FINE
font creation.
|
Multivalent API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |