Hello all,
I need your help. I trying to change the font of texts displayed in the output of my program. I know that we can use settextstyle() for changing fonts. But there are only four types of fonts( GOTHIC, SANS SERIFF , TRIPLEX , DEFAULT) available. I want to use some other fonts like Lucida calligraphy and all other installed fonts in PC . Is there any way to do that? or should i change any thing in the header file graphics.h. I am using Turbo c++ .

Thanks all in advance!

Recommended Answers

All 8 Replies

Then you need to find some fonts compatible with Borland's graphics library.

Thanks for the reply Waltp. My problem is how to get that font working using outtextxy(). Are the installed PC fonts compatible with Turboc++ ? Should i mention the chr file along with the default fonts in the header file or should i attach it somewhere ?

I doubt it. It's going to take detective work on your part to find out. Ever watch "Cold Case Files"? That's what you're up against. Trying to figure out what works today with 20-30 year old compilers is going to take time and effort to get the answers you need.

commented: Bring your pickaxe and headlamp, because in the Borland Museum they don't take American Express... +14

I tried what you said WaltP and found out a bit.
Now i am trying to register a font. This is my code..

int main()
 int a=0,b=5;

 int handle;
 unsigned fsize;
 void *ayyhar;

 handle = open("HARRYP.CHR",O_RDONLY,O_BINARY);
 fsize= filelength(handle);

 ayyhar = malloc(fsize);
 if( read(handle, ayyhar, fsize) != fsize)
 {cout<<"unable to read from file";

 if( HP5_FONT != registerfarbgifont(ayyhar) ) //HP5_FONT is the public name i gave when converting chr file to obj using bgiobj.exe 
 {cout<<" unable to register file";
 close (handle);
 initgraph(&a, &b, " ");

 settextstyle(HP5_FONT, 0, 4);

 outtextxy(200, 100, "HELLO");


I get an compiler error " undefined symbol HP5_FONT". Where should i define it ? I tried defining it along with the enumfontnames in graphics.h. But i don't know it's value. What valu should HP5_FONT have actually?

You are in unknown territory. Since you "found out a bit", you are now the expert and know more than the rest of us. It seems that no one has tried this before, therefore cannot help any further.

Closest thing I can think of is debug the code and find out what values a working cont has, then try to make your new font mimic it. Or copy your new font over one that works and see what happens. Save the original, of course.

commented: -1 -1

I don't know about Turbo C++. I thought graphics.h was only for DOS?? But I know you can change colors and fonts with some Windows functions in <windows.h>

commented: Please read the entire thread before suggesting things that won't work for the user. -3

Yeah WaltP, i tried replacing the required font in the existing default one as you said. I just got a small shaded rectangle.

I know the value that is returned by registerfarbgifont() should be used in outtextxy(). But i always get -13 given by registerfarbgifont(). That's where my problem lies.

settextstyle(SANS_SERIF_FONT, HORIZ_DIR, 4); you can use this


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.