Page 1 of 1
LoadFont() and *.fon
Posted: Thu Mar 17, 2016 7:09 pm
by Kwai chang caine
Hello at all
I try without succes to load several font at the format ".FON"
LoadFont() can manage this format ?
Have a good day
Re: LoadFont() and *.fon
Posted: Thu Mar 17, 2016 7:14 pm
by RSBasic
Yes, but you must register your font. Example for Windows:
http://www.rsbasic.de/aktualisierung/wi ... 20laden.pb
Re: LoadFont() and *.fon
Posted: Thu Mar 17, 2016 7:36 pm
by Kwai chang caine
Thanks for your quick answer.
Well i try again, it's strange impossible to load several fon, perhaps too old ...
Again thanks
Re: LoadFont() and *.fon
Posted: Thu Mar 17, 2016 10:18 pm
by Bisonte
The special "thing" is...
The filename of the font is often not the right name for LoadFont() (Windows).
For example a font named : "Arial Unicode MS Standard.ttf" ... so we suggest Loadfont(#Font, "Arial Unicode MS Standard")...
but we have to use the "screen"-name of the font.
in my Example : LoadFont(#Font, "Arial Unicode MS") !
Many fonts have another "name"... if you double-click at a font file in windows, the fontmanager opens, and on the top is the "screen" name.
See here :

Re: LoadFont() and *.fon
Posted: Mon Mar 21, 2016 12:18 pm
by Kwai chang caine
Thanks a lot BISONTE for your really good explanation in picture
I have try like you and RsBasic say and i believe i have found the problem
In fact the behavior of TextGadget and Canvas are not the same for the same font
In the textgadget the both fonts works, but in the canvas my "ATM Display" font not works (Uncomment the line
; Police$ = "ATM Display")
Have you an idea why ?? is it the problem of my font or of the Canvas at your mind ?
My font :
http://erdsjb.free.fr/purestorage/provi ... tmros0.fon
The test:
Code: Select all
#FenetreVector = 1
#GadgetCanvas = 2
Police$ = "Times New Roman"
;Police$ = "ATM Display" ; <=========== Change the font with uncomment this line and see the problem
fontVector.i = LoadFont(#PB_Any, Police$, 10)
OpenWindow(#FenetreVector, x, y, 300, 100, "Try VectorDrawing", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
CanvasGadget(#GadgetCanvas, 0,0,300,100)
ResizeGadget(#GadgetCanvas, #PB_Ignore, #PB_Ignore, WindowWidth(#FenetreVector), WindowHeight(#FenetreVector))
StartVectorDrawing(CanvasVectorOutput(#GadgetCanvas))
VectorSourceColor(RGBA(0,0,0,255))
FillVectorOutput()
VectorFont(FontID(fontVector), 30)
VectorSourceColor(RGBA(255,0,0,255))
MovePathCursor(0, 0)
DrawVectorText(Police$)
StopVectorDrawing()
OpenWindow(0, 200, 200, 270, 160, "Chargement police...", #PB_Window_SystemMenu)
If LoadFont(1, Police$, 10)
SetGadgetFont(#PB_Default, FontID(1))
TextGadget(0, 10, 10, 250, 40, Police$)
EndIf
Repeat
Evenement = WaitWindowEvent()
Until Evenement = #PB_Event_CloseWindow
Re: LoadFont() and *.fon
Posted: Mon Mar 21, 2016 3:49 pm
by Bisonte
You forgot to add the font resource. See my comments :
Code: Select all
#FenetreVector = 1
#GadgetCanvas = 2
;Police$ = "Times New Roman"
Police$ = "ATM Display" ; <=========== Change the font with uncomment this line and see the problem
;: Add the font to the system
AddFontResource_("atmros0.fon") ; Change it to your path
SendMessage_(#HWND_BROADCAST,#WM_FONTCHANGE,0,0)
fontVector.i = LoadFont(#PB_Any, Police$, 10)
OpenWindow(#FenetreVector, x, y, 300, 100, "Try VectorDrawing", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
CanvasGadget(#GadgetCanvas, 0,0,300,100)
ResizeGadget(#GadgetCanvas, #PB_Ignore, #PB_Ignore, WindowWidth(#FenetreVector), WindowHeight(#FenetreVector))
StartVectorDrawing(CanvasVectorOutput(#GadgetCanvas))
VectorSourceColor(RGBA(0,0,0,255))
FillVectorOutput()
VectorFont(FontID(fontVector), 30)
VectorSourceColor(RGBA(255,0,0,255))
MovePathCursor(0, 0)
DrawVectorText(Police$)
StopVectorDrawing()
OpenWindow(0, 200, 200, 270, 160, "Chargement police...", #PB_Window_SystemMenu)
If LoadFont(1, Police$, 10)
SetGadgetFont(#PB_Default, FontID(1))
TextGadget(0, 10, 10, 250, 40, Police$)
EndIf
Repeat
Evenement = WaitWindowEvent()
Until Evenement = #PB_Event_CloseWindow
;: Remove the font
RemoveFontResource_("atmros0.fon") ; Change it to your path
This work in canvas... but i don't know why the vector drawing not work....
Re: LoadFont() and *.fon
Posted: Mon Mar 21, 2016 4:06 pm
by Kwai chang caine
Thanks BISONTE
But i have not forget to adding the font, because i have adding it on my machine into the "Windows\Font" directory
In fact, i'm not administrator of my machine, so your code not works here (I can't adding font with code)
But the "ATM Display" appears when even here, in the TextGadget without adding font, because she is in my window font directory
This work in canvas... but i don't know why the vector drawing not work....
Yes it's exactely that my problem

You have really right, me too i don't understand why with the vector lib, my font not appears

And if you choose the "Times New Roman" font she appear in the two windows
Believe you, it's a bug of the libVector ??
Re: LoadFont() and *.fon
Posted: Tue Mar 22, 2016 12:09 am
by Bisonte
I think the different is the font itself. .ttf (like Times) is a TrueTypeFont. .fon not... And VectorFont() needs truetype fonts... maybe this is the answer.
If it so... it should be mentioned in the help !
Re: LoadFont() and *.fon
Posted: Tue Mar 22, 2016 9:40 am
by Kwai chang caine
Yes it's what i have thinking too, LibVector can't use "*.FON"
But for be sure i have continued to test another fonts, Kcc is null but persistent
And effectively several ".fon" not works ...when miracle ....i have found another font "System Gras" (VGASYS.fon) who works
It's incredible !!!! why this font works and not others ???
Just FRED, perhaps can be say that ?
If you have the desire and the time, you can see yourself
http://erdsjb.free.fr/purestorage/provi ... vgasys.fon