gdstk.Label

class gdstk.Label(text, origin, anchor='o', rotation=0, magnification=1, x_reflection=False, layer=0, texttype=0)

Text objects with out geometrical information.

Labels do not create any new geometry in the layout. They can be used to add descriptions, flags, or comments to the design. For polygonal text, gdstk.text() should be used instead.

Parameters:
  • text (str) – Text string.

  • origin (coordinate pair or complex) – Label position.

  • anchor (str) – Origin position with respect to the label text. One of “n”, “s”, “e”, “w”, “o”, “ne”, “nw”, “se”, or “sw”.

  • rotation – Rotation angle (in radians).

  • magnification – Scaling factor.

  • x_reflection – If True, the label is reflected across the horizontal axis before rotation.

  • layer – layer number assigned to this label.

  • texttype – text type number assigned to this label.

Examples

>>> frame = gdstk.rectangle((-2, -1), (2, 1), datatype=1)
>>> label_o = gdstk.Label("Center", (0, 0), rotation=numpy.pi / 6)
>>> label_n = gdstk.Label("North", (0, 1), "n")
>>> label_s = gdstk.Label("South", (0, -1), "s")
>>> label_e = gdstk.Label("East", (2, 0), "e")
>>> label_w = gdstk.Label("West", (-2, 0), "w")
>>> label_ne = gdstk.Label("Northeast", (2, 1), "ne")
>>> label_se = gdstk.Label("Southeast", (2, -1), "se")
>>> label_nw = gdstk.Label("Northwest", (-2, 1), "nw")
>>> label_sw = gdstk.Label("Southwest", (-2, -1), "sw")
../_images/init4.svg

Note that this example can only be correctly displayed in browsers with good support for text alignment in SVG images.

Notes

Label anchor and transformations (rotation, magnification and reflection) are not supported by the OASIS format.

Methods

apply_repetition()

Create new labels based on this object's repetition attribute.

copy()

Create a copy this label.

delete_gds_property(attr)

Delete a GDSII property of this element.

delete_property(name)

Delete the first property of this element matching a name.

get_gds_property(attr)

Return a GDSII property of this element.

get_property(name)

Return the values of the first property of this element matching a name.

set_gds_property(attr, value)

Set a GDSII property for this element.

set_property(name, value)

Set a property for this element.

Attributes

anchor

Label anchor.

layer

Label layer.

magnification

Label scaling factor.

origin

Label origin.

properties

Properties of this element.

repetition

Repetition associated with this element.

rotation

Label rotation angle.

text

Label text.

texttype

Label text type.

x_reflection

Label reflection across the x axis.

anchor

Label anchor.

apply_repetition() list

Create new labels based on this object’s repetition attribute.

After the repetition is applied, the original attribute is set to None.

Returns:

Newly created objects.

copy() gdstk.Label

Create a copy this label.

Returns:

Copy of this label.

delete_gds_property(attr) self

Delete a GDSII property of this element.

Parameters:

attr (number) – Property number.

delete_property(name) self

Delete the first property of this element matching a name.

Parameters:

name (str) – Property name.

get_gds_property(attr) str

Return a GDSII property of this element.

Parameters:

attr (number) – Property number.

Returns:

Property value. If the property number does not exist, None is returned.

Return type:

str or None

get_property(name) list

Return the values of the first property of this element matching a name.

Parameters:

name (str) – Property name.

Returns:

List of property values. If no property is found, None is returned.

Return type:

list or None

layer

Label layer.

magnification

Label scaling factor.

origin

Label origin.

properties

Properties of this element.

Properties are represented as a list of lists, each containing the property name followed by its values.

repetition

Repetition associated with this element.

rotation

Label rotation angle.

set_gds_property(attr, value) self

Set a GDSII property for this element.

GDSII properties are stored under the special name “S_GDS_PROPERTY”, as defined by the OASIS specification.

Parameters:
  • attr (number) – Property number.

  • value (str) – Property value.

set_property(name, value) self

Set a property for this element.

The property name does not have to be unique. Multiple properties can have the same name.

Parameters:
  • name (str) – Property name.

  • value (str, bytes, number, or sequence of those) – Values associated with the property.

Notes

These properties can be used to associate custom metadata with an element, but general properties are not supported by GDSII files, only OASIS. Use the specific methods to access GDSII properties.

text

Label text.

texttype

Label text type.

x_reflection

Label reflection across the x axis.