Skip to content

Exporter

Details

  • File: FontGenerator/Exporter.py
  • Details: Python 3.9
  • Date: 2022-10-08
  • Version: v1.0.0

Description

Exporter for the font generator.

Author

Sebastian Oberschwendtner, 📧 sebastian.oberschwendtner@gmail.com


Code


get_namespace_for_size

def get_namespace_for_size(size: int) -> str

[view_source]

Converts the font size to a namespace.

Arguments:

  • size int - 1x1 [px] The font size in pixels.

Returns:

  • str - 1xn [str] The namespace for the font size.

def write_copyright_header(file: pathlib.Path)

[view_source]

Writes the copyright header to the file.

Arguments:

  • file pathlib.Path - 1x1 [-] The file to write to.

get_array_line

def get_array_line(line_number: int, array: list) -> str

[view_source]

Get the line of an array as a string.

Arguments:

  • line_number int - 1x1 [-] The line number of the array in the file.
  • array list - 1xn [-] The array to write.

Returns:

  • str - 1x1 [-] The line of the array.

write_lookup_table_preamble

def write_lookup_table_preamble(file: pathlib.Path, font_name: str)

[view_source]

Write the preamble of the lookup table.

Arguments:

  • file pathlib.Path - 1x1 [-] The file to write to.
  • font_name str - 1x1 [-] The name of the font.

write_lookup_table_begin

def write_lookup_table_begin(file: pathlib.Path, font_name: str, size: tuple)

[view_source]

Write the beginning of the lookup table.

Arguments:

  • file pathlib.Path - 1x1 [-] The file to write to.
  • font_name str - 1x1 [-] The name of the font.
  • size tuple - 1x2 [px] The (width, height) of the font.

write_lookup_table_end

def write_lookup_table_end(file: pathlib.Path, font_name: str, size: tuple,
                           stride: int)

[view_source]

Write the end of the lookup table.

Arguments:

  • file pathlib.Path - 1x1 [-] The file to write to.
  • font_name str - 1x1 [-] The name of the font.
  • size tuple - 1x2 [px] The (width, height) of the font.
  • stride int - 1x1 [-] The stride of the font.

finalize_file

def finalize_file(file: pathlib.Path, font_name: str)

[view_source]

Finalize the file.

Arguments:

  • file pathlib.Path - 1x1 [-] The file to write to.
  • font_name str - 1x1 [-] The name of the font.