-
Notifications
You must be signed in to change notification settings - Fork 3
Text
The Text
class is designed to represent and manipulate text within a coordinate system, allowing for the creation of text objects with specific fonts, sizes, and positions. It is capable of generating and translating text into a series of geometric representations.
Initializes a new Text instance
- `id` (str): A unique identifier for the text object.
- `type` (str): The class name, "Text".
- `text` (str, optional): The text string to be represented.
- `font_family` (str, optional): The font family of the text, defaulting to "Arial".
- `xyz` (Vector): The origin point of the text in the coordinate system.
- `csglobal` (CoordinateSystem): The global coordinate system applied to the text.
- `x`, `y`, `z` (float): The position offsets for the text within its coordinate system.
- `scale` (float, optional): The scale factor applied to the text size.
- `height` (float, optional): The height of the text characters.
- `bbHeight` (float, optional): The bounding box height of the text.
- `width` (float, optional): The calculated width of the text string.
- `character_offset` (int): The offset between characters.
- `space` (int): The space between words.
- `curves` (list): A list of curves representing the text geometry.
- `points` (list): A list of points derived from the text geometry.
- `path_list` (list): A list containing the path data for each character.
-
calculate_bounding_box(self, points: list[Point]) -> tuple
: Calculates the bounding box for a given set of points. -
convert_points_to_polyline(self, points: list[Point]) -> PolyCurve
: Converts a list of points into a PolyCurve. This method is used to generate a PolyCurve from a series of points, typically derived from text path data. -
load_path(self) -> str
: Loads the glyph paths for the specified text from a JSON file. This method fetches the glyph paths for each character in the text attribute, using a predefined font JSON file. -
serialize(self) -> dict
: Serializes the text object's attributes into a dictionary. This method is useful for exporting the text object's properties, making it easier to save or transmit as JSON. -
translate(self, polyCurve: PolyCurve) -> PolyCurve
: Translates a PolyCurve according to the text object's global coordinate system and scale. -
write(self) -> List[List[PolyCurve]]
: Generates a list of PolyCurve objects representing the text. Transforms the text into geometric representations based on the specified font, scale, and position.
Calculates the bounding box for a given set of points.
points (list): A list of points to calculate the bounding box for.
tuple: A tuple containing the bounding box, its width, and its height.
Converts a list of points into a PolyCurve. This method is used to generate a PolyCurve from a series of points, typically derived from text path data.
points (list): A list of points to be converted into a PolyCurve.
PolyCurve: A PolyCurve object representing the points.
Loads the glyph paths for the specified text from a JSON file. This method fetches the glyph paths for each character in the text attribute, using a predefined font JSON file.
str: A string representation of the glyph paths for the text.
Serializes the text object's attributes into a dictionary. This method is useful for exporting the text object's properties, making it easier to save or transmit as JSON.
dict: A dictionary containing the serialized attributes of the text object.
Translates a PolyCurve according to the text object's global coordinate system and scale.
polyCurve (PolyCurve): The PolyCurve to be translated.
PolyCurve: The translated PolyCurve.
Generates a list of PolyCurve objects representing the text. Transforms the text into geometric representations based on the specified font, scale, and position.
List[List[PolyCurve]]: A list of lists containing PolyCurve objects representing the text geometry.