geomerative
Class RFont

java.lang.Object
  extended by 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 acces their geometry.


Field Summary
 int align
          The alignement 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
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Constructor Summary
RFont(java.lang.String fontPath)
           
RFont(java.lang.String fontPath, int size)
           
RFont(java.lang.String fontPath, int size, int align)
          The constructor of the RFont object.
 
Method Summary
 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()
           
 void setAlign(int align)
          Use this method to reset the alignement 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)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

public int size
The point size of the font.


align

public int align
The alignement of the font. This proprety can take the following values: RFont.LEFT, RFont.CENTER and RFont.RIGHT


forceAscii

public boolean forceAscii
Should we try to use ASCII, rather than Unicode?

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.

setAlign

public void setAlign(int align)
              throws java.lang.RuntimeException
Use this method to reset the alignement of the font. This proprety 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 drawn
g - 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 drawn
g - 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 drawn
g - 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 drawn
g - 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


Geomerative by Ricard Marxer, http://www.ricardmarxer.com/geomerative/