X font

New to FreeBASIC? Post your questions here.
Post Reply
qbasic
Posts: 20
Joined: May 15, 2009 13:12

X font

Post by qbasic »

I cannot get X font to load any fonts.
I have tried moving the fonts to C:\fonts and changing the path
but i still get file not found error.
Any help would be appreciated.
Billythebarge.
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Post by BasicScience »

Have you seen the documentation and examples at this site ?

http://xaviorsoft.freebasic.net/fbproduct/index.html
qbasic
Posts: 20
Joined: May 15, 2009 13:12

X font

Post by qbasic »

Yes I have dowloaded the doc and the examples.
Its those examples that do not load the fonts.
Using the font.fontname it says default.
Do I need a special font lib for xfonts as the file "xfont" set in the example
dose not seem to exist."C:\Program Files\FreeBASIC\inc\xfont\"

Thanks for answering.
Billythebarge.
BigBaddie
Posts: 40
Joined: Oct 10, 2009 10:08
Location: Space
Contact:

Post by BigBaddie »

first. are you using an ide to run your programs?
if so then instead of running the application via your ide, head to the
location where you compiled your source and double-click on it instead.
qbasic
Posts: 20
Joined: May 15, 2009 13:12

x font

Post by qbasic »

I have done as you sugested but I still get the same results.
First with fbide version 0.4.6 and again with
FbEdit version 1.0.7
This is the code I am using,maybe I have missed somthing.
#Include Once "xfont.bi"
Dim Shared As xfont.interface font
ScreenRes 640,480,32
font.loadfont ("c:\xfonts\fonts/gigi", 1)
if font.loadfont("c:\xfonts\fonts/gigi",1) then
Print "LoadFont Error. File not found."
End If
font.fontindex = 1
font.forecolor=rgb(200,100,200)
font.backcolor=rgb(100,200,100)

font.drawstring (," Hello World! ",10,10,2,2)
print font.fontname
Sleep

Billythebarge.
BasicScience
Posts: 489
Joined: Apr 18, 2008 4:09
Location: Los Angeles, CA
Contact:

Post by BasicScience »

Try This

Code: Select all

#Include Once "xfont.bi"
Dim Shared As xfont.interface font
Dim as integer id
ScreenRes 640,480,32
IF font.loadfont("freesans.xf",1) = -1 Then
    Print "Font not found"
end if
font.fontindex = 1
font.forecolor=rgb(200,100,200)
font.backcolor=rgb(200,200,100)

font.drawstring (," Hello World! ",10,20,2,2)
print font.fontname
Sleep 
The xFont Zip for Win32 contains a sample font file, freesans.xf. To run from FBIde, first make sure you save the code of this example program to your default FB folder which also contains freessans.xf.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

I also resolved the font problem by substituting freesans.xf, and compiling with FBC version 0.21.0 (03-09-2009) for win32 (target:win32), and this batch file:

Code: Select all

"c:\Program Files\freeBASIC\fbc" -v -C -R -s gui test.bas
pause
And using the Windows version of xfont and running under Windows 2000, the source compiles without error and the EXE runs OK.
qbasic
Posts: 20
Joined: May 15, 2009 13:12

xfont

Post by qbasic »

Yes your code works fine.
Dose this mean that i can't use normal window fonts
with xfont.
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Post by MichaelW »

To use a Windows font you must first convert it to the xfont format using the X-Font Converter application, available as a separate download.
Post Reply