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
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
You need first to load the font with AddFontResourceA(path) api from gdi32.dll, then call CreateFont (passing font name instead path).
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
(getstartpath+"C:\Program Files
Huh? This is a path to alternate data stream (probably still invalid, not supported), not to a normal file ;)
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")