Skip to main content

ndots - matrix fonts

Project description

Introduction

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

  • fifteendots (5 * 3 font)

    an ultra tiny font (particularly useful for digits)

  • fiftydots (10 * 5 font)

    a full fledged font, including many accented letters

  • twentyfourdots (8 * 3 font)

    a tiny font to be used when horizontal space is at a premium

Installation

pip install ndots

Usage

In order to use a font:

from ndots import fiftydots

Each font has a couple of methods:

grid

def grid(s,
         default=" ",
         intra=1,
         proportional=False,
         width=None,
         align="c",
         narrow=False)

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

def coordinates(s,
                value=True,
                default=" ",
                intra=1,
                proportional=False,
                width=None,
                align="c",
                x_first=False,
                narrow=False,
                x_offset=0,
                y_offset=0)

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

def grid_to_str(s, leftborder="<", rightborder=">", **kwargs)

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)

fiftydots.width() ==> 5

height

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

fiftydots.height() ==> 10

name

name() returns the name of the font

fiftydots.name() ==> "fiftydots"

has_char()

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

fiftydots.has_char("A") ==> True

The module has one function:

available_fonts

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

"|".join(font.name[5] for font in ndots.available_fonts()) ==> "fifte|fifty|twent"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ndots-1.0.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ndots-1.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file ndots-1.0.0.tar.gz.

File metadata

  • Download URL: ndots-1.0.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for ndots-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2f19aaee07935479a3f3a9bb40dff888a1897763283c172614017cbf17bbbd8a
MD5 9a7745ecabf8deaa4e3817ede92d70a4
BLAKE2b-256 5565c4e5a0925d09a9a0fa38b4f2a2d2bd9663f8fd77ef59cdd49e03a4b069d8

See more details on using hashes here.

File details

Details for the file ndots-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: ndots-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for ndots-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d09cbd51b4feac6a6e01c2633d194afec804824311ce63f956e92dd43b6b6ed
MD5 4e2734d80263e8f7d400cd0c2550d4b2
BLAKE2b-256 743ac635ba04523c24ebb5167b5ec5aea63fc475b80d61ad9f3767176b4b9301

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page