SWU Module

The swu module contains functions for handling SignWriting in Unicode (SWU) characters.

SWU characters definition: https://datatracker.ietf.org/doc/id/draft-slevinski-formal-signwriting-10.html#name-signwriting-in-unicode-swu

sutton_signwriting_core.swu.swu_is_type(swu_char, type_name)

Test whether an SWU character is of the given type/range.

Parameters:
  • swu_char (str) – an SWU symbol

  • type_name (str) – the name of a symbol range

Returns:

True if symbol of specified type

Return type:

bool

Example

>>> swu_is_type('񀀁', 'hand')
True

Note

The following type_name values are supported:

  • all - All symbols used in Formal SignWriting.

  • writing - Symbols that can be used in the spatial signbox or the temporal prefix.

  • hand - Various handshapes.

  • movement - Contact symbols, small finger movements, straight arrows, curved arrows, and circles.

  • dynamic - Dynamic symbols used to express “feeling” or “tempo” of movement.

  • head - Symbols for the head and face.

  • hcenter - Used to determine the horizontal center of a sign (same as the head type).

  • vcenter - Used to determine the vertical center of a sign (includes head and trunk types).

  • trunk - Symbols for torso movement, shoulders, and hips.

  • limb - Symbols for limbs and fingers.

  • location - Detailed location symbols used only in the temporal prefix.

  • punctuation - Symbols used to divide signs into sentences.

sutton_signwriting_core.swu.swu_colorize(sym)

Function that returns the standardized color for a symbol.

Parameters:

sym (str) – an SWU symbol

Returns:

name of standardized color for symbol

Return type:

str

Example

>>> swu_colorize('񀀁')
'#0000CC'
sutton_signwriting_core.swu.swu_parse_symbol(swu_sym)

Parse an SWU symbol with optional coordinate and style string.

Parameters:

swu_sym (str) – an SWU symbol string

Returns:

Dictionary with ‘symbol’, ‘coord’, ‘style’ keys

Return type:

SymbolObject

Example

>>> swu_parse_symbol('񀀁𝤆𝤆-C')
{'symbol': '񀀁', 'coord': [500, 500], 'style': '-C'}
sutton_signwriting_core.swu.swu_parse_sign(swu_sign)

Parse an SWU sign with optional style string.

Parameters:

swu_sign (str) – an SWU sign string

Returns:

Dictionary with ‘sequence’, ‘box’, ‘max’, ‘spatials’, ‘style’ keys

Return type:

SignObject

Example

>>> swu_parse_sign('𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C')
{'sequence': ['񀀒', '񀀚', '񋚥', '񋛩'],
 'box': '𝠃',
 'max': [525, 535],
 'spatials': [{'symbol': '񋛩', 'coord': [483, 510]},
              {'symbol': '񀀒', 'coord': [501, 466]},
              {'symbol': '񋚥', 'coord': [510, 500]},
              {'symbol': '񀀚', 'coord': [476, 475]}],
 'style': '-C'}
sutton_signwriting_core.swu.swu_parse_text(swu_text)

Parse an SWU text into signs and punctuations.

Parameters:

swu_text (str) – an SWU text string

Returns:

List of SWU signs and punctuations

Return type:

List[str]

Example

>>> swu_parse_text('𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻 𝠀񃊢񃊫񋛕񆇡𝠃𝤘𝤧񃊫𝣻𝤕񃊢𝣴𝣼񆇡𝤎𝤂񋛕𝤆𝣦 񏌁𝣢𝤂')
['𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻',
 '𝠀񃊢񃊫񋛕񆇡𝠃𝤘𝤧񃊫𝣻𝤕񃊢𝣴𝣼񆇡𝤎𝤂񋛕𝤆𝣦',
 '񏌁𝣢𝤂']
sutton_signwriting_core.swu.swu_compose_symbol(swu_sym_object)

Function to compose an swu symbol with optional coordinate and style string.

Parameters:

swu_sym_object (SymbolObject) – an swu symbol object

Returns:

an swu symbol string

Return type:

str | None

Example

>>> swu_compose_symbol({'symbol': '񀀁', 'coord': [500, 500], 'style': '-C'})
'񀀁𝤆𝤆-C'
sutton_signwriting_core.swu.swu_compose_sign(swu_sign_object)

Function to compose an swu sign with style string.

Parameters:

swu_sign_object (SignObject) – an swu sign object

Returns:

an swu sign string

Return type:

str | None

Example

>>> swu_compose_sign({
...     'sequence': ['񀀒','񀀚','񋚥','񋛩'],
...     'box': '𝠃',
...     'max': [525, 535],
...     'spatials': [
...         {'symbol': '񋛩', 'coord': [483, 510]},
...         {'symbol': '񀀒', 'coord': [501, 466]},
...         {'symbol': '񋚥', 'coord': [510, 500]},
...         {'symbol': '񀀚', 'coord': [476, 475]}
...     ],
...     'style': '-C'
... })
'𝠀񀀒񀀚񋚥񋛩𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C'
sutton_signwriting_core.swu.swu_info(swu)

Function to gather sizing information about an swu sign or symbol.

Parameters:

swu (str) – an swu sign or symbol

Returns:

information about the swu string

Return type:

SegmentInfo

Example

>>> swu_info('𝠀񁲡񈩧𝠂𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻-P10Z2')
{
    'minX': 481,
    'minY': 471,
    'width': 37,
    'height': 58,
    'lane': -1,
    'padding': 10,
    'segment': 'sign',
    'zoom': 2
}
sutton_signwriting_core.swu.swu_column_defaults_merge(options=None)

Function to merge an object of column options with default values.

Parameters:

options (ColumnOptions | None) – object of column options

Returns:

object of column options merged with column defaults

Return type:

ColumnOptions

Example

>>> swu_column_defaults_merge({'height': 500, 'width': 150})
{'height': 500, 'width': 150, 'offset': 50, ...}
sutton_signwriting_core.swu.swu_columns(swu_text, options=None)

Function to transform an FSW text to an array of columns.

Parameters:
  • swu_text (str) – FSW text of signs and punctuation

  • options (ColumnOptions | None) – object of column options

Returns:

object of column options, widths array, and column data

Return type:

ColumnsResult

Example

>>> swu_columns('𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻 𝠀񃊢񃊫񋛕񆇡𝠃𝤘𝤧񃊫𝣻𝤕񃊢𝣴𝣼񆇡𝤎𝤂񋛕𝤆𝣦 񏌁𝣢𝤂', {'height': 500, 'width': 150})
{'options': {...}, 'widths': [150], 'columns': [[{'x': 56, 'y': 20, ...}, ...]]}