c多语言字体问题,c语言 字体显示问题

匿名用户

1级

2009-07-10 回答

曾经看过的类似问题:

C语言中字体的问题

C语言中有两种显示方式,即文本方式和图形方式。就我所知,只能在图形方式下控制字体.

先看一下C中定义的几种字体

名称 索引值 字体说明

DEFAULT_FONT 0 8x8 bit-mapped font

TRIPLEX_FONT 1 Stroked triplex font

SMALL_FONT 2 Stroked small font

SANS_SERIF_FONT 3 Stroked sans-serif font

GOTHIC_FONT 4 Stroked gothic font

(字体说明中的英文解释无须明白,在例子的演示中去看)

请看例子(摘自TC3.0的联机帮助文件)

例一.

#include

#include

#include

#include

/* 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\n", 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;

}

原代码讲解:

上面的例子中,控制字体用settextstyle函数,style参数是选择字体的,关于其它的参数说明可参考联机帮助。Outtextxy函数用来输出文本。

如果老兄是想显示各种不同字体的汉字话,那得麻烦点。这里不想多说,只提供两种方案

(1) 利用UCDOS的汉字特显技术,用C中的printf函数带上特殊参数即可,具体可参考有关资料(比如《电脑爱好者》中曾讲过)

(2) 在图形模式下,调用字体文件,用C函数putpixel输出。推荐参考书

[1]《C语言最新编程技巧200例》(修订本)鲁沐浴主编 电子工业出版社 1997

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值