Glyphs
Bases: dict
A glyph dictionary, mapping single chars or groups of chars (ligatures) to glyphs.
bg_boundary
classmethod
Calculates the background boundary between two glyphs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
List[str]
|
Left glyph. |
required |
|
List[str]
|
Right glyph. |
required |
|
int
|
Space between left and right in number of cells. |
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
List[int]: Boundary in offsets from the end of the left glyph. |
boundary
classmethod
Calculates the boundary between two glyphs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
List[str]
|
Left glyph. |
required |
|
List[str]
|
Right glyph. |
required |
|
int
|
Space between left and right in number of cells. |
required |
Returns:
| Type | Description |
|---|---|
List[int]
|
List[int]: Boundary in offsets from the end of the left glyph. |
from_lines
classmethod
Create a Glyphs instance from lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Union[str, List[str]]
|
String of chars or list of char groups in the same order as glyphs. |
required |
|
str
|
Lines of concatenated glyphs, delimited by full column of separator char. |
()
|
|
str
|
Separator char used to separate individual glyphs. Defaults to space. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Glyph lines are of unequal length. |
ValueError
|
Number of glyphs does not match number of chars. |
get_char_map
classmethod
Map chars to split glyphs. Glyphs are split at every full column of the separator char.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Union[List[str], str]
|
String or List of chars. |
required |
|
List[str]
|
Lines of concatenated glyphs, delimited by full column of separator. |
()
|
|
Optional[str]
|
description. Defaults to None. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Number of glyphs does not match number of chars. |
Returns:
| Type | Description |
|---|---|
Dict[str, Glyph]
|
Dict[str, List[str]]: Char to glyph map. |
line_lead
classmethod
line_lead(line)
Get number of leading whitespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Line of text. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Leading whitespace count. |
line_trail
classmethod
line_trail(line)
Get number of trailing whitespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Line of text. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Trailing whitespace count. |
max_overlap
classmethod
Calculates the maximum number of cells two glyphs can overlap without occluding each other.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
List[str]
|
Left glyph. |
required |
|
List[str]
|
Right glyph. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
Max overlap in number of cells. |
merge
classmethod
Merges two glyphs. In case of overlapping non-space characters, the right glyph will occlude the left glyph.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
List[str]
|
Left glyph. |
required |
|
List[str]
|
Right glyph. |
required |
|
int
|
Space between left and right in number of cells. Defaults to 0. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
Glyph |
Glyph
|
Merged glyph. |
merge_line
classmethod
Merge two lines. In case of overlapping non-space characters, the right line will occlude the left line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Left line. |
required |
|
str
|
Right line. |
required |
|
int
|
Space between left and right in number of cells. Defaults to 0. |
0
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Merged line. |