Skip to content

Font Tables

Chapter 7-7
Font Tables

Introduction

Domino and Notes store the definitions of additional font faces (font faces other than FONT_FACE_xxx) in a special item called a font table. This chapter explains how to use the C API to access font tables in documents.


The Font Table Item

A font table resides in a special item with field name $Fonts (ITEM_NAME_FONTS) and data type TYPE_COMPOSITE. Each entry in a font table associates a font ID with information that describes the font in a platform-independent manner.

A font table is necessary when a rich text field in a document contains text that uses font faces other than the standard ones (FONT_FACE_ROMAN, FONT_FACE_SWISS, and FONT_FACE_TYPEWRITER).

When a Notes user assigns a non-standard font face to document text, Notes creates a font table item, assigns a unique ID to that font face, and associates the ID with a description of that font face in an entry in the font table. The CDTEXT records in the rich text field refer to the ID in the font table.

A C API program must add a font table to a document in order to give text in a rich text field any font face other than FONTID_ROMAN, FONTID_SWISS, or FONTID_TYPEWRITER.

Creating the Font Table

The data value of a font table item consists of a CDFONTTABLE record followed by one or more CDFACE records.

CDFONTTABLE
CDFACE
CDFACE
CDFACE
...

The C API header file editods.h defines the CDFONTTABLE structure. It consists of a Header member and a Fonts member. The Fonts member must be set to the number of CDFACE structures in the FONTTABLE.

The CDFACE structure contains the members Face, Family, and Name. The Face member is an application-assigned font ID for this font. The Family and Name members are the family code and name of the font associated with the font ID. Do not use font IDs 0 through 4, since these are hard-coded in Domino and Notes. The application should assign font IDs starting with the number STATIC_FONT_FACES (5), which is defined in fontid.h.

The Family member of the CDFACE structure is a BYTE in which the four low-order bits specify the pitch of the font and the four high-order bits specify the font family.

For Windows programs, use the values as defined in windows.h:

/ PitchAndFamily pitch values (low 4 bits) /

define DEFAULT_PITCH   0x00

define FIXED_PITCH     0x01

define VARIABLE_PITCH  0x02


/ PitchAndFamily family values (high 4 bits) /

define FF_DONTCARE     0x00

define FF_ROMAN        0x10

define FF_SWISS        0x20

define FF_MODERN       0x30

define FF_SCRIPT       0x40

define FF_DECORATIVE   0x50


Use NSFItemAppend to write a field named $FONTS (#defined as ITEM_NAME_FONTS in stdnames.h) to the note. This adds the font table to the note.


Using a Font in the Font Table

To use one of the fonts listed in the font table in a rich text field, set the CDTEXT FontID field to the application-assigned ID (the Face member in the CDFACE structure).


The FONTBL Sample Program

This section examines FONTBL, a sample program that creates a document, adds a font table to the document, and uses fonts from the font table to writes some rich text to a rich text field.

Creating a Font Table Structure in Sample Program FONTBL

/ #defines for fonts included in the font table /

define FTFAMILY_UNKNOWN  0xF0   / Font family /

define DEFAULT_PITCH     0x00

define FIXED_PITCH       0x01

define VARIABLE_PITCH    0x02


#define FTFACE_ID   STATIC_FONT_FACES  / starting ID number for the font
                                         face in the font table
/

#define NUM_FONTS     2    / number of fonts in the font table /

/ Fill in the font table with the following fonts:
  System Monospaced and System Proportional
/


   fntTable.Header.Signature = SIG_CD_FONTTABLE;
  fntTable.Header.Length = ODSLength(_CDFONTTABLE) + (ODSLength(_CDFACE) * NUM_FONTS);
  fntTable.Fonts = NUM_FONTS;   / number CDFACE records follow /


    ODSWriteMemory( (void far * far )&pCDBuffer, _CDFONTTABLE, &fntTable, 1 );

/
The ID number of the font face in the font table start at FTFACE_ID
  (number 5).  ID numbers 0 - 4 are hard-coded /


   fntFace[0].Face = FTFACE_ID;          /
ID number of face /

   /
Font family /
  fntFace[0].Family = FTFAMILY_UNKNOWN | FIXED_PITCH;
  strcpy (fntFace[0].Name, "System Monospaced");   /
Font name /



   fntFace[1].Face = FTFACE_ID + 1;       /
ID number of face /

   /
Font family /
  fntFace[1].Family = FTFAMILY_UNKNOWN | VARIABLE_PITCH;
  strcpy (fntFace[1].Name, "System Proportional"); /
Font name */



Store the Font Table Structure in a Field Named $FONTS in the Note.


/ Write a field named $FONTS to the note. This field specifies the
  font table used with the note.
/


   if (error = NSFItemAppend ( note_handle,
              0,
              ITEM_NAME_FONTS,
              (WORD) strlen(ITEM_NAME_FONTS),
              TYPE_COMPOSITE,
              pCDBufferStart,
              pCDBuffer-pCDBufferStart))
  {
     NSFNoteClose (note_handle);
     NSFDbClose (db_handle);
     API_RETURN (ERR(error));
  }


Once you have written the font table to the note, you can set the CDTEXT FontID field of a rich text structure to the Face ID of one of the fonts in the font table.