FSW Module

sutton_signwriting_font.fsw.fsw_symbol_normalize(fsw_sym)

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

Parameters:

fsw_sym (str) – an FSW symbol key with optional coordinate and style string

Returns:

normalized symbol

Return type:

str

Example

>>> fsw_symbol_normalize('S20500-C')
'S20500493x493-C'
sutton_signwriting_font.fsw.fsw_symbol_svg_body(fsw_sym)

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

Parameters:

fsw_sym (str) – an FSW symbol key with optional style string

Returns:

symbol svg body

Return type:

str

Example

>>> fsw_symbol_svg_body('S20500-C')
'  <text font-size="0">S20500-C</text>\n  <svg x="493" y="493">...</svg>'
sutton_signwriting_font.fsw.fsw_symbol_svg(fsw_sym)

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

Parameters:

fsw_sym (str) – an FSW symbol key with optional style string

Returns:

symbol svg

Return type:

str

Example

>>> fsw_symbol_svg('S20500-C')
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" ...>...</svg>'
sutton_signwriting_font.fsw.fsw_symbol_png(fsw_sym, scale=None)

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

Parameters:
  • fsw_sym (str) – an FSW 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 = fsw_symbol_png('S20500-C')
>>> png[:8] == b'\x89PNG\r\n\n'  # Valid PNG header
True
sutton_signwriting_font.fsw.fsw_symbol_png_data_url(fsw_sym, scale=None)

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

Parameters:
  • fsw_sym (str) – an FSW 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

>>> fsw_symbol_png_data_url('S20500-C').startswith('data:image/png;base64,')
True
sutton_signwriting_font.fsw.fsw_sign_normalize(fsw_sign)

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

Parameters:

fsw_sign (str) – an FSW sign with optional style string

Returns:

normalized sign

Return type:

str

Example

>>> fsw_sign_normalize('M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475')
'M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475'
sutton_signwriting_font.fsw.fsw_sign_svg_body(fsw_sign)

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

Parameters:

fsw_sign (str) – an FSW sign with optional style string

Returns:

sign svg body

Return type:

str

Example

>>> fsw_sign_svg_body('M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475-C')
'  <text font-size="0">M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475-C</text>\n  <svg x="476" y="466">...</svg>...'
sutton_signwriting_font.fsw.fsw_sign_svg(fsw_sign)

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

Parameters:

fsw_sign (str) – an FSW sign with optional style string

Returns:

sign svg

Return type:

str

Example

>>> fsw_sign_svg('M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475-C')
'<svg ...> ... </svg>'
sutton_signwriting_font.fsw.fsw_sign_png(fsw_sign, scale=None)

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

Parameters:
  • fsw_sign (str) – an FSW 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 = fsw_sign_png('M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475-C')
>>> png[:8] == b'\x89PNG\r\n\n'  # Valid PNG header
True
sutton_signwriting_font.fsw.fsw_sign_png_data_url(fsw_sign, scale=None)

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

Parameters:
  • fsw_sign (str) – an FSW 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

>>> fsw_sign_png_data_url('M525x535S2e748483x510S10011501x466S2e704510x500S10019476x475-C').startswith('data:image/png;base64,')
True
sutton_signwriting_font.fsw.fsw_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 (fsw_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": "AS14c20S27106M518x529S14c20481x471S27106503x489", "zoom": 1}]
>>> fsw_column_svg(col, {"height": 250, "width": 150}).startswith('<svg')
True
sutton_signwriting_font.fsw.fsw_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 (fsw_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": "AS14c20S27106M518x529S14c20481x471S27106503x489", "zoom": 1}]
>>> len(fsw_column_png(col, {"height": 250, "width": 150})) > 0
True
sutton_signwriting_font.fsw.fsw_columns_svg(fsw_text, options=None)

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

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

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

Returns:

array of svg columns

Return type:

List[str]

Example

>>> fsw_text = "AS14c20S27106M518x529S14c20481x471S27106503x489 AS18701S1870aS2e734S20500M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468 S38800464x496"
>>> opts = {"height": 250, "width": 150}
>>> len(fsw_columns_svg(fsw_text, opts))
1
sutton_signwriting_font.fsw.fsw_columns_png(fsw_text, options=None)

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

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

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

Returns:

array of PNG data

Return type:

List[bytes]

Example

>>> fsw_text = "AS14c20S27106M518x529S14c20481x471S27106503x489 AS18701S1870aS2e734S20500M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468 S38800464x496"
>>> opts = {"height": 250, "width": 150}
>>> len(fsw_columns_png(fsw_text, opts))
1
sutton_signwriting_font.fsw.fsw_columns_png_data_url(fsw_text, options=None)

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

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

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

Returns:

array of PNG data urls

Return type:

List[str]

Example

>>> fsw_text = "AS14c20S27106M518x529S14c20481x471S27106503x489 AS18701S1870aS2e734S20500M518x533S1870a489x515S18701482x490S20500508x496S2e734500x468 S38800464x496"
>>> opts = {"height": 250, "width": 150}
>>> all(u.startswith('data:image/png;base64,') for u in fsw_columns_png_data_url(fsw_text, opts))
True