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!

Edited 5 Years Ago by Arbus: n/a

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 ?

Edited 5 Years Ago by Arbus: n/a

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.

Comments
Bring your pickaxe and headlamp, because in the Borland Museum they don't take American Express...

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

#include<iostream.h>
#include<graphics.h>
#include<io.h>
#include<process.h>
#include<stdlib.h>
#include<alloc.h>
#include<fcntl.h>
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";
  exit(1);
 }

 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");

 return(0);
}

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?

Edited 5 Years Ago by Arbus: n/a

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.

Comments
-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>

Comments
Please read the entire thread before suggesting things that won't work for the user.

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.

Edited 5 Years Ago by Arbus: n/a

This article has been dead for over six months. Start a new discussion instead.