Page 1 of 1

LoadFont inside StartDrawing-block

Posted: Wed Jun 04, 2025 7:47 pm
by es_91
The debugger still complains about usings of LoadFont inside a StartDrawing/StopDrawing block.

Turning off the debugger, it works however. :|

Re: LoadFont inside StartDrawing-block

Posted: Wed Jun 04, 2025 11:05 pm
by boddhi
Any code?

I haven't tested it, and maybe it's a bug, but I wonder: What is the absolute necessity of including LoadFont inside a StartDrawing()/StopDrawing() block?
I've never had a problem loading a font before using such a block...

Re: LoadFont inside StartDrawing-block

Posted: Thu Jun 05, 2025 12:24 am
by es_91
Think Fred should make a decision on this.

Code: Select all


;{
	
	define  *img
	define  *fnt
	
;}


*img  =  createImage  (  #pb_any,  
                         256,  
                         256  )


if  (  startDrawing  (  imageOutput  (  *img  )  )  )

;{
	
	; this line works when the debugger is disabled:
	
	*fnt  =  loadFont  (  #pb_any,  
	                      "Lucida Console",  
	                      12  )
	
	if  (  (  *fnt  )  and  (  isFont  (  *fnt  )  )  )
	
	;{
		
		if  (  fontId  (  *fnt  )  )
		
		;{
			
			drawingFont  (  fontId  (  *fnt  )  )
			
			drawText  (  0,  
			             0,  
			             "Testtext",  
			             #white  )
			
		;}
		
		endIf
		
	;}
	
	endIf
	
	stopDrawing  (  )
	
	saveImage  (  *img,  
	              getTemporaryDirectory  (  )  +  
	              "256.bmp"  )
	
	runProgram  (  getTemporaryDirectory  (  )  +  
	               "256.bmp"  )
	
;}

endIf

Don't forget to erase the file.

Re: LoadFont inside StartDrawing-block

Posted: Thu Jun 05, 2025 6:12 am
by Fred
Yes, LoadFont() doesn't always work in startdrawing block, that's why the debugger complains. I don't see a problem here.