Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C/C++ v10.0 : C library - <b>synopsis:</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <graph.h>
    short _FAR _setfont( char _FAR *opt );

Description:
    The _setfont function selects a font from the list of registered fonts
    (see the  _registerfonts function).  The font selected becomes the
    current font and is used whenever text is displayed with the  _outgtext
    function.  The function will fail if no fonts have been registered, or
    if a font cannot be found that matches the given characteristics.

    The argument opt is a string of characters specifying the
    characteristics of the desired font.  These characteristics determine
    which font is selected.  The options may be separated by blanks and are
    not case-sensitive.  Any number of options may be specified and in any
    order.  The available options are:

    hX
        character height X (in pixels)

    wX
        character width X (in pixels)

    f
        choose a fixed-width font

    p
        choose a proportional-width font

    r
        choose a raster (bit-mapped) font

    v
        choose a vector font

    b
        choose the font that best matches the options

    nX
        choose font number X (the number of fonts is returned by the
         _registerfonts function)

    t'facename'
        choose a font with specified facename

    The facename option is specified as a "t" followed by a facename
    enclosed in single quotes.  The available facenames are:

    Courier
        fixed-width raster font with serifs

    Helv
        proportional-width raster font without serifs

    Tms Rmn
        proportional-width raster font with serifs

    Script
        proportional-width vector font that appears similar to hand-writing

    Modern
        proportional-width vector font without serifs

    Roman
        proportional-width vector font with serifs

    When "nX" is specified to select a particular font, the other options
    are ignored.

    If the best fit option ("b") is specified, _setfont will always be able
    to select a font.  The font chosen will be the one that best matches the
    options specified.  The following precedence is given to the options
    when selecting a font:

     1. Pixel height (higher precedence is given to heights less than the
        specified height)

     2. Facename

     3. Pixel width

     4. Font type (fixed or proportional)

    When a pixel height or width does not match exactly and a vector font
    has been selected, the font will be stretched appropriately to match the
    given size.

Returns:
    The _setfont function returns zero if successful; otherwise, (-1) is
    returned.

See Also:
    _registerfonts, _unregisterfonts, _getfontinfo, _outgtext,
    _getgtextextent, _setgtextvector, _getgtextvector

Example:
    #include <conio.h>
    #include <stdio.h>
    #include <graph.h>

    main()
    {
        int i, n;
        char buf[ 10 ];

        _setvideomode( _VRES16COLOR );
        n = _registerfonts( "*.fon" );
        for( i = 0; i < n; ++i ) {
            sprintf( buf, "n%d", i );
            _setfont( buf );
            _moveto( 100, 100 );
            _outgtext( "WATCOM Graphics" );
            getch();
            _clearscreen( _GCLEARSCREEN );
        }
        _unregisterfonts();
        _setvideomode( _DEFAULTMODE );
    }

Classification:
    PC Graphics

Systems:
    DOS, QNX

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson