Home  Contents

Multifont support

Graphics Core4 Lua Commands

SYNOPSIS

  1. success = fnt:load(filename)
  2. list = fnt:names()
  3. str = tostring(fnt)

DESCRIPTION

It is possible to load multiple font files into one instance of a font structure.

This is useful when working with several languages that differ greatly. An example would be to have one font file for western languages, one for arabic and one for chinese.

The initial font file that was used when the font instance was created is the main font of the list. The main font decides the line height and the position of the baseline.

When looking up characters in the font, the system first tries the main font. If that does not have the character, it will then go on trying each font in the list until one font matches. The list is tried in the order it was loaded. If no font has the character, the system will paint some indicator that the character is missing instead.

The function fnt:load() will load another font file into the list. It returns true or false to indicate success.

The query function fnt:names() returns a list with the names of each loaded font, starting with the main font. (The font name is not the file name, but is the name of the font as stored in the file itself.)

When calling tostring() on a font, it returns a human readable representation of the loaded fonts. This is meant as a debugging aid.

NOTES

The first font file used to create the font object is the main font. It decides the line height and position of the baseline.

When combining multiple fonts, make sure all fonts have about the same height and the same baseline position. If this is not the case, the overall result will look jagged, as characters from different fonts appear at different vertical alignments.

ERRORS

Raises an error if fnt is not a font handle.

EXAMPLE

>  >  > 
fnt = gfx.font("/usr/lib/fonts/western-50.lfn") fnt:load("/usr/lib/fonts/nazli-50.lfn") print (tostring(fnt))
{ "Western-50", "Nazli-50" }

SEE ALSO