# CanvasTextField.CharTints class

Namespace: [Grasshopper2.UI.Canvas](https://developer.rhino3d.com/api/gh2/namespace/grasshopper2.ui.canvas.md) · Assembly: [Grasshopper2](https://developer.rhino3d.com/api/gh2/assembly/grasshopper2.md)

```cs
public sealed class CanvasTextField.CharTints
```

A resolved table of per-grapheme colours, and the [CanvasTextField.Tinting](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.canvastextfield/tinting.md) delegate which reads it. Construct one per field and keep it for the lifetime of the field; call [CanvasTextField.CharTints.Prepare(string, Color)](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.canvastextfield.chartints/prepare.md) once per draw and assign the result to [CanvasTextField.Tinting](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.canvastextfield/tinting.md).

The point of this class is that the resolver sees the entire string at once, so it can do as much parsing as it likes - multi-character operators, symbols whose meaning depends on their context, colour names resolved to the colour they name - and it only runs again when the text or the text colour actually change. The per-grapheme callback the field ends up invoking is a bare array lookup.

Not thread safe, and doesn't need to be: it is only touched while drawing.

## Constructors

- [CanvasTextField.CharTints](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.canvastextfield.chartints/ctor.md): Create a table from a resolver.

## Methods

- [Prepare](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.canvastextfield.chartints/prepare.md): Re-resolve the table if the text or the colour have changed since the last call, and return the [CanvasTextField.Tinting](https://developer.rhino3d.com/api/gh2/type/grasshopper2.ui.canvas.canvastextfield/tinting.md) delegate which reads it. Cheap to call on every draw; the resolver only runs when something actually moved.
