Top Description Fields Constructors Methods
jogamp.graph.font.typecast.t2

public Class T2Interpreter

extends Object
Class Inheritance
Imports
java.util.ArrayList, jogamp.graph.font.typecast.ot.Point, jogamp.graph.font.typecast.ot.table.CharstringType2

Type 2 Charstring Interpreter. Operator descriptions are quoted from Adobe's Type 2 Charstring Format document -- 5117.Type2.pdf.
Author
David Schweinsberg
Version
$Id: T2Interpreter.java,v 1.2 2007-07-26 11:10:18 davidsch Exp $

Field Summary

Modifier and TypeField and Description
private final Number[]
private int
private ArrayList<Point>
private final int[]
private int
private final Number[]
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
T2Interpreter()

Creates a new instance of T2Interpreter

Method Summary

Modifier and TypeMethod and Description
private void
_abs()

Returns the absolute value of num.

private void
_add()

Returns the sum of the two numbers num1 and num2.

private void
_and()

Puts a 1 on the stack if num1 and num2 are both non-zero, and puts a 0 on the stack if either argument is zero.

private void
_callgsubr()

Operates in the same manner as callsubr except that it calls a global subroutine.

private void
_callsubr()

Calls a charstring subroutine with index subr# (actually the subr number plus the subroutine bias number, as described in section 2.3) in the Subrs array.

private void
private void
_div()

Returns the quotient of num1 divided by num2.

private void
_drop()

Removes the top element num from the Type 2 argument stack.

private void
_dup()

Duplicates the top element on the argument stack.

private void
_endchar()

Finishes a charstring outline definition, and must be the last operator in a character's outline.

private void
_eq()

Puts a 1 on the stack if num1 equals num2, otherwise a 0 (zero) is put on the stack.

private void
_exch()

Exchanges the top two elements on the argument stack.

private void
_flex()

Causes two Bezier curves, as described by the arguments (as shown in Figure 2 below), to be rendered as a straight line when the flex depth is less than fd /100 device pixels, and as curved lines when the flex depth is greater than or equal to fd/100 device pixels.

private void
_flex1()

Causes the two curves described by the arguments to be rendered as a straight line when the flex depth is less than 0.5 device pixels, and as curved lines when the flex depth is greater than or equal to 0.5 device pixels.

private void
_get()

Retrieves the value stored in the transient array at the location given by i and pushes the value onto the argument stack.

private void
_hflex()

Causes the two curves described by the arguments dx1...dx6 to be rendered as a straight line when the flex depth is less than 0.5 (that is, fd is 50) device pixels, and as curved lines when the flex depth is greater than or equal to 0.5 device pixels.

private void
_hflex1()

Causes the two curves described by the arguments to be rendered as a straight line when the flex depth is less than 0.5 device pixels, and as curved lines when the flex depth is greater than or equal to 0.5 device pixels.

private void
_hhcurveto()

Appends one or more Bezier curves, as described by the dxa...dxc set of arguments, to the current point.

private void
private void
_hlineto()

Appends a horizontal line of length dx1 to the current point.

private void
_hmoveto()

Moves the current point dx1 units in the horizontal direction.

private void
private void
private void
_hvcurveto()

Appends one or more Bezier curves to the current point.

private void
_ifelse()

Leaves the value s1 on the stack if v1 ?

private void
_index()

Retrieves the element i from the top of the argument stack and pushes a copy of that element onto that stack.

private void
_mul()

Returns the product of num1 and num2.

private void
_neg()

Returns the negative of num.

private void
_not()

Returns a 0 if num1 is non-zero; returns a 1 if num1 is zero.

private void
_or()

Puts a 1 on the stack if either num1 or num2 are non-zero, and puts a 0 on the stack if both arguments are zero.

private void
_put()

Stores val into the transient array at the location given by i.

private void
_random()

Returns a pseudo random number num2 in the range (0,1], that is, greater than zero and less than or equal to one.

private void
_rcurveline()

Is equivalent to one rrcurveto for each set of six arguments dxa...dyc, followed by exactly one rlineto using the dxd, dyd arguments.

private void
_return()

Returns from either a local or global charstring subroutine, and continues execution after the corresponding call(g)subr.

private void
_rlinecurve()

Is equivalent to one rlineto for each pair of arguments beyond the six arguments dxb...dyd needed for the one rrcurveto command.

private void
_rlineto()

Appends a line from the current point to a position at the relative coordinates dxa, dya.

private void
_rmoveto()

Moves the current point to a position at the relative coordinates (dx1, dy1).

private void
_roll()

Performs a circular shift of the elements num(Nx1) ...

private void
_rrcurveto()

Appends a Bezier curve, defined by dxa...dyc, to the current point.

private void
_sqrt()

Returns the square root of num.

private void
_sub()

Returns the result of subtracting num2 from num1.

private void
_vhcurveto()

Appends one or more Bezier curves to the current point, where the first tangent is vertical and the second tangent is horizontal.

private void
_vlineto()

Appends a vertical line of length dy1 to the current point.

private void
_vmoveto()

Moves the current point dy1 units in the vertical direction.

private void
private void
private void
_vvcurveto()

Appends one or more curves to the current point.

private void
clearArg()

Clear the argument stack

private void
curveTo(final int cx1, final int cy1, final int cx2, final int cy2, final int x, final int y)

private void
public Point[]
private int
getArgCount()

The number of arguments on the argument stack

private Point
private void
lineTo(final int x, final int y)

private void
moveTo(final int x, final int y)

private Number
popArg()

Pop a value off the argument stack

private int
popSubr()

Pop a value off the subroutine stack

private void
pushArg(final Number n)

Push a value on to the argument stack

private void
pushSubr(final int n)

Push a value on to the subroutine stack

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_argStackback to summary
private final Number[] _argStack
_argStackIndexback to summary
private int _argStackIndex
_pointsback to summary
private ArrayList<Point> _points
_subrStackback to summary
private final int[] _subrStack
_subrStackIndexback to summary
private int _subrStackIndex
_transientArrayback to summary
private final Number[] _transientArray
ARGUMENT_STACK_LIMITback to summary
private static final int ARGUMENT_STACK_LIMIT
SUBR_STACK_LIMITback to summary
private static final int SUBR_STACK_LIMIT
TRANSIENT_ARRAY_ELEMENT_COUNTback to summary
private static final int TRANSIENT_ARRAY_ELEMENT_COUNT

Constructor Detail

T2Interpreterback to summary
public T2Interpreter()

Creates a new instance of T2Interpreter

Method Detail

_absback to summary
private void _abs()

Returns the absolute value of num.

_addback to summary
private void _add()

Returns the sum of the two numbers num1 and num2.

_andback to summary
private void _and()

Puts a 1 on the stack if num1 and num2 are both non-zero, and puts a 0 on the stack if either argument is zero.

_callgsubrback to summary
private void _callgsubr()

Operates in the same manner as callsubr except that it calls a global subroutine.

_callsubrback to summary
private void _callsubr()

Calls a charstring subroutine with index subr# (actually the subr number plus the subroutine bias number, as described in section 2.3) in the Subrs array. Each element of the Subrs array is a charstring encoded like any other charstring. Arguments pushed on the Type 2 argument stack prior to calling the subroutine, and results pushed on this stack by the subroutine, act according to the manner in which the subroutine is coded. Calling an undefined subr (gsubr) has undefined results.

_cntrmaskback to summary
private void _cntrmask()
_divback to summary
private void _div()

Returns the quotient of num1 divided by num2. The result is undefined if overflow occurs and is zero for underflow.

_dropback to summary
private void _drop()

Removes the top element num from the Type 2 argument stack.

_dupback to summary
private void _dup()

Duplicates the top element on the argument stack.

_endcharback to summary
private void _endchar()

Finishes a charstring outline definition, and must be the last operator in a character's outline.

_eqback to summary
private void _eq()

Puts a 1 on the stack if num1 equals num2, otherwise a 0 (zero) is put on the stack.

_exchback to summary
private void _exch()

Exchanges the top two elements on the argument stack.

_flexback to summary
private void _flex()

Causes two Bezier curves, as described by the arguments (as shown in Figure 2 below), to be rendered as a straight line when the flex depth is less than fd /100 device pixels, and as curved lines when the flex depth is greater than or equal to fd/100 device pixels.

_flex1back to summary
private void _flex1()

Causes the two curves described by the arguments to be rendered as a straight line when the flex depth is less than 0.5 device pixels, and as curved lines when the flex depth is greater than or equal to 0.5 device pixels.

_getback to summary
private void _get()

Retrieves the value stored in the transient array at the location given by i and pushes the value onto the argument stack. If get is executed prior to put for i during execution of the current charstring, the value returned is undefined.

_hflexback to summary
private void _hflex()

Causes the two curves described by the arguments dx1...dx6 to be rendered as a straight line when the flex depth is less than 0.5 (that is, fd is 50) device pixels, and as curved lines when the flex depth is greater than or equal to 0.5 device pixels.

_hflex1back to summary
private void _hflex1()

Causes the two curves described by the arguments to be rendered as a straight line when the flex depth is less than 0.5 device pixels, and as curved lines when the flex depth is greater than or equal to 0.5 device pixels.

_hhcurvetoback to summary
private void _hhcurveto()

Appends one or more Bezier curves, as described by the dxa...dxc set of arguments, to the current point. For each curve, if there are 4 arguments, the curve starts and ends horizontal. The first curve need not start horizontal (the odd argument case). Note the argument order for the odd argument case.

_hintmaskback to summary
private void _hintmask()
_hlinetoback to summary
private void _hlineto()

Appends a horizontal line of length dx1 to the current point. With an odd number of arguments, subsequent argument pairs are interpreted as alternating values of dy and dx, for which additional lineto operators draw alternating vertical and horizontal lines. With an even number of arguments, the arguments are interpreted as alternating horizontal and vertical lines. The number of lines is determined from the number of arguments on the stack.

_hmovetoback to summary
private void _hmoveto()

Moves the current point dx1 units in the horizontal direction.

_hstemback to summary
private void _hstem()
_hstemhmback to summary
private void _hstemhm()
_hvcurvetoback to summary
private void _hvcurveto()

Appends one or more Bezier curves to the current point. The tangent for the first Bezier must be horizontal, and the second must be vertical (except as noted below). If there is a multiple of four arguments, the curve starts horizontal and ends vertical. Note that the curves alternate between start horizontal, end vertical, and start vertical, and end horizontal. The last curve (the odd argument case) need not end horizontal/vertical.

_ifelseback to summary
private void _ifelse()

Leaves the value s1 on the stack if v1 ? v2, or leaves s2 on the stack if v1 > v2. The value of s1 and s2 is usually the biased number of a subroutine.

_indexback to summary
private void _index()

Retrieves the element i from the top of the argument stack and pushes a copy of that element onto that stack. If i is negative, the top element is copied. If i is greater than X, the operation is undefined.

_mulback to summary
private void _mul()

Returns the product of num1 and num2. If overflow occurs, the result is undefined, and zero is returned for underflow.

_negback to summary
private void _neg()

Returns the negative of num.

_notback to summary
private void _not()

Returns a 0 if num1 is non-zero; returns a 1 if num1 is zero.

_orback to summary
private void _or()

Puts a 1 on the stack if either num1 or num2 are non-zero, and puts a 0 on the stack if both arguments are zero.

_putback to summary
private void _put()

Stores val into the transient array at the location given by i.

_randomback to summary
private void _random()

Returns a pseudo random number num2 in the range (0,1], that is, greater than zero and less than or equal to one.

_rcurvelineback to summary
private void _rcurveline()

Is equivalent to one rrcurveto for each set of six arguments dxa...dyc, followed by exactly one rlineto using the dxd, dyd arguments. The number of curves is determined from the count on the argument stack.

_returnback to summary
private void _return()

Returns from either a local or global charstring subroutine, and continues execution after the corresponding call(g)subr.

_rlinecurveback to summary
private void _rlinecurve()

Is equivalent to one rlineto for each pair of arguments beyond the six arguments dxb...dyd needed for the one rrcurveto command. The number of lines is determined from the count of items on the argument stack.

_rlinetoback to summary
private void _rlineto()

Appends a line from the current point to a position at the relative coordinates dxa, dya. Additional rlineto operations are performed for all subsequent argument pairs. The number of lines is determined from the number of arguments on the stack.

_rmovetoback to summary
private void _rmoveto()

Moves the current point to a position at the relative coordinates (dx1, dy1).

_rollback to summary
private void _roll()

Performs a circular shift of the elements num(Nx1) ... num0 on the argument stack by the amount J. Positive J indicates upward motion of the stack; negative J indicates downward motion. The value N must be a non-negative integer, otherwise the operation is undefined.

_rrcurvetoback to summary
private void _rrcurveto()

Appends a Bezier curve, defined by dxa...dyc, to the current point. For each subsequent set of six arguments, an additional curve is appended to the current point. The number of curve segments is determined from the number of arguments on the number stack and is limited only by the size of the number stack.

_sqrtback to summary
private void _sqrt()

Returns the square root of num. If num is negative, the result is undefined.

_subback to summary
private void _sub()

Returns the result of subtracting num2 from num1.

_vhcurvetoback to summary
private void _vhcurveto()

Appends one or more Bezier curves to the current point, where the first tangent is vertical and the second tangent is horizontal. This command is the complement of hvcurveto; see the description of hvcurveto for more information.

_vlinetoback to summary
private void _vlineto()

Appends a vertical line of length dy1 to the current point. With an odd number of arguments, subsequent argument pairs are interpreted as alternating values of dx and dy, for which additional lineto operators draw alternating horizontal and vertical lines. With an even number of arguments, the arguments are interpreted as alternating vertical and horizontal lines. The number of lines is determined from the number of arguments on the stack.

_vmovetoback to summary
private void _vmoveto()

Moves the current point dy1 units in the vertical direction.

_vstemback to summary
private void _vstem()
_vstemhmback to summary
private void _vstemhm()
_vvcurvetoback to summary
private void _vvcurveto()

Appends one or more curves to the current point. If the argument count is a multiple of four, the curve starts and ends vertical. If the argument count is odd, the first curve does not begin with a vertical tangent.

clearArgback to summary
private void clearArg()

Clear the argument stack

curveToback to summary
private void curveTo(final int cx1, final int cy1, final int cx2, final int cy2, final int x, final int y)
endContourback to summary
private void endContour()
executeback to summary
public Point[] execute(final CharstringType2 cs)
getArgCountback to summary
private int getArgCount()

The number of arguments on the argument stack

getLastPointback to summary
private Point getLastPoint()
lineToback to summary
private void lineTo(final int x, final int y)
moveToback to summary
private void moveTo(final int x, final int y)
popArgback to summary
private Number popArg()

Pop a value off the argument stack

popSubrback to summary
private int popSubr()

Pop a value off the subroutine stack

pushArgback to summary
private void pushArg(final Number n)

Push a value on to the argument stack

pushSubrback to summary
private void pushSubr(final int n)

Push a value on to the subroutine stack