LoadFont inside StartDrawing-block

Just starting out? Need help? Post your questions and find answers here.
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

LoadFont inside StartDrawing-block

Post by es_91 »

The debugger still complains about usings of LoadFont inside a StartDrawing/StopDrawing block.

Turning off the debugger, it works however. :|
:mrgreen:
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: LoadFont inside StartDrawing-block

Post 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...
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
es_91
Enthusiast
Enthusiast
Posts: 298
Joined: Thu Jan 27, 2011 12:00 pm
Location: DE

Re: LoadFont inside StartDrawing-block

Post 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.
:mrgreen:
Fred
Administrator
Administrator
Posts: 18150
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: LoadFont inside StartDrawing-block

Post by Fred »

Yes, LoadFont() doesn't always work in startdrawing block, that's why the debugger complains. I don't see a problem here.
Post Reply