IonicWind Software

Creative Basic => General Questions => Topic started by: aurelCB on April 04, 2010, 07:57:27 AM

Title: New Font
Post by: aurelCB on April 04, 2010, 07:57:27 AM
Hi all..
I try to add external font and i do this sometimes but i lost source code.
So i try on this way but without succses.
What i do wrong ? Any idea?
I use .fnt and try also .fon extension.
I also download small font maker called Fony.

'main window app
Def w1:window
Def hfont:uINT
CONST WM_SETFONT = 0x30
CONST DEFAULT_CHARSET = 1
CONST ANSI_CHARSET = 0

Declare "gdi32", CreateFontA(nHeight:INT,nWidth:INT,nEsc:INT,nOri:INT,fnWeight:INT,fnItalic:INT,fnUnderline:INT,fnStrikeOut:INT,fnCharSet:INT,fnOutPrecision:INT,fnClipPrecision:INT,fnQuality:INT,fnPAFamily:INT,fnName:STRING),INT
'Private (nHeight,nWidth,nEscapement,nOrientation,fnWeight,fdwItalic,fdwUnderline,fdwStrikeOut,fdwCharSet,fdwOutputPrecision,fdwClipPrecision,fdwQuality,fdwPitchAndFamily,lpszFace As String) As Long
'open window
Window w1,0,0,500,400,@minbox,0,"MainGUI",main
Setwindowcolor w1,rgb(220,220,220)
'--------------------------------------------------------

hfont = CreateFontA(15,0,0,0,400,0,0,0,1,0,0,0,2,getstartpath+"Dina.fnt")
'CreateFont(_fsize,0,0,0,_ff,_fi,_fu,_fs,1,0,0,0,2,_fname)

'SetFont w1,getstartpath+"Dina.fnt",8,400,0
SendMessage(w1,WM_SETFONT,hfont,1)

Move w1,10,20:Print w1,"Font Test Aurel Small"


CONTROL w1,"RE,,7,35,570,294,0x50B010C4,1"
SendMessage(w1,WM_SETFONT,hfont,1,1)
'+SETCONTROLTEXT w1,1,"Widea"



'---------------------------------------------------------
run=1
waituntil run=0
'stoptimer w1
closewindow w1
end

'-------------------------------------------------------
Sub main
Select @class
Case @idclosewindow
run=0
Case @idcreate
Centerwindow w1
Endselect
Return
Title: Re: New Font
Post by: LarryMc on April 04, 2010, 08:41:54 AM
Zlatko

The last parameter, fname, is not the name of a file; it is the name of a font typeface like "Tahoma".

You have to create a font file; register it on your computer; and then the font name will appear on your computer.

LarryMc
Title: Re: New Font
Post by: sapero on April 04, 2010, 08:43:17 AM
You need first to load the font with AddFontResourceA(path) api from gdi32.dll, then call CreateFont (passing font name instead path).
Title: Re: New Font
Post by: aurelCB on April 05, 2010, 01:51:23 AM
Oh my...
I forget about AddFontResourceA(fpath:string),INT  ::)
Thanks Sapero.. :)


'main window app
Def w1:window
Def hfont:uINT
CONST WM_SETFONT = 0x30
CONST DEFAULT_CHARSET = 1
CONST ANSI_CHARSET = 0

Declare "gdi32", CreateFontA(nHeight:INT,nWidth:INT,nEsc:INT,nOri:INT,fnWeight:INT,fnItalic:INT,fnUnderline:INT,fnStrikeOut:INT,fnCharSet:INT,fnOutPrecision:INT,fnClipPrecision:INT,fnQuality:INT,fnPAFamily:INT,fnName:STRING),INT
Declare "gdi32",AddFontResourceA(fpath:string),INT

Window w1,0,0,500,400,@minbox,0,"MainGUI",main
Setwindowcolor w1,rgb(220,220,220)
'--------------------------------------------------------

AddFontResourceA(getstartpath+"C:\Program Files\Ionic Wind\Creative BASIC\samples\Dina.fon")
hfont = CreateFontA(12,0,0,0,400,0,0,0,1,0,0,0,1,"Dina")

' not work for window
SendMessage(w1,WM_SETFONT,hfont,1)
' this work for window
SetFont w1,"Dina",9,400,0

Move w1,10,20:Print w1,"Font Test Dina 9"

'work for control font
CONTROL w1,"E,,7,65,470,294,0x50B010C4,1"
SendMessage(w1,WM_SETFONT,hfont,1,1)

SetControlText w1,1,"Font Test Dina 9"



'---------------------------------------------------------
run=1
waituntil run=0
'stoptimer w1
closewindow w1
end

'-------------------------------------------------------
Sub main
Select @class
Case @idclosewindow
run=0
Case @idcreate
Centerwindow w1
Endselect
Return
Title: Re: New Font
Post by: sapero on April 05, 2010, 04:13:23 AM
(getstartpath+"C:\Program Files
Huh? This is a path to alternate data stream (probably still invalid, not supported), not to a normal file ;)
Title: Re: New Font
Post by: aurelCB on April 05, 2010, 07:16:36 AM
Dont worry man now works fine :)
Yes Sapero you right:
this is right
AddFontResourceA(getstartpath+"Dina.fon")
hfont = CreateFontA(12,0,0,0,400,0,0,0,1,0,0,0,1,"Dina")