settextstyle

王朝百科·作者佚名  2010-04-09  
宽屏版  字体: |||超大  

函数名: settextstyle

功 能: 为图形输出设置当前的文本属性

用 法: void far settextstyle (int font, int direction, char size);

fornt 为字体:DEFAULT_FONT, TRIPLEX_FONT, SMALL_FONT, SANSSERIF_FONT, GOTHIC_FONT,也可以用0 ~ 4代替。

direction 为字符的排列方向:横向和竖向,0为横向排列,1为竖向排列。

size 为字体大小:可用interger做参数。

程序例:

#include <graphics.h>

#include <stdlib.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"

};

int main(void)

{

/* request auto detection */

int gdriver = DETECT, gmode, errorcode;

int style, midx, midy;

int size = 1;

/* initialize graphics and local variables */

initgraph(&gdriver, &gmode, "");

/* read result of initialization */

errorcode = graphresult();

if (errorcode != grOk) /* an error occurred */

{

printf("Graphics error: %s

", grapherrormsg(errorcode));

printf("Press any key to halt:");

getch();

exit(1); /* terminate with an error code */

}

midx = getmaxx() / 2;

midy = getmaxy() / 2;

settextjustify(CENTER_TEXT, CENTER_TEXT);

/* loop through the available text styles */

for (style=DEFAULT_FONT; style<=GOTHIC_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]);

getch();

}

/* clean up */

closegraph();

return 0;

}

 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
© 2005- 王朝百科 版权所有