LoadFont() and *.fon

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

LoadFont() and *.fon

Post 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
ImageThe happiness is a road...
Not a destination
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: LoadFont() and *.fon

Post by RSBasic »

Yes, but you must register your font. Example for Windows: http://www.rsbasic.de/aktualisierung/wi ... 20laden.pb
Image
Image
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: LoadFont() and *.fon

Post 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
ImageThe happiness is a road...
Not a destination
User avatar
Bisonte
Addict
Addict
Posts: 1313
Joined: Tue Oct 09, 2007 2:15 am

Re: LoadFont() and *.fon

Post 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 :
Image
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: LoadFont() and *.fon

Post by Kwai chang caine »

Thanks a lot BISONTE for your really good explanation in picture 8)

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 :shock:

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
ImageThe happiness is a road...
Not a destination
User avatar
Bisonte
Addict
Addict
Posts: 1313
Joined: Tue Oct 09, 2007 2:15 am

Re: LoadFont() and *.fon

Post 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....
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: LoadFont() and *.fon

Post 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 :wink:

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 :D
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 :shock:

Believe you, it's a bug of the libVector ??
ImageThe happiness is a road...
Not a destination
User avatar
Bisonte
Addict
Addict
Posts: 1313
Joined: Tue Oct 09, 2007 2:15 am

Re: LoadFont() and *.fon

Post 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 !
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: LoadFont() and *.fon

Post by Kwai chang caine »

Yes it's what i have thinking too, LibVector can't use "*.FON" :cry:

But for be sure i have continued to test another fonts, Kcc is null but persistent :mrgreen:

And effectively several ".fon" not works ...when miracle ....i have found another font "System Gras" (VGASYS.fon) who works :shock:
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 :wink:
http://erdsjb.free.fr/purestorage/provi ... vgasys.fon
ImageThe happiness is a road...
Not a destination
Post Reply