Fog Info Global Memory Globals Table of Contents

Font List

Availability  LightWave® 6.0
Component  Modeler
Header  lwmodeler.h

The font list global provides a set of functions for managing Modeler's internal list of fonts.

Global Call

   LWFontListFuncs *fontf;
   fontf = global( LWFONTLISTFUNCS_GLOBAL, GFUSE_TRANSIENT );

The global function returns a pointer to an LWFontListFuncs.

   typedef struct st_LWFontListFuncs {
      int          (*count) (void);
      int          (*index) (const char *name);
      const char * (*name)  (int index);
      int          (*load)  (const char *filename);
      void         (*clear) (int index);
   } LWFontListFuncs;
numfonts = count()
Returns the number of fonts in the list.

fontindex = index( fontname )
Returns the list index for a named font, or -1 if a font of that name isn't in the list.

fontname = name( fontindex )
Returns the name of a font given its list index, or NULL if the index is less than 0 or greater than numfonts - 1.

fontindex = load( filename )
Adds the Postscript Type 1 font to the list and returns its list index, or -1 if the font couldn't be loaded. Since the font list is kept in an order that may differ from the order in which fonts are added, a font added by load might be inserted anywhere in the list, not just at the end, and fonts with higher indexes will be shifted downward (incrementing their indexes).

Note that only Postscript fonts can be added to the list in this way. TrueType fonts are made available to Modeler indirectly, through operating system calls, rather than directly by reading their file contents.

clear( fontindex )
Removes the font at the given index from the list. Fonts at higher indexes will be shifted up (their indexes will decrement) to fill the gap left by the removed font.

Example

This code fragment loads the Postscript font Helvetica.

   #include <lwserver.h>
   #include <lwmodeler.h>

   LWFontListFuncs *fontf;
   int index;

   fontf = global( LWFONTLISTFUNCS_GLOBAL, GFUSE_TRANSIENT );
   if ( !fontf ) return AFUNC_BADGLOBAL;

   /* You can get the default fonts directory from the
      Directory Info global. */

   index = fontf->load( "Helvetica.pfd" );