   Math/PI*2). Values are returned in the range -1 to 1."
   [angle] (PApplet/cos (float angle)))
 
+(def available-fonts
+  "A sequence of strings representing the fonts on this system
+  available for use.
+
+  Because of limitations in Java, not all fonts can be used and some
+  might work with one operating system and not others. When sharing a
+  sketch with other people or posting it on the web, you may need to
+  include a .ttf or .otf version of your font in the data directory of
+  the sketch because other people might not have the font installed on
+  their computer. Only fonts that can legally be distributed should be
+  included with a sketch."
+  (seq (PFont/list)))
+
+(defn font-available?
+  "Returns true if font (specified as a string) is available on this
+  system, false otherwise"
+  [font-str]
+  (if (some #{font-str} available-fonts)
+    true
+    false))
+
 (defn create-font
-  ([name size] (.createFont *applet* name (float size)))
-  ([name size smooth] (.createFont *applet* name (float size) smooth))
+  "Dynamically converts a font to the format used by Processing (a
+  PFont) from either a font name that's installed on the computer, or
+  from a .ttf or .otf file inside the sketches 'data' folder. This
+  function is an advanced feature for precise control.
+
+  Use available-fonts to obtain the names for the fonts recognized by
+  the computer and are compatible with this function.
+
+  The size parameter states the font size you want to generate. The
+  smooth parameter specifies if the font should be antialiased or not,
+  and the charset parameter is an array of chars that specifies the
+  characters to generate.
+
+  This function creates a bitmapped version of a font It loads a font
+  by name, and converts it to a series of images based on the size of
+  the font. When possible, the text function will use a native font
+  rather than the bitmapped version created behind the scenes with
+  create-font. For instance, when using the default renderer
+  setting (JAVA2D), the actual native version of the font will be
+  employed by the sketch, improving drawing quality and
+  performance. With the P2D, P3D, and OPENGL renderer settings, the
+  bitmapped version will be used. While this can drastically improve
+  speed and appearance, results are poor when exporting if the sketch
+  does not include the .otf or .ttf file, and the requested font is
+  not available on the machine running the sketch."
+  ([name size] (.createFont *applet* (str name) (float size)))
+  ([name size smooth] (.createFont *applet* (str name) (float size) smooth))
   ([name size smooth ^chars charset]
-     (.createFont *applet* name (float size) smooth charset)))
+     (.createFont *applet* (str name) (float size) smooth charset)))
 
 (defn create-graphics
   ([w h renderer]

  [angle]
  (PApplet/tan (float angle)))

(defn char->text
  ([c] (.text *applet* (char c)))
  ([c x y] (.text *applet* (char c) (float x) (float y)))
  ([c x y z] (.text *applet* (char c) (float x) (float y) (float z))))

(defn num->text
  ([num x y] (.text *applet* (float num) (float x) (float y)))
  ([num x y z] (.text *applet* (float num) (float x) (float y) (float z))))

(defn string->text
  ([^String s] (.text *applet* s))
  ([^String s x y] (.text *applet* s (float x) (float y)))
  ([^String s x y z] (.text *applet* s (float x) (float y) (float z))))

(defn string->text-in
  ([^String s x1 y1 x2 y2]
     (.text *applet* s (float x1) (float y1) (float x2) (float y2)))
  ([^String s x1 y1 x2 y2 z]
     (.text *applet* s (float x1) (float y1) (float x2) (float y2) (float z))))

(defn text-align
  ([align] (.textAlign *applet* (int align)))
  ([align-x align-y] (.textAlign *applet* (int align-x) (int align-y))))

(defn text-ascent [] (.textAscent *applet*))

(defn text-descend [] (.textDescent *applet*))

(defn text-font
  ([^PFont which] (.textFont *applet* which))
  ([^PFont which size] (.textFont *applet* which (int size))))

(defn text-leading [leading] (.textLeading *applet* (float leading)))

(defn text-mode [mode] (.textMode *applet* (int mode)))

(defn text-size [size] (.textSize *applet* (float size)))

(defn texture [^PImage img] (.texture *applet* img))



(defn load-bytes [filename] (PApplet/loadBytes filename))

(defn load-font
  "Loads a font into a variable of type PFont. To load correctly,
  fonts must be located in the data directory of the current sketch.
  To create a font to use with Processing use the create-font fn.

  Like load-image and other methods that load data, the load-font fn
  should not be used inside draw, because it will slow down the sketch
  considerably, as the font will be re-loaded from the disk (or
  network) on each frame.

  For most renderers, Processing displays fonts using the .vlw font
  format, which uses images for each letter, rather than defining them
  through vector data. When hint :enable-native-fonts is used with the
  JAVA2D renderer, the native version of a font will be used if it is
  installed on the user's machine.

  Using create-font (instead of load-font) enables vector data to be
  used with the JAVA2D (default) renderer setting. This can be helpful
  when many font sizes are needed, or when using any renderer based on
  JAVA2D, such as the PDF library."
  [filename]
  (.loadFont *applet*  (str filename)))

(defn load-image [filename] (.loadImage *applet* filename))

