Sidechair

table.cell_set_text_font_family()

Browse the reference

Switches one cell between the default typeface and a monospace face with equal-width digits.

Try it in the editor

font.family_monospace gives every character the same width, which keeps columns of figures lined up from row to row. font.family_default restores the ordinary face.

Only the cell you name changes, so mix a monospace value column with a normal label column.

Syntax

Pine Script
table.cell_set_text_font_family(table_id: series table, column: series int, row: series int, text_font_family: series string) -> void
table.cell_set_text_font_family(column: series int, row: series int, text_font_family: series string) -> void

Arguments

NameTypeDefaultDescription
table_idseries tablerequiredThe table that holds the cell whose typeface changes.
columnseries intrequiredColumn of the cell whose typeface changes, counting from 0 at the left.
rowseries intrequiredRow of the cell whose typeface changes, counting from 0 at the top.
text_font_familyseries stringrequiredfont.family_default for the ordinary face, or font.family_monospace for equal-width characters.

Returns

Nothing.

Example

Pine ScriptMonospaced price and volumeOpen in editor
//@version=6
indicator("table.cell_set_text_font_family: figures", overlay = true)
var t = table.new(position.top_right, 2, 2)
if barstate.islast
    table.cell(t, 0, 0, "Close")
    table.cell(t, 1, 0, str.tostring(close, "#.00"), text_halign = text.align_right)
    table.cell(t, 0, 1, "Volume")
    table.cell(t, 1, 1, str.tostring(volume, "#"), text_halign = text.align_right)
    table.cell_set_text_font_family(t, 1, 0, font.family_monospace)
    table.cell_set_text_font_family(t, 1, 1, font.family_monospace)

See also

Runs on Sidechair