Borland C++ reference

settextstyle

raw OCR

Sets the current text characteristics for graphics output.

Defined in header <graphics.h>

Syntax

#include <graphics.h>
void  far settextstyle(int  font, int direction, int charsize);

Portability

DOSUNIXWindowsANSI CC++ only
■

Remarks

settextstyle sets the text font, the direction in which text is displayed, and the size of the characters. A call to settextstyle affects all text output by outtext and outtextxy.

The parameters/onf, direction, and charsize passed to settextstyle are described in the following:

font: One 8x8 bit-mapped font and several "stroked" fonts are available. The 8x8 bit-mapped font is the default. The enumeration font_names, defined in graphics.h, provides names for these different font settings:

NameValueDescription
DEFAULTFONT08x8 bit-mapped font
TRIPLEX FONT1, Stroked triplex font
SMALL FONT2Stroked small font
SANS SERIF FONT3Stroked sans-serif font
GOTHIC FONT4Stroked gothic font
SCRIPT FONT5Stroked script font
SIMPLEX FONT6Stroked triplex script font
TRIPLEX_SCR_FONT 7Stroked triplex scriptfont
COMPLEX_FONT8Stroked complex font
EUROPEAN_FONT9Stroked European font
BOLD_FONT10Stroked bold font

The default bit-mapped font is built into the graphics system. Stroked fonts are stored in '^.CHR disk files, and only one at a time is kept in memory. Therefore, when you select a stroked font (different from the last selected stroked font), the corresponding *.CHR file must be loaded from disk.

To avoid this loading when several stroked fonts are used, you can link font files into your program. Do this by converting them into object files with the BGIOBJ utihty, then registeriitg them through registerbgifont, as described in UTIL.DOC, included with your distributions disks.

direction: Font directions supported are horizontal text (left to right) and vertical text (rotated 90 degrees counterclockwise). The default direction is HORIZ DIR.

NameValueDescription
HORIZ_DIR0Left to right
VERT_DIR1Bottom to top

charsize: The size of each character can be magnified using the charsize factor. If charsize is nonzero, it can affect bit-mapped or stroked characters. A charsize value of 0 can be used only with stroked fonts.

Q If charsize equals 1, outtext and outtextxy displays characters from the 8x8 bit-mapped font in an 8x8 pixel rectangle onscreen. a If charsize equals 2, these output functions display characters from the 8x8 bit-mapped font in a 16x16 pixel rectangle, and so on (up to a limit of ten times the normal size). □ When charsize equals 0, the output functions outtext and outtextxy magnify the stroked font text using either the default character magnification factor (4) or the user-defined character size given by setusercharsize.

Always use textheight and textwidth to determine the actual dimensions of the text.

Return value

None.

See also

Example

 #include <graphics.h>
 #include <st(ilib.h>
 #include <stdio.h>
 #include <conio.h>

,/* the names of the text styles supported */
 char *fname[] = { "DEFAULT font",  "TRIPLEX font",
                   "SMALL font",    "SANS SERIF font",
                   "GOTHIC font",   "SCRIPT font",
                   "SIMPLEX font",  "TRIPLEX SCRIPT font'
                   "COMPLEX font",  "EUROPEAN font",
                   "BOLD font"};
 int main(void)

    /* request autodetection */
    int gdriver = DETECT, gmode, errorcode;
    int style, midx, midy;
    int size = 1;
    /* initialize graphics and local variables */
    initgraph(&gdriver, Sigmode, "");

    /* read result of initialization */
    errorcode = graphresult ();
    if (errorcode != grOk) {  /* an error occurred */
       printf("Graphics error: %s\n", grapherrormsg (errorcode));
       printf("Press any key to halt:");
       getchO ;
       exit(l);               /* terminate with an error code  */
    }
   midx  = getraaxx() / 2;
   midy  = getraaxyO / 2;
    settext]UStify(CENTER_TEXT, CENTER_TEXT);

    /* loop through the available text styles */
    for (style=DEFAULT_FONT; style<=BOLD_FONT; style++) {
       cleardevice();
       if (style == TRIPLEX_FONT)
          size = 4;
       /* select the text style */
       settextstyle(style, HORIZ_DIR, size);

       /* output a message */
       outtextxy(midx, midy, fname[style]);
       getchO ;
    }
    /* clean up */
   closegraphO  ;
return

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.