Table of Contents

DisplayText2

from OpenCAD2D import DisplayText2

class DisplayText2(DisplayItem2) ยท DisplayText2 in the .NET reference

A piece of text, placed by the point its alignment names; the canvas measures and draws it in a font.

Constructors

__init__

.NET

def __init__(
    self,
    text: str,
    x: float,
    y: float,
    height: float,
    rotation: float,
    widthFactor: float,
    horizontal: int,
    vertical: int,
    style: DisplayStyle,
    handle: str,
    layer: str,
    fontName: str,
    oblique: float,
) -> None

Makes a piece of text.

def __init__(
    self,
    text: str,
    x: float,
    y: float,
    height: float,
    rotation: float,
    widthFactor: float,
    horizontal: int,
    vertical: int,
    style: DisplayStyle,
    handle: str,
    layer: str,
    fontName: str,
    oblique: float,
    backward: bool,
) -> None

Makes a piece of text that may be drawn backwards, as text in a mirrored block is.

Properties and fields

Bounds

.NET

@property
def Bounds(self) -> DisplayBox

Gets the box that holds the item.

EstimatedWidth

.NET

@property
def EstimatedWidth(self) -> float

Gets the width the text is taken to have for picking and extents: of its widest line, by the advances of its letters where it is drawn in an SHX font (DisplayText2.Strokes); else from its height and the number of its letters, 0.6 of the height a letter, as a monospace font would, the canvas measuring the real width.

FontName

.NET

@property
def FontName(self) -> str | None

Gets the font of the text's style, a typeface or a font file; null for the canvas's own.

Height

.NET

@property
def Height(self) -> float

Gets the height of a capital letter.

Horizontal

.NET

@property
def Horizontal(self) -> int

Gets where the point lies along the text: 0 left, 1 centre, 2 right.

IsBackward

.NET

@property
def IsBackward(self) -> bool

Gets whether the text is drawn backwards: laid out and drawn as always in its own frame (along DisplayText2.Rotation and up it), that frame then turned over along its baseline, so that the letters run against DisplayText2.Rotation and read as in a mirror. A text in a block inserted mirrored, written backwards or upside down is drawn so; a canvas draws it by scaling its frame by -1 along the baseline after turning it.

IsBold

.NET

@property
def IsBold(self) -> bool

Gets whether the canvas draws the letters in the bold face of DisplayText2.FontName, as a run of an MTEXT coded |b1 is drawn.

IsField

.NET

@property
def IsField(self) -> bool

Gets whether the words are those of a field, which the canvas draws on a grey ground that is not plotted, as AutoCAD does where FIELDDISPLAY is 1; the ground covers the box of the text.

IsItalic

.NET

@property
def IsItalic(self) -> bool

Gets whether the canvas draws the letters in the italic face of DisplayText2.FontName, as a run of an MTEXT coded |i1 is drawn.

IsQuick

.NET

@property
def IsQuick(self) -> bool

Gets whether the text is shown as its box alone, as AutoCAD shows it where QTEXTMODE is 1: the canvas draws the rectangle that holds its lines, in the text's colour, and not its letters. The words stay for what reads them.

LineCount

.NET

@property
def LineCount(self) -> int

Gets the number of lines of the text.

Oblique

.NET

@property
def Oblique(self) -> float

Gets how far the letters lean, in radians clockwise from upright.

Parts

.NET

@property
def Parts(self) -> System.Collections.Generic.IReadOnlyList[DisplayItem2] | None

Gets what an MTEXT is drawn as, in place of DisplayText2.Text drawn whole: its mask (a DisplayFill2) and its frame first, then a text for each run of each line where AutoCAD sets it, in its own font, face, height, width, slant and colour, the parts of a stacked fraction among them, and a line under, over or through a run its codes line and for the bar of a fraction; null for a TEXT, drawn whole. The text keeps its words, height and attachment as one text has them, for what reads it; its box is that of the parts. "AB{\C1;CD}" 2.5 high is drawn as AB in the MTEXT's colour and CD in red after it; "II II II" 20 wide in letters 10 high as "II II" and, 16.67 below it, "II".

Rotation

.NET

@property
def Rotation(self) -> float

Gets the angle of the baseline in radians.

Strokes

.NET

@property
def Strokes(self) -> System.Collections.Generic.IReadOnlyList[System.Array[float]] | None

Gets the strokes of the letters where the text is drawn in an SHX font, each a polyline of x, y pairs in the drawing's coordinates, the text's height, width factor, slant, alignment, angle and turning over already taken, then the lines a TEXT's %%U, %%K and %%O draw under, through and over its letters, one segment each; null where the canvas draws the text in DisplayText2.FontName.

Text

.NET

@property
def Text(self) -> str

Gets the text.

Vertical

.NET

@property
def Vertical(self) -> int

Gets where the point lies up the text: 0 baseline, 1 bottom, 2 middle, 3 top.

WidthFactor

.NET

@property
def WidthFactor(self) -> float

Gets the width factor.

X

.NET

@property
def X(self) -> float

Gets the X of the alignment point.

Y

.NET

@property
def Y(self) -> float

Gets the Y of the alignment point.

Methods

DistanceTo

.NET

def DistanceTo(self, x: float, y: float) -> float

Gets the distance from a point to the item, the shortest to any part that is drawn; the distance to the nearest edge for a fill, nought inside it.