[MaxGUI] Canvas and fonts

BlitzMax Forums/BlitzMax Programming/[MaxGUI] Canvas and fonts

Hi
I have a small problem. I would like to load a font with "RequestFont" and set it to my canvas (DrawText).
My first idea:

SuperStrict 

Local Quit:Int 
Local Window:TGadget
Local Canvas:TGadget


Window = CreateWindow("Font Test", 100,100,400,400)
Canvas = CreateCanvas(0,0,ClientWidth(Window), ClientHeight(Window), Window)

SetGadgetLayout canvas, EDGE_ALIGNED,0, EDGE_ALIGNED,0



Quit = False




Repeat 

	WaitEvent()
	
	Select EventID()
	
		Case EVENT_WINDOWCLOSE
			Quit = True
		
		
		Case EVENT_WINDOWSIZE
			SetGadgetShape canvas, 0,0,ClientWidth(Window), ClientHeight(Window)
		
		
		Case EVENT_MOUSEDOWN
		
			Local TempFont:TGUiFont = RequestFont()
			
			If TempFont
				Print "Font loaded"
				SetGadgetFont Canvas, TempFont
			EndIf
			
		
		
		Case EVENT_GADGETPAINT
			
			Select EventSource()
			
				Case Canvas
				
					SetGraphics CanvasGraphics(Canvas)
					SetViewport 0,0,GadgetWidth(Canvas), GadgetHeight(Canvas)
					
					Cls
					
					DrawText "Click to load a font",10,10
					
					Flip
					
			
			End Select 
		
	End Select 
	

Until Quit = True



No effects with this code.
If i use FontName and LoadImageFont, i can´t load every selected font from my "windows/fonts"+FontName()+".ttf" dir.
Any idea?
Thanks.
Mfg Suco

Is there a problem loading the image font?
You cant set a gadget font to the canvas, because
ist has no guitexts in it.

I think this is pixel manipulation and will not
be saved as objects, more as a PixMap.
So you can' set Gadget fonts.

There's just one way I think. Load the imagefont
or use labels to represent texts.

EDIT: As the result, you can only set Fonts per RequestFont,
which returns a GUI font, to GUI Objects. Drawtext isnt
a GUI object i think.

Hope you understood by bad english, german friend ,D

IMurDOOM

In Bplus you can load a Reuqested font for a canvas with LoadFont and the data (FontName, FontSize) from the RequestedFont.
But in Bmax I can´t see a way to load an ImageFont by the Name (FontName, FontSize) of the requested Font.

Look at this

		Case EVENT_MOUSEDOWN
		
			Local TempFont:TGUiFont = RequestFont()
			
			If TempFont
				Local FontPath:String = "C:\WINDOWS\Fonts"+FontName(TempFont)+".ttf"
				Local ImageFont:TImageFont = LoadImageFont(FontPath, FontSize(TempFont))
				Print "Font Path: "+FontPath
				If ImageFont
					Print "ImageFont loaded"
					SetImageFont ImageFont
				EndIf
				
			EndIf


It´s a bad solution and he can find only the Arial font..

Mfg Suco

Yes, i have the same problem, that should have
other reasons why it doesn't work (I think).

I hardcoded a few fonts and didn't got it to work.
With your solution, some fonts are working, others not.

As i said, guifonts for textareas and labels are nicely working.

Hmmmmmmmm,

IMurDOOM

Is this a bug? That's a gread problem for me! And ImageFont isn't absolutely a solution...