package fontforge-of-ocaml

  1. Overview
  2. Docs

GlyphPen Protocol to draw into a Glyph You create a glyphPen with the GlyphPen function of a glyph. You then draw into it with the functions below. API: complete (compared to the Python API); a finalize function has been added.

type t

Abstract type for glyph pens.

Python workarounds

val finalize : t -> unit

Finalize the pen (equivalent to pen = None at the Python side). This tells FontForge that the drawing is done and causes it to refresh the display (if a UI is active). Note: nothing is performed in the OCaml implementation

Methods

val moveTo : x:int -> y:int -> t -> unit

With one exception this call begins every contour and creates an on curve point at (x,y) as the start point of that contour. This should be the first call after a pen has been created and the call that follows a closePath, endPath.

val moveToCoord : coord -> t -> unit

With one exception this call begins every contour and creates an on curve point at (x,y) as the start point of that contour. This should be the first call after a pen has been created and the call that follows a closePath, endPath.

Idem moveTo with float coords.

val lineTo : x:int -> y:int -> t -> unit

Idem moveTo with float coords.

Draws a line from the last point to (x,y) and adds that to the contour.

val lineToCoord : coord -> t -> unit

Draws a line from the last point to (x,y) and adds that to the contour.

Idem lineTo with float coords.

val curveTo : cp1:coord -> ?cp2:coord -> pt:coord -> t -> unit

Idem lineTo with float coords.

This routine has slightly different arguments depending on the type of the font. When drawing into a cubic font (PostScript) use the first set of arguments (with two control points -- off curve points -- between each on curve point). When drawing into a quadratic font (TrueType) use the second format (when the optional cp2 is specified) with one control point between adjacent on-curve points. The standard appears to support super-bezier curves with more than two control points between on-curve points. FontForge does not. Nor does FontForge allow you to draw a quadratic spline into a cubic font, nor vice versa.

val qcurveTo : cps:coord list -> ?pt:coord -> t -> unit

This routine has slightly different arguments depending on the type of the font. When drawing into a cubic font (PostScript) use the first set of arguments (with two control points -- off curve points -- between each on curve point). When drawing into a quadratic font (TrueType) use the second format (when the optional cp2 is specified) with one control point between adjacent on-curve points. The standard appears to support super-bezier curves with more than two control points between on-curve points. FontForge does not. Nor does FontForge allow you to draw a quadratic spline into a cubic font, nor vice versa.

This routine may only be used in quadratic (TrueType) fonts and has two different formats. It is used to express the TrueType idiom where an on-curve point mid-way between its control points may be omitted, leading to a run of off-curve points (with implied but unspecified on-curve points between them). The first format (when the optional pt is specified) allows an arbetary number of off-curve points followed by one on-curve point. It is possible to have a contour which consists solely of off-curve points. When this happens the contour is NOT started with a moveTo, instead the entire contour, all the off curve points, are listed in one call, and the argument list is terminated by a None to indicate there are no on-curve points.

val closePath : t -> unit

This routine may only be used in quadratic (TrueType) fonts and has two different formats. It is used to express the TrueType idiom where an on-curve point mid-way between its control points may be omitted, leading to a run of off-curve points (with implied but unspecified on-curve points between them). The first format (when the optional pt is specified) allows an arbetary number of off-curve points followed by one on-curve point. It is possible to have a contour which consists solely of off-curve points. When this happens the contour is NOT started with a moveTo, instead the entire contour, all the off curve points, are listed in one call, and the argument list is terminated by a None to indicate there are no on-curve points.

Closes the contour (connects the last point to the first point to make a loop) and ends it.

val endPath : t -> unit

Closes the contour (connects the last point to the first point to make a loop) and ends it.

Ends the contour without closing it. This is only relevant if you are stroking contours.

val addComponent : glyphname:string -> transform:PsMat.t -> t -> unit

Ends the contour without closing it. This is only relevant if you are stroking contours.

Adds a reference (a component) to the glyph. The PostScript transformation matrix is a 6 element tuple.