LoadFont() and *.fon
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
LoadFont() and *.fon
Hello at all
I try without succes to load several font at the format ".FON"
LoadFont() can manage this format ?
Have a good day
I try without succes to load several font at the format ".FON"
LoadFont() can manage this format ?
Have a good day

Not a destination
- RSBasic
- Moderator
- Posts: 1228
- Joined: Thu Dec 31, 2009 11:05 pm
- Location: Gernsbach (Germany)
- Contact:
Re: LoadFont() and *.fon
Yes, but you must register your font. Example for Windows: http://www.rsbasic.de/aktualisierung/wi ... 20laden.pb
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: LoadFont() and *.fon
Thanks for your quick answer.
Well i try again, it's strange impossible to load several fon, perhaps too old ...
Again thanks
Well i try again, it's strange impossible to load several fon, perhaps too old ...
Again thanks

Not a destination
Re: LoadFont() and *.fon
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 :

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 :

- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: LoadFont() and *.fon
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:

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

Not a destination
Re: LoadFont() and *.fon
You forgot to add the font resource. See my comments :
This work in canvas... but i don't know why the vector drawing not work....
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
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: LoadFont() and *.fon
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

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 ??
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
Yes it's exactely that my problemThis work in canvas... but i don't know why the vector drawing not work....

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

Not a destination
Re: LoadFont() and *.fon
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 !
If it so... it should be mentioned in the help !
- Kwai chang caine
- Always Here
- Posts: 5494
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: LoadFont() and *.fon
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

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

Not a destination