SWU Module

sutton_signwriting_font.swu.swu_symbol_normalize(swu_sym)

Normalizes a symbol with a minimum coordinate for a center of 500,500.

Parameters:

swu_sym (str) – an SWU symbol key with optional coordinate and style string

Returns:

normalized symbol

Return type:

str

Example

>>> swu_symbol_normalize('񀀁-C')
'񀀁𝣿𝣷-C'
sutton_signwriting_font.swu.swu_symbol_svg_body(swu_sym)

Creates the body of an SVG image from an SWU symbol key with an optional style string.

Parameters:

swu_sym (str) – an SWU symbol key with optional style string

Returns:

symbol svg body

Return type:

str

Example

>>> swu_symbol_svg_body('񀀁-C')
'  <text font-size="0">񆇡-C</text>\n  <svg x="493" y="485">...</svg>'
sutton_signwriting_font.swu.swu_symbol_svg(swu_sym)

Creates an SVG image from an SWU symbol key with an optional style string.

Parameters:

swu_sym (str) – an SWU symbol key with optional style string

Returns:

symbol svg

Return type:

str

Example

>>> swu_symbol_svg('񀀁-C')
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" ...>...</svg>'
sutton_signwriting_font.swu.swu_symbol_png(swu_sym, scale=None)

Creates a binary PNG image from an SWU symbol key with an optional style string.

Parameters:
  • swu_sym (str) – an SWU symbol key with optional style string

  • scale (ScaleObject | None) – options for scaling to specific width or height

Returns:

symbol png bytes

Return type:

bytes

Example

>>> png = swu_symbol_png('񀀁-C')
>>> png[:8] == b'\x89PNG\r\n\n'  # Valid PNG header
True
sutton_signwriting_font.swu.swu_symbol_png_data_url(swu_sym, scale=None)

Creates a data url PNG image from an SWU symbol key with an optional style string.

Parameters:
  • swu_sym (str) – an SWU symbol key with optional style string

  • scale (ScaleObject | None) – options for scaling to specific width or height

Returns:

symbol png data url

Return type:

str

Example

>>> swu_symbol_png_data_url('񀀁-C').startswith('data:image/png;base64,')
True
sutton_signwriting_font.swu.swu_sign_normalize(swu_sign)

Normalizes an SWU sign for a center of 500,500.

Parameters:

swu_sign (str) – an SWU sign with optional style string

Returns:

normalized sign

Return type:

str

Example

>>> swu_sign_normalize('𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭')
'𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭'
sutton_signwriting_font.swu.swu_sign_svg_body(swu_sign)

Creates the body of an SVG image from an SWU sign with an optional style string.

Parameters:

swu_sign (str) – an SWU sign with optional style string

Returns:

sign svg body

Return type:

str

Example

>>> swu_sign_svg_body('𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C')
'  <text font-size="0">𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C</text>\n  <svg x="476" y="466">...</svg>...'
sutton_signwriting_font.swu.swu_sign_svg(swu_sign)

Creates an SVG image from an SWU sign with an optional style string.

Parameters:

swu_sign (str) – an SWU sign with optional style string

Returns:

sign svg

Return type:

str

Example

>>> swu_sign_svg('𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C')
'<svg ...> ... </svg>'
sutton_signwriting_font.swu.swu_sign_png(swu_sign, scale=None)

Creates a binary PNG image from an SWU sign with an optional style string.

Parameters:
  • swu_sign (str) – an SWU sign with optional style string

  • scale (ScaleObject | None) – options for scaling to specific width or height

Returns:

sign png bytes

Return type:

bytes

Example

>>> png = swu_sign_png('𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C')
>>> png[:8] == b'\x89PNG\r\n\n'  # Valid PNG header
True
sutton_signwriting_font.swu.swu_sign_png_data_url(swu_sign, scale=None)

Creates a data url PNG image from an SWU sign with an optional style string.

Parameters:
  • swu_sign (str) – an SWU sign with optional style string

  • scale (ScaleObject | None) – options for scaling to specific width or height

Returns:

sign png data url

Return type:

str

Example

>>> swu_sign_png_data_url('𝠃𝤟𝤩񋛩𝣵𝤐񀀒𝤇𝣤񋚥𝤐𝤆񀀚𝣮𝣭-C').startswith('data:image/png;base64,')
True
sutton_signwriting_font.swu.swu_column_svg(column, options=None)

Creates an SVG column image for an array of column data.

Note

This is an internal helper; column and options must be generated in tandem by the calling function (swu_columns_svg) to ensure compatibility. Standalone use may produce incorrect output if values are mismatched.

Parameters:
Returns:

svg column

Return type:

str

Example

>>> col = [{"x": 56, "y": 20, "minX": 481, "minY": 471, "width": 37, "height": 58, "lane": 0, "padding": 0, "segment": "sign", "text": "𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻", "zoom": 1}]
>>> swu_column_svg(col, {"height": 250, "width": 150}).startswith('<svg')
True
sutton_signwriting_font.swu.swu_column_png(column, options=None)

Creates a binary PNG column image for an array of column data.

Note

This is an internal helper; column and options must be generated in tandem by the calling function (swu_columns_png) to ensure compatibility. Standalone use may produce incorrect output if values are mismatched.

Parameters:
Returns:

png column bytes

Return type:

bytes

Example

>>> col = [{"x": 56, "y": 20, "minX": 481, "minY": 471, "width": 37, "height": 58, "lane": 0, "padding": 0, "segment": "sign", "text": "𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻", "zoom": 1}]
>>> len(swu_column_png(col, {"height": 250, "width": 150})) > 0
True
sutton_signwriting_font.swu.swu_columns_svg(swu_text, options=None)

Creates an array of SVG column images for an SWU text.

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

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

Returns:

array of svg columns

Return type:

List[str]

Example

>>> swu_text = "𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻 𝠀񃊢񃊫񋛕񆇡𝠃𝤘𝤧񃊫𝣻𝤕񃊢𝣴𝣼񆇡𝤎𝤂񋛕𝤆𝣦 񏌁𝣢𝤂"
>>> opts = {"height": 250, "width": 150}
>>> len(swu_columns_svg(swu_text, opts))
1
sutton_signwriting_font.swu.swu_columns_png(swu_text, options=None)

Creates an array of PNG column images for an SWU text.

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

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

Returns:

array of PNG data

Return type:

List[bytes]

Example

>>> swu_text = "𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻 𝠀񃊢񃊫񋛕񆇡𝠃𝤘𝤧񃊫𝣻𝤕񃊢𝣴𝣼񆇡𝤎𝤂񋛕𝤆𝣦 񏌁𝣢𝤂"
>>> opts = {"height": 250, "width": 150}
>>> len(swu_columns_png(swu_text, opts))
1
sutton_signwriting_font.swu.swu_columns_png_data_url(swu_text, options=None)

Creates an array of PNG data url column images for an SWU text.

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

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

Returns:

array of PNG data urls

Return type:

List[str]

Example

>>> swu_text = "𝠀񁲡񈩧𝠃𝤘𝤣񁲡𝣳𝣩񈩧𝤉𝣻 𝠀񃊢񃊫񋛕񆇡𝠃𝤘𝤧񃊫𝣻𝤕񃊢𝣴𝣼񆇡𝤎𝤂񋛕𝤆𝣦 񏌁𝣢𝤂"
>>> opts = {"height": 250, "width": 150}
>>> all(u.startswith('data:image/png;base64,') for u in swu_columns_png_data_url(swu_text, opts))
True