Package geomerative
Class RFont
- java.lang.Object
-
- geomerative.RFont
-
- All Implemented Interfaces:
processing.core.PConstants
public class RFont extends java.lang.Object implements processing.core.PConstants
RShape is a reduced interface for creating, holding and drawing text from TrueType Font files. It's a basic interpreter of TrueType fonts enabling to access any String in the form of a group of shapes. Enabling us in this way to access their geometry.
-
-
Field Summary
Fields Modifier and Type Field Description int
align
The alignment of the font.boolean
forceAscii
Should we try to use ASCII, rather than Unicode?int
size
The point size of the font.-
Fields inherited from interface processing.core.PConstants
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
draw(char character)
void
draw(char character, processing.core.PApplet g)
Use this method to draw a character on a certain canvas.void
draw(char character, processing.core.PGraphics g)
Use this method to draw a character on a certain canvas.void
draw(java.lang.String text)
void
draw(java.lang.String text, processing.core.PApplet g)
Use this method to draw a character on a certain canvas.void
draw(java.lang.String text, processing.core.PGraphics g)
Use this method to draw a character on a certain canvas.java.lang.String
getFamily()
float
getLineSpacing()
void
setAlign(int align)
Use this method to reset the alignment of the font.void
setSize(int size)
Use this method to reset the point size of the font.RGroup
toGroup(java.lang.String text)
Use this method to get the outlines of a string in the form of an RGroup.RPolygon
toPolygon(char character)
Use this method to get the outlines of a character in the form of an RPolygon.RShape
toShape(char character)
Use this method to get the outlines of a character in the form of an RShape.RShape
toShape(java.lang.String text)
-
-
-
Constructor Detail
-
RFont
public RFont(java.lang.String fontPath, int size, int align) throws java.lang.RuntimeException
The constructor of the RFont object. Use this in order to create a font with which we will be able to draw and obtain outlines of text.- Parameters:
fontPath
- String, the name of the TrueType Font file which should be situated in the data folder of the sketch.size
- int, the point size of the font in points.align
- int, this can only take the following values: RFont.LEFT, RFont.CENTER and RFont.RIGHT.- Throws:
java.lang.RuntimeException
-
RFont
public RFont(java.lang.String fontPath, int size) throws java.lang.RuntimeException
- Throws:
java.lang.RuntimeException
-
RFont
public RFont(java.lang.String fontPath) throws java.lang.RuntimeException
- Throws:
java.lang.RuntimeException
-
-
Method Detail
-
setSize
public void setSize(int size)
Use this method to reset the point size of the font.- Parameters:
size
- int, the point size of the font in points.
-
getLineSpacing
public float getLineSpacing()
-
setAlign
public void setAlign(int align) throws java.lang.RuntimeException
Use this method to reset the alignment of the font. This property can take the following values: RFont.LEFT, RFont.CENTER and RFont.RIGHT- Parameters:
align
- int, this can only take the following values: RFont.LEFT, RFont.CENTER and RFont.RIGHT.- Throws:
java.lang.RuntimeException
-
getFamily
public java.lang.String getFamily()
-
toShape
public RShape toShape(char character)
Use this method to get the outlines of a character in the form of an RShape.- Parameters:
character
- char, the character we want the outline from.- Returns:
- RShape, the outline of the character.
-
toPolygon
public RPolygon toPolygon(char character)
Use this method to get the outlines of a character in the form of an RPolygon.- Parameters:
character
- char, the character we want the outline from.- Returns:
- RPolygon, the outline of the character.
-
toGroup
public RGroup toGroup(java.lang.String text) throws java.lang.RuntimeException
Use this method to get the outlines of a string in the form of an RGroup. All the elements of the group will be RShapes.- Parameters:
text
- String, the string we want the outlines from.- Returns:
- RGroup, the group of outlines of the character. All the elements are RShapes.
- Throws:
java.lang.RuntimeException
-
toShape
public RShape toShape(java.lang.String text) throws java.lang.RuntimeException
- Throws:
java.lang.RuntimeException
-
draw
public void draw(char character, processing.core.PGraphics g) throws java.lang.RuntimeException
Use this method to draw a character on a certain canvas.- Parameters:
character
- the character to be drawng
- the canvas where to draw- Throws:
java.lang.RuntimeException
-
draw
public void draw(java.lang.String text, processing.core.PGraphics g) throws java.lang.RuntimeException
Use this method to draw a character on a certain canvas.- Parameters:
text
- the string to be drawng
- the canvas where to draw- Throws:
java.lang.RuntimeException
-
draw
public void draw(char character, processing.core.PApplet g) throws java.lang.RuntimeException
Use this method to draw a character on a certain canvas.- Parameters:
character
- char, the character to be drawng
- the canvas where to draw- Throws:
java.lang.RuntimeException
-
draw
public void draw(java.lang.String text, processing.core.PApplet g) throws java.lang.RuntimeException
Use this method to draw a character on a certain canvas.- Parameters:
text
- the string to be drawng
- the canvas where to draw- Throws:
java.lang.RuntimeException
-
draw
public void draw(java.lang.String text) throws java.lang.RuntimeException
- Throws:
java.lang.RuntimeException
-
draw
public void draw(char character) throws java.lang.RuntimeException
- Throws:
java.lang.RuntimeException
-
-