UPT Programming Tool - Vector Fonts

 

Apologies - at the time of this writing (2018-08-22), vector fonts were already supported in the programming tool and in the MKT-View IV firmware, but with status 'work in progress' there was no time yet to describe them completely !

Contents

  1. Vector fonts
    1. Introduction to vector fonts (as used in MKT-View & Co)
    2. Using vector fonts in the programming tool
    3. Rotated text using vector fonts
    4. Displaying 'special characters' by their Unicode value

1.1 Introduction to vector fonts (as used in MKT-View & Co)

All credits for the vector fonts described in this chapter are to Dr. Allen Vincent Hershey, who designed them in the 1960s (!) during his work at the Naval Weapons Laboratory, Dahlgren, Virginia. In 2018, details were available at en.wikipedia.org/wiki/Hershey_fonts.
Each character (glyph) in a vector font consists of an array of coordinates, which can be used to render them on a graphic screen, plotter, printer, or (as in Dr. Hershey's original use) on a vector cathode ray display.

Compared to the older bitmap-fonts, vector-fonts have many advantages and a few disadvantages.
Advantages of vector fonts:
Disadvantages of vector fonts:


MKT-View IV (with 800 * 480 pixels) displaying the 'Hershey Simplex' font,
partially 'boldified' via tag <b> in the format string.


At the time of this writing (autumn 2019), vector fonts were only available in devices with ARM Cortex controllers, because older devices (with 8- and 16-bit CPUs, or older ARM7TDMI controllers like LPC2xxx) lacked memory or CPU power. Devices with built-in vector fonts are:


1.2 Using vector fonts in the programming tool

From a developer's point of view, it doesn't make a big difference if a display element is rendered with a bitmap- or vector font. Both can be selected from a drop-down list named 'Font' on the Display Line Properties panel, or the equivalent dialog 'Alphanumeric Display' for the graphic page editor.


Fractional zoom values for an alphanumeric display line with a vector font

After selecting a vector font (e.g. 'Hershey Simplex'), the input fields for horizontal (X) and vertical zoom (Y) accept fractional numbers, and the up/down buttons ('+'/'-') attached those fields step by 0.1 (instead of stepping by one for bitmap fonts).

In addition to the simple HTML-like <b> tag (which means 'bold' in the format string), the font-weight can be adjusted freely via format string. The weight defines the 'thickness' of lines (measured in pixels) when rendering a vector font on the screen. Without an explicit specification, the thickness of lines is automatically selected, depending on the zoom factor:
<w1> .. text .. </w>
Specify text weight as 'line width in pixels'. w1 is the thinnest possible line.
</w> switches back to the default font weight.

<w0> .. text ..
Switches back to the automatic selection of the line width, which depends on the vertical and horizontal zoom factors for text output.

As with most HTML-like tags and backslash-sequences in the format string, the font-weight can even be controlled through a variable. The application programs/HersheyFont.cvt (runs on MKT-View and the like) contains an example to modify these attributes during runtime, e.g.:

  <w(v)>This text will appear with variable line width, controlled by 'v'.</w>
Note: v can be used as placeholder for "the value in the current display line".

To check which characters are actually implemented in a certain font, open the 'font table' (which was originally developed to pick hexadecimal character codes for 'special characters').


(font table display, can be opened via button in the
Dialog for alphanumeric display elements
or by clicking the underlined label 'Font'
on the Display Line Properties panel)


1.3 Rotated text using vector fonts

Normal display elements cannot be rotated by arbitrary angles (in the UPT ecosystem).
But besides drawing lines and polygons, the backslash-sequence '\li' (in a format string) can also be used to draw text rotated by arbitrary angles.
At the time of this writing, the graphic editor did not support the syntax for rotated text (and rotated polygons) yet, thus the entire sequence had to be entered manually (as text in the editor's dialog box for display elements, or in the display line properties if you prefer the tabular input).

The following screenshot from page 'RotateText' in programs/HersheyFont.cvt illustrates the angle system (0° = normal text):

Backslash sequences used to create the effect shown above:


     X    Y    W    H     Display command (format string)   
    256   48  152   80    \li(w=2,0,55;rot=-25,"rot=-25°") 
    256  128  152   48    \li(w=2;10,10;"rot=0°")
    256  176  152   80    \li(w=2;12,2;rot=25,"rot=+25°")
    208   48   48  208    \li(w=2;40,2;rot=90,"rot=+90°")
    160   48   48  208    \li(w=2;12,200;rot=-90,"rot=-90°")
      8  176  152   80    \li(w=2;152,25;rot=155,"rot=155°")
      8  128  152   48    \li(w=2;150,40;rot=180,"rot=180°")
      8   48  152   80    \li(w=2;140,80;rot=205,"rot=205°")
Notes:

1.4 Displaying 'special characters' by their Unicode value

Since 2018, 'Hershey Simplex' font contains a few glyphs that may be addressed via their hexadecimal Unicode value ("codepoint"). In the format string of a display element (text, button, etc), they can be embedded as backslash-U, followed by "+" and the character's code (hex without prefix). Example from programs/HersheyFont.cvt :