Introduction

The ndots module contains three special matrix font, to be used in applications:

 

Installation

Usage

In order to use a font:

from ndots import fiftydots

Each font has a couple of methods:

 

grid

returns a list of boolean lists to represent the text s in the font

Parameters

s : str string to represent

default : str if a character has no representation in the font, it will be replaced with default, that is a blank by default if the length is not 1, a ValueError will be raised

intra : int number of dots between characters default is 1

proportional : bool if proportional is False (default), all characters will be 5 dots wide if proportional is True, the actual width of the character will be used Note that in case of proportional, a blank will be 2 dots wide.

width : int width in dots of the result the default is the actal width (no align applied) if the actual width is smaller than width, the string will be padded according to the align parameter if the actual width is larger than width, the string is chopped according to the align parameter

align : str if align starts with a c (default), the result will be centered if align starts with a l, the result will be left aligned if align starts with a r, the result will be right aligned

narrow : bool if False (default), blanks will be 2 wide when proportional is True if True, blanks will be 1 wide when proportional is True

Returns

the representation of s : list of boolean lists each set dot will be True, not set False

coordinates

returns a list of coordinates representing the text s in the font

Parameters

s : str string to represent

value : bool if True (default), the set dots will be returned if False, the non set dots will be returned

default : str if a character has no representation in the font, it will be replaced with default, that is a blank by default if the length is not 1, a ValueError will be raised

intra : int number of dots between characters default is 1

proportional : bool if proportional is False (default), all characters will be 5 dots wide if proportional is True, the actual width of the character will be used Note that in case of proportional, a blank will be 2 dots wide.

width : int width in dots of the result the default is the actal width (no align applied) if the actual width is smaller than width, the string will be padded according to the align parameter if the actual width is larger than width, the string is chopped according to the align parameter

align : str if align starts with a c (default), the result will be centered if align starts with a l, the result will be left aligned if align starts with a r, the result will be right aligned

x_first : bool if False (default), coordinates will be given row by row if True, coordinates will be given column by column

narrow : bool if False (default), blanks will be 2 wide when proportional is True if True, blanks will be 1 wide when proportional is True

x_offset : int adds this value to each of the x-coordinates (default 0)

y_offset : int adds this value to each of the y-coordinates (default 0)

Returns

a list of coordinates (tuples)

grid_to_str

returns a string representing the given string s, using * if a pixel is set, and a space if not.

each line is prefixed with leftborder and postfixed with rightborder. all parameters for grid may be given as well.

width

width() returns the with of the font (3 of 5)

height

height returns the height of the font (5, 8 or 10)

name

name() returns the name of the font

has_char()

has_char(char) returns True if char is defined in the font, False if not

The module has one function:

available_fonts

ndots.available_fonts() returns a tuple with the three defined fonts