measure_text — ANNOTATE text op

• Data kinds: text → table

• Call: import fullseye as fs; fs.ledger.measure_text(text, font_size=14, font_path=None, max_width=None, min_font_size=9, line_spacing=1.15, wrap=True, bold=False, italic=False) (to call the implementation directly, import annotate; annotate.measure_text(text, font_size=14, font_path=None, max_width=None, min_font_size=9, line_spacing=1.15, wrap=True, bold=False, italic=False); from the registry, opsannotate.get("measure_text"))

Usage

Measure text before drawing it. If it does not fit, wrap or shrink it; if that fails, raise.

Parameters

text : str

String to measure (\n for line breaks).

font_size : int

Desired size. If it does not fit max_width, it is shrunk 1pt at a time.

font_path : str or None

Giving it explicitly yields the same result across machines. None searches FONT_CANDIDATES

in a fixed order.

max_width : int or None

Width [px] it should fit into. If None, neither shrinking nor wrapping is done.

min_font_size : int

If it still does not fit after shrinking down to this, ValueError (no silent truncation).

line_spacing : float

Line-spacing factor.

bold, italic : bool or int

Synthetic bold and italic (_bold_px / _italic_tile). These are not real

Bold / Italic typefaces, so the glyph shapes differ -- when you need the real thing,

pass that typeface's file as font_path. Passing an integer to bold

directly specifies the number of overstrike passes. The extra width from weight and slant goes into width,

so plate and table columns widen accordingly (overstriking only thickens horizontally, so

height does not change).

wrap : bool

If True (default), wraps at max_width. If False, it does not wrap but

fits by shrinking the font without adding lines (used where 2 lines

would break the layout, like grid labels -- the same approach as exhibit_tile._fit_label).

Either way, if it does not fit by min_font_size, an exception is raised.

\n line breaks take effect always, regardless of whether max_width is given or the value of wrap

(the accident "without a width it collapses into 1 line" does not happen).

Returns

dict

{"lines", "font", "font_size", "width", "height", "line_height"}.

width/height are measured [px].

Raises

ValueError

max_width is not positive / 1 line does not fit even after shrinking to min_font_size.

Detailed usage guide

• figure_annotation family guide

Background guides (the physics and conventions behind this op)

• dataset_conventions — Training-dataset conventions — COCO / YOLO / VOC and pitfalls in visual inspection

References (sample data, literature)

• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).

• Operator provenance and references — the sources of the research/methods this op family came from.

• The canonical algorithm (author, year) and its uses are named in the family usage guide above.

Runnable examples (verified samples that actually call this op)

• annotate_gallery — py -3.11 examples/annotate_gallery.py

• annotate_paper_tour — py -3.11 examples/annotate_paper_tour.py

• poc_diabolo_model_and_vision — py -3.11 examples/poc_diabolo_model_and_vision.py

Ops the type connects to (they accept table as input)

—

Same category (text)

text_box


*Provenance: annotate.py — ANNOTATE operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*

© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.