如何在C编程图形中使文本更大 [英] How do I make the text bigger in C programming graphics

查看:90
本文介绍了如何在C编程图形中使文本更大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经厌倦并尝试过,但我得到的只是错误。



我尝试了什么:



这是一个例子



I have tired and tried, but all i get is errors.

What I have tried:

Here is an example

#include <graphics.h>
 
main()
{
   int gd = DETECT, gm, x = 25, y = 25, font = 0;
 
   initgraph(&gd,&gm,"NULL");
 
   for (font = 0; font <= 10; font++)
   {
      settextstyle(font, HORIZ_DIR, 1);
      outtextxy(x, y, "Text with different fonts");
      y = y + 25;
   }
 
   getch();
   closegraph();
   return 0;
}







In function ‘int main()’:
warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    initgraph(&gd,&gm,"NULL");
                            ^
error: ‘HORIZ_DIR’ was not declared in this scope
       settextstyle(font, HORIZ_DIR, 1);
                          ^
error: ‘settextstyle’ was not declared in this scope
       settextstyle(font, HORIZ_DIR, 1);
                                      ^
warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
       outtextxy(x, y, "Text with different fonts");

推荐答案

为了避免警告,请在源文件的顶部添加以下行:

To avoid the warnings add this line on top of your source file:
# pragma GCC diagnostic ignored "-Wwrite-strings"





initgraph 调用应该更改为传递 NULL 而不是字符串参数NULL:



The initgraph call should probably be changed to pass NULL instead of the string parameter "NULL":

initgraph(&gd,&gm,NULL);





最后给坏消息。似乎BGI(Borland图形界面)的Linux移植不支持文本样式。头文件 graphics.h 包括另一个头文件 grtext.h ,它提供了 outtextxy()的定义,但不是 settextstyle()和与该函数相关的常量,如 HORIZ_DIR



您可能会考虑使用其他图形界面,而不是最初为Turbo C / C ++提供的用于MS-DOS和Windows 95的过时图形驱动程序界面的Linux端口。



Finally to the bad news. It seems that the Linux porting of the BGI (Borland Graphics Interface) does not support text styles. The header file graphics.h includes another header file grtext.h which provides definitions for outtextxy() but not for settextstyle() and constants related to that function like HORIZ_DIR.

You might think about using other graphic interfaces than a Linux port of an outdated graphics driver interface that was initially provided with Turbo C/C++ for MS-DOS and Windows 95.


这篇关于如何在C编程图形中使文本更大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆