Click or drag to resize

9.3.1 Defining Fonts

On the SP-ICE-3 Card, a font is simply a collection of key-value pairs, where each key is a character-code, and the corresponding value is a glyph definition.

  • Glyph

    An arbitrary shape corresponding to all or part of a letter, numeral, punctuation mark, etc.[Note 1]

    Note that although we can use the same name or character-code (e.g. letter 'a', 0x61 ) to refer to particular item in any of many thousands of fonts, the corresponding glyph for that item is (usually) unique to one particular font.

    For instance, the glyph for the letter 'a' in the Times Roman font (a) is different to that in the Courier (a) font, yet they share the same name and character-code.

    Conversely, within a given font, a particular glyph might well be re-used in several places, so that e.g. letter 'O' and numeral 'O' (zero) might share the same glyph, even though both are present in the font with distinct names and character-codes.

  • Within the font, each glyph is defined by its own CommandList, which can be treated as a sub-routine, and may in turn reference other sub-routines.

  • Within a glyph definition, only relative vectors are used: see 9.1.1 Straight Lines and Jumps.

  • Luckily for us, most of these nasty details are hidden away behind the user-friendly Font class and FontAPI.

Defining a Font

  1. A font is nothing without glyphs to which we can assign character-codes, so our first task is to design (or obtain) some suitable glyphs.

    • A detailed discussion of the principles of font design is well beyond the scope of this manual: please refer to the established literature for such guidance.

  2. Armed with a set of glyph designs, we can now cast them into a form suitable for defining the font's characters.

    • Note that for the following example we are using an Em-square size of 1000 units.

      However, this is an arbitrary choice, and we can scale the characters at will during the marking process.

    Defining glyphs for the numerals 0 to 9, and a space character.
    CommandList c0 = new CommandList();
    c0.AppendJumpRel( 500, 1000 );
    c0.AppendMarkRel( 0, -500 );
    c0.AppendMarkRel( 0, -500 );
    c0.AppendMarkRel( -500, 0 );
    c0.AppendMarkRel( 0, 500 );
    c0.AppendMarkRel( 0, 500 );
    c0.AppendMarkRel( 500, 0 );
    c0.AppendJumpRel( 500, -1000 );
    
    CommandList c1 = new CommandList();
    c1.AppendJumpRel( 500, 0 );
    c1.AppendMarkRel( 0, 1000 );
    c1.AppendJumpRel( 500, -1000 );
    
    CommandList c2 = new CommandList();
    c2.AppendJumpRel( 0, 1000 );
    c2.AppendMarkRel( 500, 0 );
    c2.AppendMarkRel( 0, -500 );
    c2.AppendMarkRel( -500, 0 );
    c2.AppendMarkRel( 0, -500 );
    c2.AppendMarkRel( 500, 0 );
    c2.AppendJumpRel( 500, 0 );
    
    
    
                #
                # ... and so on, for all the other numerals up to 9.
                #
    
    
    
    CommandList space = new CommandList();
    space.AppendJumpRel( 500, 0 );
  3. Now that we have some glyphs, we can use them to define a font.

    • We can define as many fonts as we like [Note 2] - they are distingushed on the card simply by the ID number which we supply to the constructor.

    Defining a font.
                #
                # We are going to define the font with id = 0.
                #
    
    
    Font font = new Font( 0 );
    
    font.AddChar( ' ', space );
    font.AddChar( '0', c0 );
    font.AddChar( '1', c1 );
    font.AddChar( '2', c2 );
    font.AddChar( '3', c3 );
    font.AddChar( '4', c4 );
    font.AddChar( '5', c5 );
    font.AddChar( '6', c6 );
    font.AddChar( '7', c7 );
    font.AddChar( '8', c8 );
    font.AddChar( '9', c9 );
    
    client.Font.Set( font );
    
    
                #
                # note that the last statement sends the font definition to the card.
                #
Notes
  1. Sometimes also called outline, although this term is rather inappropriate for the simple, single-stroke fonts typically used when marking serial numbers or date/time stamps.

  2. Modulo available memory, of course.