measure_text — ANNOTATE text op

Data kinds: texttable

Call: 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) (or opsannotate.get("measure_text"))

Usage

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

> The detailed description below is the original text — the summary and the headings are translated.

Parameters

----------

text : str

測る文字列(`\n` で改行)。

font_size : int

希望のサイズ。`max_width` に入らなければ 1pt ずつ縮める。

font_path : str or None

明示すると機械をまたいでも同じ結果になる。None は :data:FONT_CANDIDATES

を固定順で探す。

max_width : int or None

入れたい幅[px]。None なら縮小も折り返しもしない。

min_font_size : int

ここまで縮めても入らなければ ValueError(黙って切らない)。

line_spacing : float

行送り係数。

wrap : bool

True(既定)なら `max_width` で折り返す。False なら折り返さず

行を増やさずフォントを縮めて収める(格子のラベルのように、2 行に

なると版が崩れる場所で使う ―― `exhibit_tile._fit_label` と同じ流儀)。

どちらでも `min_font_size` まで来て入らなければ例外。

``

` の改行は max_width の有無・wrap` の値によらず常に効く

(幅を与えないと 1 行に潰れる、という事故は起きない)。

Returns

-------

dict

`{"lines", "font", "font_size", "width", "height", "line_height"}`。

`width/height` は実測[px]。

Raises

------

ValueError

`max_width が非正 / min_font_size` まで縮めても 1 行が入らない。

Detailed usage guide

figure_annotation family guide

Background guides (the physics and conventions behind this op)

dataset_conventions — 学習データセット規約の知識 — COCO / YOLO / VOC と外観検査での落とし穴

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_gallerypy -3.11 examples/annotate_gallery.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.