|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object processing.core.PFont
public class PFont
Grayscale bitmap font class used by Processing.
Awful (and by that, I mean awesome) ascii (non)art for how this works:
| | height is the full used height of the image | | ..XX.. } | ..XX.. } | ...... } | XXXX.. } topExtent (top y is baseline - topExtent) | ..XX.. } | ..XX.. } dotted areas are where the image data | ..XX.. } is actually located for the character +---XXXXXX---- } (it extends to the right and down | for power of two texture sizes) ^^^^ leftExtent (amount to move over before drawing the image ^^^^^^^^^^^^^^ setWidth (width displaced by char)
Field Summary | |
---|---|
int |
ascent
|
int |
charCount
|
static char[] |
DEFAULT_CHARSET
The default Processing character set. |
int |
descent
|
int[] |
height
|
PImage[] |
images
|
int[] |
leftExtent
|
int |
mbox2
next power of 2 over the max image size (usually 64) |
java.lang.String |
name
Name of the font as seen by Java when it was created. |
java.lang.String |
psname
Postscript name of the font that this bitmap was created from. |
int[] |
setWidth
|
int |
size
"natural" size of the font (most often 48) |
boolean |
smooth
true if smoothing was enabled for this font, used for native impl |
int |
theight
texture height, same as mbox2, but reserved for future use |
int[] |
topExtent
|
int |
twidth
texture width, same as mbox2, but reserved for future use |
int[] |
value
|
int[] |
width
|
Constructor Summary | |
---|---|
PFont()
|
|
PFont(java.awt.Font font,
boolean smooth,
char[] charset)
Create a new image-based font on the fly. |
|
PFont(java.io.InputStream input)
|
Method Summary | |
---|---|
float |
ascent()
Returns the ascent of this font from the baseline. |
float |
descent()
Returns how far this font descends from the baseline. |
java.awt.Font |
findFont()
Attempt to find the native version of this font. |
static java.awt.Font |
findFont(java.lang.String name)
Starting with Java 1.5, Apple broke the ability to specify most fonts. |
java.awt.Font |
getFont()
Return the native java.awt.Font associated with this PFont (if any). |
int |
index(char c)
Get index for the char (convert from unicode to bagel charset). |
float |
kern(char a,
char b)
Currently un-implemented for .vlw fonts, but honored for layout in case subclasses use it. |
static java.lang.String[] |
list()
Get a list of the fonts installed on the system that can be used by Java. |
static void |
loadFonts()
|
void |
save(java.io.OutputStream output)
Write this PFont to an OutputStream. |
void |
setFont(java.awt.Font font)
Set the native complement of this font. |
float |
width(char c)
Width of this character for a font of size 1. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int charCount
public PImage[] images
public java.lang.String name
public java.lang.String psname
public int size
public boolean smooth
public int mbox2
public int twidth
public int theight
public int[] value
public int[] height
public int[] width
public int[] setWidth
public int[] topExtent
public int[] leftExtent
public int ascent
public int descent
public static char[] DEFAULT_CHARSET
This is the union of the Mac Roman and Windows ANSI (CP1250) character sets. ISO 8859-1 Latin 1 is Unicode characters 0x80 -> 0xFF, and would seem a good standard, but in practice, most P5 users would rather have characters that they expect from their platform's fonts.
This is more of an interim solution until a much better font solution can be determined. (i.e. create fonts on the fly from some sort of vector format).
Not that I expect that to happen.
Constructor Detail |
---|
public PFont()
public PFont(java.io.InputStream input) throws java.io.IOException
java.io.IOException
public PFont(java.awt.Font font, boolean smooth, char[] charset)
font
- the font object to create fromcharset
- array of all unicode chars that should be includedsmooth
- true to enable smoothing/anti-aliasingMethod Detail |
---|
public void setFont(java.awt.Font font)
public java.awt.Font getFont()
public java.awt.Font findFont()
public void save(java.io.OutputStream output) throws java.io.IOException
This is used by the Create Font tool, or whatever anyone else dreams up for messing with fonts themselves.
It is assumed that the calling class will handle closing the stream when finished.
java.io.IOException
public int index(char c)
public float kern(char a, char b)
public float ascent()
public float descent()
public float width(char c)
public static java.lang.String[] list()
Not recommended for use in applets, but this is implemented in PFont because the Java methods to access this information have changed between 1.1 and 1.4, and the 1.4 method is typical of the sort of undergraduate-level over-abstraction that the seems to have made its way into the Java API after 1.1.
public static void loadFonts()
public static java.awt.Font findFont(java.lang.String name)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |