Skip to content

fontlab.flExpression · declarations 001

Back to fontlab.flExpression

clearError

clearError() -> Any

clearError()

Clears any cached error state. After fixing a typo in the formula string, call this before calling process() so the error doesn't persist from the previous bad evaluation.

Source: FontLab Proteus API documentation

error instance-attribute

error: Any

int

The error code from the last evaluation. 0 means no error. Any non-zero value indicates a problem with the formula. Use flPropertiesProcessor.errorToStr(error) to convert to a readable message.

Source: FontLab Proteus API documentation

expression

expression(aliases: dict[str, str]) -> str

QString expression(QMap aliases)

Returns the formula string with variables substituted according to aliases. Useful for displaying the expression to the user with friendlier names, or for translating axis tags to human-readable names.

The formula string itself. Set this to change the expression. The formula can use standard arithmetic operators (+, -, *, /), comparison operators, axis tag names, and font metric names. Example: "xHeight * 0.5 + 50".

Source: FontLab Proteus API documentation

hasError

hasError() -> bool

bool hasError()

Returns True if the last evaluation attempt produced an error. Check error for the numeric error code and pass it to flPropertiesProcessor.errorToStr() for a message.

Source: FontLab Proteus API documentation

hasExpression

hasExpression() -> bool

bool hasExpression()

Returns True if the expression string is non-empty. A non-empty expression means this value is formula-driven, not fixed. Check this before trying to manually set a value — if an expression is active, your manual value will be overwritten on the next evaluation.

Source: FontLab Proteus API documentation

isNeedToComplete

isNeedToComplete() -> bool

bool isNeedToComplete()

Returns True if the expression cannot yet be evaluated because it references variables that have not been defined (e.g. an axis tag that hasn't been created yet).

Source: FontLab Proteus API documentation

ready instance-attribute

ready: Any

bool

Whether the expression has been evaluated and is current. Set to False to force a re-evaluation on the next process() cycle. Read to check whether the current value reflects the latest formula.

Source: FontLab Proteus API documentation

resetReady

resetReady() -> Any

resetReady()

Marks the expression as needing re-evaluation. After calling this, the next process() call will re-run the formula even if the inputs haven't visibly changed. Use this when you have changed the formula string and want to force an update.

Source: FontLab Proteus API documentation

variables

variables(*args: Any, **kwargs: Any) -> Any

QStringList variables([QMap aliases])

Returns a list of the variable names referenced in the formula. Pass an optional aliases map to rename variables. For example, {"ascender": "asc"} will return ["asc"] if the formula uses ascender. Use this to audit which axes or metrics a given expression depends on.

Source: FontLab Proteus API documentation