public class PFont extends Object implements PConstants
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)
Modifier and Type | Class and Description |
---|---|
class |
PFont.Glyph
A single character, and its visage.
|
Modifier and Type | Field and Description |
---|---|
static char[] |
CHARSET
The default Processing character set.
|
ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ASYNC_SAVEFRAME, DISABLE_BUFFER_READING, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_KEY_REPEAT, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_ASYNC_SAVEFRAME, ENABLE_BUFFER_READING, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_KEY_REPEAT, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ESC, EXCLUSION, FX2D, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADRATIC_VERTEX, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPAN, SPHERE, SPOT, SQUARE, SUBTRACT, SVG, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z
Constructor and Description |
---|
PFont() |
PFont(Font font,
boolean smooth)
( begin auto-generated from PFont.xml )
PFont is the font class for Processing.
|
PFont(Font font,
boolean smooth,
char[] charset)
Create a new image-based font on the fly.
|
PFont(Font font,
boolean smooth,
char[] charset,
boolean stream,
int density)
Adds an additional parameter that indicates the font came from a file,
not a built-in OS font.
|
PFont(InputStream input) |
Modifier and Type | Method and Description |
---|---|
float |
ascent()
Returns the ascent of this font from the baseline.
|
float |
descent()
Returns how far this font descends from the baseline.
|
static Font |
findFont(String name)
Starting with Java 1.5, Apple broke the ability to specify most fonts.
|
Object |
findNative()
Attempt to find the native version of this font.
|
int |
getDefaultSize()
Returns the size that will be used when textFont(font) is called.
|
Font |
getFont()
Deprecated.
|
PFont.Glyph |
getGlyph(char c) |
PFont.Glyph |
getGlyph(int i) |
int |
getGlyphCount() |
String |
getName() |
Object |
getNative()
Return the native java.awt.Font associated with this PFont (if any).
|
String |
getPostScriptName() |
PShape |
getShape(char ch) |
PShape |
getShape(char ch,
float detail) |
int |
getSize()
Return size of this font.
|
boolean |
isSmooth() |
boolean |
isStream() |
float |
kern(char a,
char b)
Currently un-implemented for .vlw fonts,
but honored for layout in case subclasses use it.
|
static String[] |
list()
( begin auto-generated from PFont_list.xml )
Gets a list of the fonts installed on the system.
|
static void |
loadFonts()
Make an internal list of all installed fonts.
|
void |
save(OutputStream output)
Write this PFont to an OutputStream.
|
void |
setNative(Object font)
Set the native complement of this font.
|
void |
setSubsetting() |
float |
width(char c)
Width of this character for a font of size 1.
|
public static char[] 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.
public PFont()
public PFont(Font font, boolean smooth)
font
- font the font object to create fromsmooth
- smooth true to enable smoothing/anti-aliasingpublic PFont(Font font, boolean smooth, char[] charset)
charset
- array of all unicode chars that should be includedpublic PFont(Font font, boolean smooth, char[] charset, boolean stream, int density)
public PFont(InputStream input) throws IOException
input
- InputStreamIOException
public void save(OutputStream output) throws 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.
IOException
public String getName()
public String getPostScriptName()
public void setNative(Object font)
@Deprecated public Font getFont()
public Object getNative()
public int getSize()
public int getDefaultSize()
public boolean isSmooth()
public boolean isStream()
public void setSubsetting()
public Object findNative()
public PFont.Glyph getGlyph(char c)
public float kern(char a, char b)
public float ascent()
public float descent()
public float width(char c)
public int getGlyphCount()
public PFont.Glyph getGlyph(int i)
public PShape getShape(char ch)
public PShape getShape(char ch, float detail)
public static String[] list()
public static void loadFonts()
public static Font findFont(String name)