Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_setfont() set current font</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _setfont()              Set current font

 #include   <graph.h>

 short _setfont(options);
 unsigned char _far *options;           Option string

    The _setfont() function finds a single font among all registered
    fonts that has the characteristics specified by options and
    makes it the current font. options is a string of characters
    that indicates which font you want; here are the possible options
    (separate them with blanks in the string):

    t'fontname'    Typeface.
    hx             Character height (x is number of pixels).
    wy             Character width (where y is the number of pixels).
    f              Fixed-space font only.
    p              Proportionally spaced font only.
    v              Vector font.
    r              Raster-mapped font.
    b              Find the best fit.
    nx             Choose font number x; nx can step through all fonts
                        (use nx by itself, not in combination)

    For example, to choose the third registered font, the options string
    would be "n3". Valid typeface names for the t'fontname' option
    include:

     Courier     Helv     Tms Rmn      Script      Modern     Roman

    Returns:    Font index is successful; < 0 value otherwise.

   Portability:     MS-DOS only, true MDPA, CGA, EGA, MCGA, or VGA video
                    compatibles

   -------------------------------- Example ---------------------------------

     This program uses _setfont() to make a font the default.

    #include <conio.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <graph.h>

    unsigned char *tstring = "Here is the Text";

    void main()
    {
        struct videoconfig vstruc;
        struct _fontinfo finfo;
        short nfont, maxfonts, halfinx, halfiny;

        _setvideomode(_MAXRESMODE);
        _getvideoconfig(&vstruc);
        _registerfonts("*.FON");
        _clearscreen(_GCLEARSCREEN);

        halfinx = vstruc.numxpixels/2 - _getgtextextent(tstring)/2;
        halfiny = vstruc.numypixels/2 + _getgtextextent(tstring)/2;
        _moveto(halfinx, halfiny);

        _setfont("n1");     /* Display first font */
        _setgtextvector(1, 0);
        _outgtext(tstring);
        _setgtextvector(-1, 0);
        _outgtext(tstring);
        _getfontinfo(&finfo);
        getch();

        _unregisterfonts();
        _setvideomode(_DEFAULTMODE);
    }

See Also: _getfontinfo() _outgtext() _registerfonts() _unregisterfonts()

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