Oberon/ETH Oberon/font

This document was originally hosted at the ETHZ. It remains under the ETH license and is in the WayBack archive.

Back to: Native Oberon Hardware Compatiblity List

Font support
Summary

A type-font (or simply font) is a collection of screen or printer characters sharing a common typeface. Oberon is delivered with the custom designed font family "Oberon" created by Mr. H. Meier, after he created the "Syntax" font, the standard font of Oberon for Windows. Both families consist of several collections of varying size (8, 10 12, 14, 16, 20 and 24 points - 1 point = 1/72 inch) and style (normal, italic, bold - "Syntax" includes a medium bold style in addition).

Further font families are delivered with the Oberon system:

  • "Math" in the sizes 10, 12, 14, 16, 20 and 24 points of the normal style
  • "Greek" in the sizes 10, 12, 14, 16, 20 and 24 points of the normal style
  • "Courier" in the sizes 8, 10 and 12 points of the normal style. The only non-proportional font supplied

Screen fonts and printer fonts are stored in files with extensions .Scn.Fnt and .Prx.Fnt respectively (the x refers to x00dpi printer fonts). A full font name (like Syntax12b.Scn.Fnt) has to be specified to load a font.

Default font, current font, current color, current offset

When Native Oberon is started and Oberon.Text is in its original state, GUI (or TUI) text will have attributes defined by a number of global variables which are assigned default values.

    Fonts.Default := Fonts.This("Oberon10.Scn.Fnt");  
    Oberon.CurFnt := Fonts.Default; 
    Oberon.CurCol := Display.FG; (* = 15 - black *) 
    Oberon.CurOff := 0;

Fonts.Default is the font of text appearing in NamePlates, Buttons, Captions of the GUI, and will be used as default in cases where an invalid fontname is specified; that is, is not the name of a valid font file.
Oberon.CurFnt determines the font used when text is entered in a new viewer.
Oberon.CurColor determines the color used when text is entered in a new viewer.
Oberon.CurOff determines the vertical offset used when text is entered in a new viewer.

In Oberon for Windows, the default font is Syntax10.Scn.Fnt.

Assigning a new value to the current font - by command / program
  • System.SetFont (fontName | ^): fontName must be a valid font file name. The font file is opened and the font is loaded in cache. Void if not a valid font.
  • PROCEDURE SetFont (Fonts.This(fontName: ARRAY OF CHAR)); in Oberon.Mod. If fontName is not a valid font file name, the default font is used.
How to control which fonts are currently loaded
System.ShowLibraries
List the libraries currently in cache; that is, the font libraries and the others (*.Lib). The most recently loaded library appears on top.
System.FreeLibraries ({ libraryname} | ^) ~
Free the named libraries.

PROCEDURE This(fontName: ARRAY OF CHAR): Font; in Fonts.Mod

Open the font file and load the font in cache. If fontName is not a valid font file name, NIL is returned.

A font can also be loaded in cache in the context of ASCIITab.Tool.

Assigning a new value to the current color - by command / program
  • System.SetColor (color | ^) - 0 <= color <= 15
  • PROCEDURE SetColor (color: SHORTINT); in Oberon.Mod
Assigning a new value to the current offset - by command / program
  • System.SetOffset (voff | ^) - voff positive or negative integer
  • PROCEDURE SetOffset (voff: SHORTINT); in Oberon.Mod
Adding new fonts with OpenType

Instead of designing and producing a new font, one should take advantage of the current implementation of OpenType for Oberon described in OType.Text. Though it supports only the TrueType part of OpenType, it covers already most existing OpenType fonts. There are two ways to use OpenType.

  1. Convert a TTF to Oberon raster font files using the command OTFonts.Make. E.g.
    OTFonts.Make Arial.TTF Arial 8 10 12 14 16 20 24 Scn Pr3 Pr6~
  2. Generate Oberon raster font files dynamically when needed.

The font thus produced will map the character set represented in the TTF to the Oberon character set.

In another approach, one could design a program for mapping a font to Oberon, and we would suggest renaming the new font to avoid conflicts. For the font file format, look at the Internalize procedure in Fonts.Mod.

Adding new fonts with Gfx font extensions

Gfx: features a plug-in mechanism for adding other font formats than native Oberon bitmap and outline fonts. At the moment, two extensions are supported: TrueType fonts and Metafont pk bitmaps (used in Kaspar Fischer's DVI file viewer). TrueType support requires that the OType package is already installed. more in Gfx.Tool.

Definitions

The abstract data type Font has the following definition in module Fonts:

 TYPE 
   FontDesc = RECORD ( Objects.LibDesc )  
     type: SHORTINT;  (* Substitute, font, or metric. *) 
     height, minX, maxX, minY, maxY: INTEGER 
       (* Font height, extremal values of characters in font. *) 
   END;

Font is an extension of Library. Each character of the font is a (virtual) object indexed by ASCII code in a font library. The abstract data type Char has the following definition:

 TYPE 
   CharDesc* = RECORD (Objects.ObjDesc) 
   dx*, x*, y*, w*, h*: INTEGER; 
     (** Character width, pattern offset (x, y), pattern size (w, h). *) 
   pat*: Display.Pattern     (** Character raster data. *) 
   END;

[Top]

13 Jul 2002 - Copyright © 2002 ETH Zürich. All rights reserved.
E-Mail: oberon at lists.inf.ethz.ch
Homepage: http://www.ethoberon.ethz.ch/