Insert text into a given rectangle. Args: rect -- the textbox to fill buffer -- text to be inserted fontname -- a Base-14 font, font name or '/name' fontfile -- name of a font file fontsize -- font size lineheight -- ov
(
self,
rect: rect_like,
buffer: typing.Union[str, list],
*,
fontname: OptStr = "helv",
fontfile: OptStr = None,
fontsize: float = 11,
lineheight: OptFloat = None,
set_simple: bool = 0,
encoding: int = 0,
color: OptSeq = None,
fill: OptSeq = None,
expandtabs: int = 1,
border_width: float = 0.05,
miter_limit: float = 1,
align: int = 0,
render_mode: int = 0,
rotate: int = 0,
morph: OptSeq = None,
stroke_opacity: float = 1,
fill_opacity: float = 1,
oc: int = 0,
)
| 15380 | # Shape.insert_textbox |
| 15381 | # ============================================================================== |
| 15382 | def insert_textbox( |
| 15383 | self, |
| 15384 | rect: rect_like, |
| 15385 | buffer: typing.Union[str, list], |
| 15386 | *, |
| 15387 | fontname: OptStr = "helv", |
| 15388 | fontfile: OptStr = None, |
| 15389 | fontsize: float = 11, |
| 15390 | lineheight: OptFloat = None, |
| 15391 | set_simple: bool = 0, |
| 15392 | encoding: int = 0, |
| 15393 | color: OptSeq = None, |
| 15394 | fill: OptSeq = None, |
| 15395 | expandtabs: int = 1, |
| 15396 | border_width: float = 0.05, |
| 15397 | miter_limit: float = 1, |
| 15398 | align: int = 0, |
| 15399 | render_mode: int = 0, |
| 15400 | rotate: int = 0, |
| 15401 | morph: OptSeq = None, |
| 15402 | stroke_opacity: float = 1, |
| 15403 | fill_opacity: float = 1, |
| 15404 | oc: int = 0, |
| 15405 | ) -> float: |
| 15406 | """Insert text into a given rectangle. |
| 15407 | |
| 15408 | Args: |
| 15409 | rect -- the textbox to fill |
| 15410 | buffer -- text to be inserted |
| 15411 | fontname -- a Base-14 font, font name or '/name' |
| 15412 | fontfile -- name of a font file |
| 15413 | fontsize -- font size |
| 15414 | lineheight -- overwrite the font property |
| 15415 | color -- RGB stroke color triple |
| 15416 | fill -- RGB fill color triple |
| 15417 | render_mode -- text rendering control |
| 15418 | border_width -- thickness of glyph borders as percentage of fontsize |
| 15419 | expandtabs -- handles tabulators with string function |
| 15420 | align -- left, center, right, justified |
| 15421 | rotate -- 0, 90, 180, or 270 degrees |
| 15422 | morph -- morph box with a matrix and a fixpoint |
| 15423 | Returns: |
| 15424 | unused or deficit rectangle area (float) |
| 15425 | """ |
| 15426 | rect = Rect(rect) |
| 15427 | if rect.is_empty or rect.is_infinite: |
| 15428 | raise ValueError("text box must be finite and not empty") |
| 15429 | |
| 15430 | color_str = ColorCode(color, "c") |
| 15431 | fill_str = ColorCode(fill, "f") |
| 15432 | if fill is None and render_mode == 0: # ensure fill color for 0 Tr |
| 15433 | fill = color |
| 15434 | fill_str = ColorCode(color, "f") |
| 15435 | |
| 15436 | optcont = self.page._get_optional_content(oc) |
| 15437 | if optcont is not None: |
| 15438 | bdc = f"/OC /{optcont} BDC\n" |
| 15439 | emc = "EMC\n" |
nothing calls this directly
no test coverage detected