gettextsettings
raw OCR
Gets information about the current graphics text font.
Defined in header <graphics.h>
Syntax
#include <graphics.h>
void far gettextsettings(struct textsettingstype far *texttypeinfo);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
gettextsettings fills the textsettingstype structure pointed to by textinfo with information about the current text font, direction, size, and justification.
The textsettingstype structure used by gettextsettings is defined in graphics.h as follows:
struct textsettingstype { int font; int direction; int charsize; int horiz; int vert; }; See settextstyle for a description of these fields.
Return value
None.
See also
Example
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
/* the names of the supported fonts */
char *font[] = { "DEFAULT_FONT" , "TRIPLEX_FONT", "SMALL_FONT", "SANS_SERIF_FONT"
"GOTHIC_FONT" };
/* the names of the text directions supported */
char *dir[] = { "HORIZ_DIR", "VERT_DIR" };
/* horizontal text justifications supported */
char *hjust[] = { "LEFT_TEXT", "CENTER_TEXT", "RIGHT_TEXT" };
/* vertical text justifications supported */
char *vjust[] = { "BOTTOM_TEXT", "CENTER_TEXT", "TOP_TEXT" };
int main (void)
{
/* request autodetection */
int gdriver = DETECT, gmode, errorcode;
struct textsettingstype textinfo;
int midx, midy, ht;
char fontstr[80], dirstr[80], sizestr[80];
char hjuststr [80], vjuststr[80];
/* initialize grapliics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult ();
if (errorcode != grOk) { /* an error occurred */
printf( "Graphics error: %s\n", grapherrormsg(errorcode)) ;
printf( "Press any Icey to halt:");
getchO ;
exit(l); /* terminate with an error code */
}
midx = getmaxx () / 2;
midy = getmaxyO / 2;
/* get information about current text settings */
gettextsettings (Sctextinfo) ;
/* convert text -information into strings */
sprintf (fontstr, "%s is the text style.", font[textinfo.font]);
sprintf (dirstr, "%s is the text direction.", dir[textinfo.direction]);
sprintf (sizestr, "%d is the text size.", textinfo.charsize);
sprintf (hjuststr, "%s is the horizontal justification.",
hjust [textinfo.horiz]);
sprintf (vjuststr, "%s is the vertical justification.", vjust[textinfo.vert]
/* display the information */
ht = textheight("W") ;
settextjustify (CENTER_TEXT, CENTER_TEXT);
outtextxy (midx, midy, fontstr);
outtextxy (midx, midy+2*ht, dirstr);
outtextxy (midx, midy+4*ht, sizestr);
outtextxy (midx, midy+6*ht, hjuststr);
outtextxy (midx, midy+8*ht, vjuststr);
/* clean up */
getchO;
closegraphO ;
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/graphics.h/gettextsettings/
· short form /3.1/gettextsettings/